diff --git a/code/frontend/src/components/interactive/BoxRepositoryCreate.js b/code/frontend/src/components/interactive/BoxRepositoryCreate.js index 088784d..83a18fe 100644 --- a/code/frontend/src/components/interactive/BoxRepositoryCreate.js +++ b/code/frontend/src/components/interactive/BoxRepositoryCreate.js @@ -8,6 +8,8 @@ import Radio from "../base/Radio" import Button from "../base/Button" import useRepositoryEditor from "../../hooks/useRepositoryEditor" import FormAlert from "../base/formparts/FormAlert" +import goToOnSuccess from "../../utils/goToOnSuccess" +import { useHistory } from "react-router" /** @@ -28,6 +30,8 @@ export default function BoxRepositoryCreate({ ...props }) { error, } = useRepositoryEditor() + const history = useHistory() + return ( {e.preventDefault(); save()}}> @@ -68,8 +72,7 @@ export default function BoxRepositoryCreate({ ...props }) { style={{"gridColumn": "1 / 3"}} icon={faPencilAlt} color={"Green"} - goTo={"/repositories"} - onClick={e => save()} + onClick={e => goToOnSuccess(save, history, "/repositories")} > Edit repository @@ -78,8 +81,7 @@ export default function BoxRepositoryCreate({ ...props }) { style={{"gridColumn": "1 / 3"}} icon={faPlus} color={"Green"} - goTo={"/repositories"} - onClick={e => save()} + onClick={e => goToOnSuccess(save, history, "/repositories")} > Create repository diff --git a/code/frontend/src/components/providers/RepositoryEditor.js b/code/frontend/src/components/providers/RepositoryEditor.js index b0a55c9..269ceb5 100644 --- a/code/frontend/src/components/providers/RepositoryEditor.js +++ b/code/frontend/src/components/providers/RepositoryEditor.js @@ -24,16 +24,16 @@ export default function RepositoryEditor({ className, }) { /** The repository name. */ - const [_name, setName] = useState(name) + const [_name, setName] = useState(name ?? "") /** The repository state (active / archived). */ - const [_isActive, setActive] = useState(isActive) + const [_isActive, setActive] = useState(isActive ?? true) /** The start date of the data gathering. */ - const [_start, setStart] = useState(start) + const [_start, setStart] = useState(start ?? new Date().toISOString()) /** The end date of the data gathering. */ - const [_end, setEnd] = useState(end) + const [_end, setEnd] = useState(end ?? new Date().toISOString()) /** The conditions of the data gathering. */ const {