const useDrawerSheetStore = create((set) => ({
drawerSheets: {},
currentRoute: null,
previousRoute: null,
addDrawerSheet: (drawerSheetObject) => {
set((state) => {
const drawerSheets = { ...state.drawerSheets };
if (drawerSheets[drawerSheetObject.name]) { drawerSheets[drawerSheetObject.name].children = drawerSheetObject.children }
else { drawerSheets[drawerSheetObject.name] = drawerSheetObject }
return { drawerSheets: drawerSheets };
});
},
removeDrawerSheet: (drawerSheetName) => {
set((state) => {
const drawerSheets = { ...state.drawerSheets };
delete drawerSheets[drawerSheetName];
return { drawerSheets: drawerSheets };
});
},
openDrawerSheet: (drawerSheetName) => {
set((state) => {
const drawerSheets = { ...state.drawerSheets };
drawerSheets[drawerSheetName].open = true;
return { drawerSheets: drawerSheets };
});
},
closeDrawerSheet: (drawerSheetName) => {
set((state) => {
const drawerSheets = { ...state.drawerSheets };
drawerSheets[drawerSheetName].open = false;
return { drawerSheets: drawerSheets };
});
},
toggleDrawerSheet: (drawerSheetName) => {
set((state) => {
const drawerSheets = { ...state.drawerSheets };
drawerSheets[drawerSheetName].open = !drawerSheets[drawerSheetName].open;
return { drawerSheets: drawerSheets };
});
},
updateDrawerSheetOpen: (drawerSheetName, open) => {
set((state) => {
const drawerSheets = { ...state.drawerSheets };
drawerSheets[drawerSheetName].open = open;
return { drawerSheets: drawerSheets };
});
},
updateNavigationState: (navigationState) => {
const currentRoute = getCurrentRouteFromNavigationState(navigationState);
set((state) => ({ currentRoute: currentRoute, previousRoute: state.currentRoute }));
}
}));
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)