diff --git a/src/components/pages/inventory/movement/MovementTable.tsx b/src/components/pages/inventory/movement/MovementTable.tsx index c85577de..f53b0ccb 100644 --- a/src/components/pages/inventory/movement/MovementTable.tsx +++ b/src/components/pages/inventory/movement/MovementTable.tsx @@ -181,7 +181,7 @@ const MovementTable = () => {
{
{
{
{
{
{
{
{
{
{
{
{
{
{ - const { searchValue, setSearchValue, resetSearchValue } = useUiStore(); - const previousPathRef = useRef(null); + const { searchValue, setSearchValue, setTableState } = useUiStore(); + const pathname = usePathname(); const { state: tableFilterState, @@ -214,7 +215,7 @@ const RecordingTable = () => { toQueryString: getTableFilterQueryString, } = useTableFilter({ initial: { - search: searchValue, + search: '', areaFilter: '', locationFilter: '', kandangFilter: '', @@ -229,6 +230,10 @@ const RecordingTable = () => { }, }); + useEffect(() => { + updateFilter('search', searchValue); + }, [searchValue, updateFilter]); + // ===== FILTER MODAL STATE ===== const filterModal = useModal(); @@ -526,23 +531,8 @@ const RecordingTable = () => { }, []); useEffect(() => { - previousPathRef.current = window.location.pathname; - - return () => { - const currentPath = window.location.pathname; - - const isCurrentPathRecording = currentPath.includes( - '/production/recording' - ); - const isPreviousPathRecording = previousPathRef.current?.includes( - '/production/recording' - ); - - if (isPreviousPathRecording && !isCurrentPathRecording) { - resetSearchValue(); - } - }; - }, [resetSearchValue]); + setTableState('recording-table', pathname); + }, [pathname]); const searchChangeHandler = useCallback( (e: React.ChangeEvent) => {