refactor(FE): Refactor tab actions store to use slice pattern

This commit is contained in:
rstubryan
2026-03-02 14:44:20 +07:00
parent f1ba577a97
commit 968243c370
2 changed files with 32 additions and 18 deletions
@@ -0,0 +1,29 @@
import { TabActionsSlice } from '@/stores/tab-actions/tab-actions.store';
import { StateCreator } from 'zustand';
export const createTabActionsSlice: StateCreator<
TabActionsSlice,
[],
[],
TabActionsSlice
> = (set) => ({
// Initial state
tabActions: {},
// Actions
setTabActions: (tabId, actions) =>
set((state) => ({
tabActions: {
...state.tabActions,
[tabId]: actions,
},
})),
clearTabActions: (tabId) =>
set((state) => {
const { [tabId]: _, ...rest } = state.tabActions;
return { tabActions: rest };
}),
clearAllTabActions: () => set({ tabActions: {} }),
});