2021-05-10 13:22:07 +00:00
|
|
|
import React, { useContext } from "react"
|
|
|
|
import Style from "./PageDashboard.module.css"
|
|
|
|
import classNames from "classnames"
|
|
|
|
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-10 13:22:07 +00:00
|
|
|
|
|
|
|
|
2021-05-11 16:05:01 +00:00
|
|
|
export default function PageEdit({ className, ...props }) {
|
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-11 16:05:01 +00:00
|
|
|
data => {
|
|
|
|
console.debug("Data: ", data)
|
|
|
|
return <RepositoryEditor className={Style.RepositoryEditor} {...data}/>
|
|
|
|
},
|
2021-05-11 15:05:38 +00:00
|
|
|
)
|
2021-05-10 13:22:07 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classNames(Style.PageHome, className)} {...props}>
|
|
|
|
<BoxHeader className={Style.Header}>
|
2021-05-18 16:50:02 +00:00
|
|
|
{strings.repoEdit}
|
2021-05-10 13:22:07 +00:00
|
|
|
</BoxHeader>
|
|
|
|
{contents}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|