feat(FE): Persist Recording search across navigation

This commit is contained in:
rstubryan
2026-01-22 15:24:04 +07:00
parent 8e48c4d7cf
commit 756701722a
3 changed files with 88 additions and 3 deletions
+25
View File
@@ -0,0 +1,25 @@
import { StateCreator } from 'zustand';
export interface TableState {
searchValue: string;
}
export interface TableSlice {
searchValue: string;
setSearchValue: (value: string) => void;
resetSearchValue: () => void;
}
export const createTableSlice: StateCreator<TableSlice, [], [], TableSlice> = (
set
) => ({
// Initial state
searchValue: '',
// Actions
setSearchValue: (value) => set({ searchValue: value }),
resetSearchValue: () => {
return set({ searchValue: '' });
},
});
+27
View File
@@ -0,0 +1,27 @@
'use client';
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { createTableSlice } from '@/stores/table/slices/table.slice';
import type { TableSlice } from '@/stores/table/slices/table.slice';
export type TableStore = TableSlice;
export const useTableStore = create<TableStore>()(
devtools(
persist(
(...args) => ({
...createTableSlice(...args),
}),
{
name: 'table-cache',
partialize: (state) => ({
searchValue: state.searchValue,
}),
}
),
{
name: 'TableStore',
}
)
);