Skip to content

Commit

Permalink
autosave on clicking cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
akanshaaa19 committed Nov 25, 2024
1 parent 78d8b55 commit 044a596
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/containers/Organization/Onboarding/FormLayout/FormLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ export const FormLayout = ({

useEffect(() => {
if (handleEffect) handleEffect(identifier, formik);
}, [
formik.touched?.name,
formik.values.name,
formik.values.registered_address,
formik.values.same_address,
]);
}, [formik.touched?.name, formik.values.name, formik.values.registered_address, formik.values.same_address]);

const header = (
<div className={styles.Header}>
Expand Down Expand Up @@ -123,23 +118,15 @@ export const FormLayout = ({
if (field.children) {
return (
<div className={styles.FormSection} key={key}>
<Typography
data-testid="formLabel"
variant="h5"
className={styles.SectionHeading}
>
<Typography data-testid="formLabel" variant="h5" className={styles.SectionHeading}>
{field.label}
</Typography>
<div className={styles.FormFields}>
{field.children.map((child: any, i: number) => {
return (
<div className={child.additionalStyles} key={i}>
{child.label && (
<Typography
data-testid="formLabel"
variant="h5"
className={styles.FieldLabel}
>
<Typography data-testid="formLabel" variant="h5" className={styles.FieldLabel}>
{child.label}
</Typography>
)}
Expand All @@ -161,9 +148,7 @@ export const FormLayout = ({
)}

<Field key={key} {...field} onSubmit={formik.submitForm} />
{field.fieldEndAdornment &&
field.fieldEndAdornment.show &&
field.fieldEndAdornment.component(formik)}
{field.fieldEndAdornment && field.fieldEndAdornment.show && field.fieldEndAdornment.component(formik)}
</div>
);
})}
Expand All @@ -176,6 +161,8 @@ export const FormLayout = ({
variant="outlined"
color="primary"
onClick={() => {
const payload = setPayload(formik.values);
saveData(payload, identifier);
handleStepChange(false);
}}
className={styles.Button}
Expand Down Expand Up @@ -235,9 +222,7 @@ export const FormLayout = ({
buttonOkLoading={loading}
>
<div className={styles.Modal}>
<p>
You wont be able to make changes to this page once confirmed. Do you want to go ahead?
</p>
<p>You wont be able to make changes to this page once confirmed. Do you want to go ahead?</p>
{loading && <p className={styles.Wait}>Please wait, this might take a few seconds.</p>}
</div>
</DialogBox>
Expand Down

0 comments on commit 044a596

Please sign in to comment.