From 3b7c7bb13fe71bd078eb0046af9c7afdd758d7aa Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 21 Apr 2026 15:52:36 +0700 Subject: [PATCH] fix: persist table filter --- .../project-flock/ProjectFlockTable.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/pages/production/project-flock/ProjectFlockTable.tsx b/src/components/pages/production/project-flock/ProjectFlockTable.tsx index 17d5227b..e3018e38 100644 --- a/src/components/pages/production/project-flock/ProjectFlockTable.tsx +++ b/src/components/pages/production/project-flock/ProjectFlockTable.tsx @@ -23,7 +23,6 @@ import { Icon } from '@iconify/react'; import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table'; import { useRouter, usePathname } from 'next/navigation'; import { ChangeEventHandler, useEffect, useMemo, useState } from 'react'; -import { useUiStore } from '@/stores/ui/ui.store'; import toast from 'react-hot-toast'; import useSWR from 'swr'; import { useFormik } from 'formik'; @@ -148,7 +147,6 @@ const RowOptionsMenu = ({ }; const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { - const { searchValue, setSearchValue, setTableState } = useUiStore(); const pathname = usePathname(); const isSuccess = useProjectFlockStore((s) => s.isSuccess); @@ -185,7 +183,11 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { category: 'category', period: 'period', }, + + persist: true, + storeName: 'project-flock-table', }); + const router = useRouter(); // ===== State ===== @@ -425,18 +427,11 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { setIsDeleteLoading(false); setRowSelection({}); }; - useEffect(() => { - updateFilter('search', searchValue); - }, [searchValue, updateFilter]); - - useEffect(() => { - setTableState('project-flock-table', pathname); - }, [pathname, setTableState]); const searchChangeHandler: ChangeEventHandler = (e) => { - setSearchValue(e.target.value); updateFilter('search', e.target.value); }; + const confirmApprovalHandler = async ( notes: string, approvalAction: 'APPROVED' | 'REJECTED'