fix: Creating API token reloads app

fix: API keys unselectable in list
closes #2604
This commit is contained in:
Tom Moor
2021-10-02 22:39:37 -04:00
parent 157c3ce80f
commit 7c8675ce17
3 changed files with 17 additions and 13 deletions

View File

@@ -19,19 +19,23 @@ function APITokenNew({ onSubmit }: Props) {
const { showToast } = useToasts();
const { t } = useTranslation();
const handleSubmit = React.useCallback(async () => {
setIsSaving(true);
const handleSubmit = React.useCallback(
async (ev: SyntheticEvent<>) => {
ev.preventDefault();
setIsSaving(true);
try {
await apiKeys.create({ name });
showToast(t("API token created", { type: "success" }));
onSubmit();
} catch (err) {
showToast(err.message, { type: "error" });
} finally {
setIsSaving(false);
}
}, [t, showToast, name, onSubmit, apiKeys]);
try {
await apiKeys.create({ name });
showToast(t("API token created", { type: "success" }));
onSubmit();
} catch (err) {
showToast(err.message, { type: "error" });
} finally {
setIsSaving(false);
}
},
[t, showToast, name, onSubmit, apiKeys]
);
const handleNameChange = React.useCallback((event) => {
setName(event.target.value);