feat(FE): Integrate UI store for table state and search handling

This commit is contained in:
rstubryan
2026-03-04 10:56:35 +07:00
parent 4b93cb4589
commit 6e7dfebacc
3 changed files with 40 additions and 2 deletions
@@ -1,6 +1,8 @@
'use client';
import { ChangeEventHandler, useEffect, useState } from 'react';
import { usePathname } from 'next/navigation';
import { useUiStore } from '@/stores/ui/ui.store';
import useSWR from 'swr';
import {
CellContext,
@@ -121,6 +123,9 @@ const RowOptionsMenu = ({
};
const TransferToLayingsTable = () => {
const { searchValue, setSearchValue, setTableState } = useUiStore();
const pathname = usePathname();
const {
state: tableFilterState,
updateFilter,
@@ -413,7 +418,16 @@ const TransferToLayingsTable = () => {
setIsRejectLoading(false);
};
useEffect(() => {
updateFilter('search', searchValue);
}, [searchValue, updateFilter]);
useEffect(() => {
setTableState('transfer-to-laying-table', pathname);
}, [pathname, setTableState]);
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
setSearchValue(e.target.value);
updateFilter('search', e.target.value);
};