mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 22:35:45 +00:00
feat(FE): add drawer ui store
This commit is contained in:
@@ -4,6 +4,7 @@ import { usePathname, useRouter } from 'next/navigation';
|
||||
import Drawer from '@/components/Drawer';
|
||||
import React, { ReactNode } from 'react';
|
||||
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
|
||||
import { useUiStore } from '@/stores/ui/ui.store';
|
||||
|
||||
export default function ProjectFlockLayout({
|
||||
children,
|
||||
@@ -12,6 +13,7 @@ export default function ProjectFlockLayout({
|
||||
}) {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const toggleValidate = useUiStore((s) => s.toggleValidate);
|
||||
|
||||
const isAdd = pathname.endsWith('/add');
|
||||
const isEdit = pathname.includes('/detail/edit');
|
||||
@@ -23,13 +25,14 @@ export default function ProjectFlockLayout({
|
||||
// const childRef = useRef<ProjectFlockFormRef>(null);
|
||||
|
||||
const handleBackdropClick = () => {
|
||||
// const isValid = childRef.current?.validate(); // 🔥 trigger validation child
|
||||
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
|
||||
if (isValid) {
|
||||
unsub(); // berhenti listen
|
||||
router.push('/production/project-flock');
|
||||
}
|
||||
});
|
||||
|
||||
// if (!isValid) {
|
||||
// toast.error('Form belum valid, Drawer tidak bisa close');
|
||||
// return;
|
||||
// }
|
||||
router.push('/production/project-flock');
|
||||
toggleValidate();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user