mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
feat(FE-316): Add isNextStep flag for expanded drawer flow
This commit is contained in:
@@ -5,9 +5,11 @@ import { useUiStore } from '@/stores/ui/ui.store';
|
|||||||
|
|
||||||
const ExpandedDrawerForm = () => {
|
const ExpandedDrawerForm = () => {
|
||||||
const setExpandedDrawerOpen = useUiStore((s) => s.setExpandedDrawerOpen);
|
const setExpandedDrawerOpen = useUiStore((s) => s.setExpandedDrawerOpen);
|
||||||
|
const setIsNextStep = useUiStore((s) => s.setIsNextStep);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setExpandedDrawerOpen(false);
|
setExpandedDrawerOpen(false);
|
||||||
|
setIsNextStep(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ const UniformityForm = ({
|
|||||||
const setExpandedDrawerContent = useUiStore(
|
const setExpandedDrawerContent = useUiStore(
|
||||||
(s) => s.setExpandedDrawerContent
|
(s) => s.setExpandedDrawerContent
|
||||||
);
|
);
|
||||||
|
const isNextStep = useUiStore((s) => s.isNextStep);
|
||||||
|
const setIsNextStep = useUiStore((s) => s.setIsNextStep);
|
||||||
|
|
||||||
const [uniformityFormErrorMessage, setUniformityFormErrorMessage] =
|
const [uniformityFormErrorMessage, setUniformityFormErrorMessage] =
|
||||||
useState('');
|
useState('');
|
||||||
@@ -244,7 +246,13 @@ const UniformityForm = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
toast.success(res?.message as string);
|
toast.success(res?.message as string);
|
||||||
router.push('/uniformity');
|
|
||||||
|
if (formType === 'add') {
|
||||||
|
setIsNextStep(true);
|
||||||
|
setExpandedDrawerOpen(true);
|
||||||
|
} else {
|
||||||
|
router.push('/uniformity');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -358,11 +366,6 @@ const UniformityForm = ({
|
|||||||
}
|
}
|
||||||
}, [expandedDrawerOpen, setExpandedDrawerContent]);
|
}, [expandedDrawerOpen, setExpandedDrawerContent]);
|
||||||
|
|
||||||
// ===== EVENT HANDLERS =====
|
|
||||||
const handleOpenExpandedDrawer = () => {
|
|
||||||
setExpandedDrawerOpen(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<section className='w-full'>
|
<section className='w-full'>
|
||||||
@@ -379,7 +382,7 @@ const UniformityForm = ({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className='divider mt-3'></div>
|
<div className='divider mt-3'></div>
|
||||||
<section className='w-full px-6'>
|
<section className='w-full px-6 mb-6'>
|
||||||
<h2 className='text-2xl font-semibold mb-6'>Informasi Umum</h2>
|
<h2 className='text-2xl font-semibold mb-6'>Informasi Umum</h2>
|
||||||
|
|
||||||
<form onSubmit={formik.handleSubmit} className='flex flex-col gap-6'>
|
<form onSubmit={formik.handleSubmit} className='flex flex-col gap-6'>
|
||||||
@@ -574,30 +577,21 @@ const UniformityForm = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
{!isNextStep && (
|
||||||
type='submit'
|
<Button
|
||||||
color='primary'
|
type='submit'
|
||||||
className='w-full'
|
color='primary'
|
||||||
disabled={!formik.isValid || formik.isSubmitting}
|
className='w-full'
|
||||||
>
|
disabled={!formik.isValid || formik.isSubmitting}
|
||||||
{formik.isSubmitting ? (
|
>
|
||||||
<span className='loading loading-spinner'></span>
|
{formik.isSubmitting ? (
|
||||||
) : (
|
<span className='loading loading-spinner'></span>
|
||||||
'Simpan'
|
) : (
|
||||||
)}
|
'Next'
|
||||||
</Button>
|
)}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{formType === 'add' && (
|
|
||||||
<Button
|
|
||||||
color='primary'
|
|
||||||
onClick={handleOpenExpandedDrawer}
|
|
||||||
className='mt-4 w-full'
|
|
||||||
>
|
|
||||||
<Icon icon='ic:round-plus' width={18} height={18} />
|
|
||||||
Expand Drawer
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -45,4 +45,7 @@ export const createDrawerUISlice: StateCreator<
|
|||||||
expandedDrawerContent: null as ReactNode | null,
|
expandedDrawerContent: null as ReactNode | null,
|
||||||
setExpandedDrawerContent: (content: ReactNode) =>
|
setExpandedDrawerContent: (content: ReactNode) =>
|
||||||
set({ expandedDrawerContent: content }),
|
set({ expandedDrawerContent: content }),
|
||||||
|
|
||||||
|
isNextStep: false,
|
||||||
|
setIsNextStep: (isNextStep: boolean) => set({ isNextStep }),
|
||||||
});
|
});
|
||||||
|
|||||||
Vendored
+2
@@ -16,6 +16,8 @@ type DrawerUISlice = {
|
|||||||
setExpandedDrawerOpen: (open: boolean) => void;
|
setExpandedDrawerOpen: (open: boolean) => void;
|
||||||
expandedDrawerContent: ReactNode | null;
|
expandedDrawerContent: ReactNode | null;
|
||||||
setExpandedDrawerContent: (content: ReactNode) => void;
|
setExpandedDrawerContent: (content: ReactNode) => void;
|
||||||
|
isNextStep: boolean;
|
||||||
|
setIsNextStep: (v: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UIStore = MainUiSlice & DrawerUISlice;
|
export type UIStore = MainUiSlice & DrawerUISlice;
|
||||||
|
|||||||
Reference in New Issue
Block a user