From ba2dfa415b426267944b4fa0c20dfb5084ff6de2 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <256895@studenti.unimore.it> Date: Mon, 10 May 2021 16:21:19 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20Archive=20and=20Unarchive=20f?= =?UTF-8?q?unctionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/interactive/RepositorySummaryBase.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/frontend/src/components/interactive/RepositorySummaryBase.js b/code/frontend/src/components/interactive/RepositorySummaryBase.js index 43a3be6..737b95f 100644 --- a/code/frontend/src/components/interactive/RepositorySummaryBase.js +++ b/code/frontend/src/components/interactive/RepositorySummaryBase.js @@ -1,10 +1,12 @@ -import React from "react" +import React, { useContext } from "react" import Style from "./RepositorySummaryBase.module.css" import classNames from "classnames" import {FontAwesomeIcon} from "@fortawesome/react-fontawesome" import Button from "../base/Button" import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons" import { useHistory } from "react-router" +import useData from "../../hooks/useData" +import ContextUser from "../../contexts/ContextUser" /** @@ -28,7 +30,11 @@ import { useHistory } from "react-router" export default function RepositorySummaryBase( { id, owner, icon, name, start, end, isActive, canDelete, canEdit, canArchive, className, ...props } ) { + const {fetchDataAuth} = useContext(ContextUser) const {history} = useHistory() + const {fetchNow: archiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"close": true}) + const {fetchNow: unarchiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"open": true}) + const {fetchNow: deletThis} = useData(fetchDataAuth, "DELETE", `/api/v1/repositories/${id}`) return (
@@ -56,6 +62,7 @@ export default function RepositorySummaryBase( @@ -73,6 +80,7 @@ export default function RepositorySummaryBase(