mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
feat(FE): Persist Recording search across navigation
This commit is contained in:
@@ -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: '' });
|
||||
},
|
||||
});
|
||||
@@ -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',
|
||||
}
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user