added async loading state

This commit is contained in:
2025-10-07 14:05:27 +01:00
parent c2c2fc76f2
commit d927767677
2 changed files with 42 additions and 36 deletions

View File

@@ -24,8 +24,8 @@ const BearerTypeFields = () => {
verbose: verbose === "true", verbose: verbose === "true",
}; };
const handleSubmit = (values: BearerTypeFieldType) => { const handleSubmit = async (values: BearerTypeFieldType) => {
dispatcherMutation.mutate(values); await dispatcherMutation.mutateAsync(values);
}; };
return ( return (
@@ -34,6 +34,7 @@ const BearerTypeFields = () => {
onSubmit={handleSubmit} onSubmit={handleSubmit}
enableReinitialize enableReinitialize
> >
{({ isSubmitting }) => (
<Form> <Form>
<div className="flex flex-col space-y-4 px-2"> <div className="flex flex-col space-y-4 px-2">
<FormGroup> <FormGroup>
@@ -61,10 +62,13 @@ const BearerTypeFields = () => {
type="submit" type="submit"
className="bg-[#26B170] text-white px-4 py-2 rounded hover:bg-green-700 transition w-full md:w-[50%]" className="bg-[#26B170] text-white px-4 py-2 rounded hover:bg-green-700 transition w-full md:w-[50%]"
> >
Save Changes {isSubmitting || dispatcherMutation.isPending
? "Saving..."
: "Save Changes"}
</button> </button>
</div> </div>
</Form> </Form>
)}
</Formik> </Formik>
); );
}; };

View File

@@ -30,8 +30,8 @@ const ChannelFields = () => {
readTimeoutSeconds: Number(readTimeoutSeconds), readTimeoutSeconds: Number(readTimeoutSeconds),
}; };
const handleSubmit = (values: InitialValuesForm) => { const handleSubmit = async (values: InitialValuesForm) => {
backOfficeMutation.mutate(values); await backOfficeMutation.mutateAsync(values);
}; };
const ValidationToastOnce = () => { const ValidationToastOnce = () => {
@@ -84,7 +84,7 @@ const ChannelFields = () => {
enableReinitialize enableReinitialize
validate={validateValues} validate={validateValues}
> >
{({ errors, touched }) => ( {({ errors, touched, isSubmitting }) => (
<Form> <Form>
<div className="flex flex-col space-y-2 px-2"> <div className="flex flex-col space-y-2 px-2">
<FormGroup> <FormGroup>
@@ -172,7 +172,9 @@ const ChannelFields = () => {
type="submit" type="submit"
className="bg-[#26B170] text-white px-4 py-2 rounded hover:bg-green-700 transition w-full md:w-[50%]" className="bg-[#26B170] text-white px-4 py-2 rounded hover:bg-green-700 transition w-full md:w-[50%]"
> >
Save Changes {isSubmitting || backOfficeMutation.isPending
? "Saving..."
: "Save Changes"}
</button> </button>
<ValidationToastOnce /> <ValidationToastOnce />
</Form> </Form>