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"
|
|
|
|
import BoxAlert from "../components/base/BoxAlert"
|
|
|
|
import Loading from "../components/base/Loading"
|
|
|
|
|
|
|
|
|
|
|
|
export default function PageEdit({ id, className, ...props }) {
|
2021-05-11 14:37:15 +00:00
|
|
|
const { fetchDataAuth } = useContext(ContextUser)
|
2021-05-11 14:38:56 +00:00
|
|
|
const { data, error } = useBackendImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
|
2021-05-10 13:22:07 +00:00
|
|
|
|
2021-05-11 14:37:15 +00:00
|
|
|
let contents
|
2021-05-10 13:22:07 +00:00
|
|
|
if(error) {
|
|
|
|
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
|
|
|
|
}
|
|
|
|
else if(data) {
|
|
|
|
contents = <RepositoryEditor className={Style.RepositoryEditor} {...data}/>
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
contents = <Loading/>
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classNames(Style.PageHome, className)} {...props}>
|
|
|
|
<BoxHeader className={Style.Header}>
|
|
|
|
Edit repository
|
|
|
|
</BoxHeader>
|
|
|
|
{contents}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|