split AddRepository component into two separate components to simplify the state handling

This commit is contained in:
Eduard Heimbuch
2020-12-02 13:26:31 +01:00
parent 7db33d2e65
commit dffe466405
6 changed files with 81 additions and 76 deletions

View File

@@ -49,21 +49,21 @@ const ImportRepositoryFromUrl: FC<Props> = ({ url, setImportPending }) => {
});
const [valid, setValid] = useState({ namespaceAndName: false, contact: true, importUrl: false });
const isValid = () => {
return Object.values(valid).every(v => v);
};
const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error | undefined>();
const history = useHistory();
const [t] = useTranslation("repos");
const isValid = () => Object.values(valid).every(v => v);
const handleImportLoading = (loading: boolean) => {
setLoading(loading);
setImportPending(loading);
setLoading(loading);
};
const submit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
setError(undefined);
const currentPath = history.location.pathname;
handleImportLoading(true);
apiClient