#58 code cleanup

changed unnecessary loading statements into form.formState.isLoading/submitting
This commit is contained in:
lucuswolfius
2025-07-16 12:32:37 -07:00
parent 741f42956a
commit ca5e8a87df
7 changed files with 28 additions and 42 deletions

View File

@@ -17,15 +17,12 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
resolver: zodResolver(KeywordOptionalDefaultsSchema),
defaultValues: keyword,
});
const [loading, setLoading] = useState(false);
const [deleteLoading, setDeleteLoading] = useState(false);
return (
<>
<form
onSubmit={form.handleSubmit(async (values) => {
setLoading(true);
await upsertKeyword(values, keyword?.id);
setLoading(false);
toast.success("Daten gespeichert");
if (!keyword) redirect(`/admin/keyword`);
})}
@@ -76,12 +73,15 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
<div className="card bg-base-200 shadow-xl col-span-6">
<div className="card-body ">
<div className="flex w-full gap-4">
<Button isLoading={loading} type="submit" className="btn btn-primary flex-1">
<Button
isLoading={form.formState.isSubmitting}
type="submit"
className="btn btn-primary flex-1"
>
Speichern
</Button>
{keyword && (
<Button
isLoading={deleteLoading}
onClick={async () => {
setDeleteLoading(true);
await deleteKeyword(keyword.id);