1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-24 14:04:19 +00:00
pds-2021-g2-nest/nest_frontend/routes/PageRepositoryEdit.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-05-10 13:22:07 +00:00
import React, { useContext } from "react"
import BoxHeader from "../components/base/BoxHeader"
import RepositoryEditor from "../components/providers/RepositoryEditor"
2021-05-11 14:38:56 +00:00
import useBackendImmediately from "../hooks/useBackendImmediately"
2021-05-10 13:22:07 +00:00
import ContextUser from "../contexts/ContextUser"
2021-05-11 15:05:38 +00:00
import renderContents from "../utils/renderContents"
2021-05-11 16:05:01 +00:00
import { useParams } from "react-router"
2021-05-18 16:50:02 +00:00
import ContextLanguage from "../contexts/ContextLanguage"
2021-05-25 02:06:14 +00:00
import PageWithHeader from "../components/base/layout/PageWithHeader"
import makeIcon from "../utils/makeIcon"
import { faPencilAlt } from "@fortawesome/free-solid-svg-icons"
2021-05-10 13:22:07 +00:00
2021-05-25 02:09:47 +00:00
export default function PageRepositoryEdit() {
2021-05-18 16:50:02 +00:00
const { strings } = useContext(ContextLanguage)
2021-05-11 16:05:01 +00:00
const { id } = useParams()
2021-05-11 14:37:15 +00:00
const { fetchDataAuth } = useContext(ContextUser)
2021-05-11 15:05:38 +00:00
const repositoryRequest = useBackendImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
const contents = renderContents(
repositoryRequest,
2021-05-25 02:09:47 +00:00
data => <RepositoryEditor {...data}/>
2021-05-11 15:05:38 +00:00
)
2021-05-10 13:22:07 +00:00
return (
2021-05-25 02:06:14 +00:00
<PageWithHeader
header={
<BoxHeader>
{makeIcon(faPencilAlt)} {strings.repoEdit}
</BoxHeader>
}
>
2021-05-10 13:22:07 +00:00
{contents}
2021-05-25 02:06:14 +00:00
</PageWithHeader>
2021-05-10 13:22:07 +00:00
)
}