feat(FE): Integrate UI store and pathname handling in table components

This commit is contained in:
rstubryan
2026-03-04 11:06:53 +07:00
parent 6e7dfebacc
commit 18ebf75aa7
3 changed files with 44 additions and 2 deletions
@@ -1,6 +1,8 @@
'use client';
import { ChangeEventHandler, useEffect, useState, useMemo } from 'react';
import { usePathname } from 'next/navigation';
import { useUiStore } from '@/stores/ui/ui.store';
import useSWR from 'swr';
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
import { useRouter } from 'next/navigation';
@@ -91,6 +93,9 @@ const RowOptionsMenu = ({
};
const ClosingsTable = () => {
const { searchValue, setSearchValue, setTableState } = useUiStore();
const pathname = usePathname();
// ===== ROUTER =====
const router = useRouter();
@@ -289,8 +294,17 @@ const ClosingsTable = () => {
);
}, [formik.values.project_status, projectStatusOptions]);
useEffect(() => {
updateFilter('search', searchValue);
}, [searchValue, updateFilter]);
useEffect(() => {
setTableState('closing-table', pathname);
}, [pathname, setTableState]);
// ===== SEARCH CHANGE HANDLER =====
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
setSearchValue(e.target.value);
updateFilter('search', e.target.value);
};