feat(FE): refactor drawer zustand store

This commit is contained in:
randy-ar
2025-12-02 11:01:53 +07:00
parent c76f3a3715
commit 6b5838b5aa
5 changed files with 28 additions and 40 deletions
+8 -10
View File
@@ -4,7 +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 { useProjectFlockUiStore } from '@/stores/ui/slices/production/project-flock.slice';
import { useUiStore } from '@/stores/ui/ui.store';
export default function ProjectFlockLayout({
children,
@@ -13,7 +13,7 @@ export default function ProjectFlockLayout({
}) {
const pathname = usePathname();
const router = useRouter();
const toggleValidate = useProjectFlockUiStore((s) => s.toggleValidate);
const toggleValidate = useUiStore((s) => s.toggleValidate);
const isAdd = pathname.endsWith('/add');
const isEdit = pathname.includes('/detail/edit');
@@ -23,14 +23,12 @@ export default function ProjectFlockLayout({
const isOpen = isAdd || isEdit || isDetail || isChickin;
const handleBackdropClick = () => {
const unsub = useProjectFlockUiStore
.getState()
.subscribeIsValid((isValid) => {
if (isValid) {
unsub(); // berhenti listen
router.push('/production/project-flock');
}
});
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
if (isValid) {
unsub(); // berhenti listen
router.push('/production/project-flock');
}
});
toggleValidate();
};