refactor(FE): Integrate UI store and pathname sync in master-data tables

This commit is contained in:
rstubryan
2026-03-03 10:59:26 +07:00
parent 3d2e40518b
commit 4e278c5687
13 changed files with 195 additions and 45 deletions
@@ -1,6 +1,6 @@
'use client';
import { useMemo, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import useSWR from 'swr';
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
import toast from 'react-hot-toast';
@@ -18,6 +18,8 @@ import ProductionStandardTableSkeleton from '@/components/pages/master-data/prod
import { ProductionStandard } from '@/types/api/master-data/production-standard';
import { ProductionStandardApi } from '@/services/api/master-data';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { usePathname } from 'next/navigation';
import { useUiStore } from '@/stores/ui/ui.store';
const RowOptionsMenu = ({
popoverPosition = 'bottom',
@@ -99,6 +101,13 @@ const RowOptionsMenu = ({
};
const ProductionStandardTable = () => {
const { setTableState } = useUiStore();
const pathname = usePathname();
useEffect(() => {
setTableState('production-standard-table', pathname);
}, [pathname]);
const [sorting, setSorting] = useState<SortingState>([]);
const {