mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 22:05:45 +00:00
30 lines
642 B
TypeScript
30 lines
642 B
TypeScript
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: {} }),
|
|
});
|