fix(ui): add loading state to button when creating or updating a style preset

This commit is contained in:
Mary Hipp 2024-08-20 11:41:16 -04:00 committed by psychedelicious
parent e85f221aca
commit a6f6d5c400

View File

@ -30,8 +30,8 @@ export const StylePresetForm = ({
updatingStylePresetId: string | null; updatingStylePresetId: string | null;
formData: StylePresetFormData | null; formData: StylePresetFormData | null;
}) => { }) => {
const [createStylePreset] = useCreateStylePresetMutation(); const [createStylePreset, { isLoading: isCreating }] = useCreateStylePresetMutation();
const [updateStylePreset] = useUpdateStylePresetMutation(); const [updateStylePreset, { isLoading: isUpdating }] = useUpdateStylePresetMutation();
const { t } = useTranslation(); const { t } = useTranslation();
const allowPrivateStylePresets = useAppSelector((s) => s.config.allowPrivateStylePresets); const allowPrivateStylePresets = useAppSelector((s) => s.config.allowPrivateStylePresets);
@ -109,7 +109,11 @@ export const StylePresetForm = ({
<Flex justifyContent="space-between" alignItems="flex-end" gap={10}> <Flex justifyContent="space-between" alignItems="flex-end" gap={10}>
{allowPrivateStylePresets ? <StylePresetTypeField control={control} name="type" /> : <Spacer />} {allowPrivateStylePresets ? <StylePresetTypeField control={control} name="type" /> : <Spacer />}
<Button onClick={handleSubmit(handleClickSave)} isDisabled={!formState.isValid}> <Button
onClick={handleSubmit(handleClickSave)}
isDisabled={!formState.isValid}
isLoading={isCreating || isUpdating}
>
{t('common.save')} {t('common.save')}
</Button> </Button>
</Flex> </Flex>