Fix/disable cancel button on save (#6204)
# This PR - Fix #5675 - Fix #6118 Similarly to #5673 I have improved the field creation time by re-fetching data on page redirection to the object page <img width="1511" alt="Screenshot 2024-07-10 at 16 06 37" src="https://github.com/twentyhq/twenty/assets/61581306/8ef8f4cb-4334-4f4c-b5d9-fea11fd5d99a"> @FellipeMTX @Bonapara --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6bc36635eb
commit
9917fb0f9e
@ -1,6 +1,6 @@
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { FormProvider, useForm } from 'react-hook-form';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { H2Title, IconSettings } from 'twenty-ui';
|
||||
import { z } from 'zod';
|
||||
|
||||
@ -40,8 +40,8 @@ export const SettingsNewObject = () => {
|
||||
resolver: zodResolver(newObjectFormSchema),
|
||||
});
|
||||
|
||||
const canSave =
|
||||
formConfig.formState.isValid && !formConfig.formState.isSubmitting;
|
||||
const { isValid, isSubmitting } = formConfig.formState;
|
||||
const canSave = isValid && !isSubmitting;
|
||||
|
||||
const handleSave = async (
|
||||
formValues: SettingsDataModelNewObjectFormValues,
|
||||
@ -84,6 +84,7 @@ export const SettingsNewObject = () => {
|
||||
/>
|
||||
<SaveAndCancelButtons
|
||||
isSaveDisabled={!canSave}
|
||||
isCancelDisabled={isSubmitting}
|
||||
onCancel={() => navigate(settingsObjectsPagePath)}
|
||||
onSave={formConfig.handleSubmit(handleSave)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user