feat(FE): add drawer ui store

This commit is contained in:
randy-ar
2025-12-01 10:13:28 +07:00
parent 892bb19dfd
commit 2ace95a0db
6 changed files with 89 additions and 9 deletions
+9 -6
View File
@@ -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 (