mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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 setExpandedDrawerOpen = useUiStore((s) => s.setExpandedDrawerOpen);
|
||||
const setIsNextStep = useUiStore((s) => s.setIsNextStep);
|
||||
|
||||
const handleClose = () => {
|
||||
setExpandedDrawerOpen(false);
|
||||
setIsNextStep(false);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -56,6 +56,8 @@ const UniformityForm = ({
|
||||
const setExpandedDrawerContent = useUiStore(
|
||||
(s) => s.setExpandedDrawerContent
|
||||
);
|
||||
const isNextStep = useUiStore((s) => s.isNextStep);
|
||||
const setIsNextStep = useUiStore((s) => s.setIsNextStep);
|
||||
|
||||
const [uniformityFormErrorMessage, setUniformityFormErrorMessage] =
|
||||
useState('');
|
||||
@@ -244,7 +246,13 @@ const UniformityForm = ({
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
// ===== EVENT HANDLERS =====
|
||||
const handleOpenExpandedDrawer = () => {
|
||||
setExpandedDrawerOpen(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<section className='w-full'>
|
||||
@@ -379,7 +382,7 @@ const UniformityForm = ({
|
||||
/>
|
||||
|
||||
<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>
|
||||
|
||||
<form onSubmit={formik.handleSubmit} className='flex flex-col gap-6'>
|
||||
@@ -574,30 +577,21 @@ const UniformityForm = ({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type='submit'
|
||||
color='primary'
|
||||
className='w-full'
|
||||
disabled={!formik.isValid || formik.isSubmitting}
|
||||
>
|
||||
{formik.isSubmitting ? (
|
||||
<span className='loading loading-spinner'></span>
|
||||
) : (
|
||||
'Simpan'
|
||||
)}
|
||||
</Button>
|
||||
{!isNextStep && (
|
||||
<Button
|
||||
type='submit'
|
||||
color='primary'
|
||||
className='w-full'
|
||||
disabled={!formik.isValid || formik.isSubmitting}
|
||||
>
|
||||
{formik.isSubmitting ? (
|
||||
<span className='loading loading-spinner'></span>
|
||||
) : (
|
||||
'Next'
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
</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>
|
||||
</>
|
||||
|
||||
@@ -45,4 +45,7 @@ export const createDrawerUISlice: StateCreator<
|
||||
expandedDrawerContent: null as ReactNode | null,
|
||||
setExpandedDrawerContent: (content: ReactNode) =>
|
||||
set({ expandedDrawerContent: content }),
|
||||
|
||||
isNextStep: false,
|
||||
setIsNextStep: (isNextStep: boolean) => set({ isNextStep }),
|
||||
});
|
||||
|
||||
Vendored
+2
@@ -16,6 +16,8 @@ type DrawerUISlice = {
|
||||
setExpandedDrawerOpen: (open: boolean) => void;
|
||||
expandedDrawerContent: ReactNode | null;
|
||||
setExpandedDrawerContent: (content: ReactNode) => void;
|
||||
isNextStep: boolean;
|
||||
setIsNextStep: (v: boolean) => void;
|
||||
};
|
||||
|
||||
export type UIStore = MainUiSlice & DrawerUISlice;
|
||||
|
||||
Reference in New Issue
Block a user