Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import { useDispatch, useSelector } from "react-redux"; import { setPermanentView, permanentViewSelector, setAdditionalState, additionalStateSelector, } from "../../store/features/drawers/drawersSlice.ts"; import { PermanentDrawerTypes } from "../../store/features/drawers/permanentDrawerTypes.ts"; import { setCurrentVisibleTask } from "../../store/features/playbook/playbookSlice.ts"; import { PermanentDrawerTypesKeys } from "../../store/features/drawers/initialState.ts"; type DrawerState = { isOpen: boolean; openDrawer: (view: PermanentDrawerTypesKeys) => void; toggle: (view: PermanentDrawerTypesKeys) => void; closeDrawer: () => void; addAdditionalData: (data: any) => void; additionalData: any; permanentView: PermanentDrawerTypesKeys; }; function usePermanentDrawerState(): DrawerState { const permanentView = useSelector(permanentViewSelector); const additionalData = useSelector(additionalStateSelector); const dispatch = useDispatch(); const isOpen = permanentView !== PermanentDrawerTypes.DEFAULT; const openDrawerFunction = (view: PermanentDrawerTypesKeys) => { dispatch(setPermanentView(view)); }; const toggleDrawerFunction = (view: PermanentDrawerTypesKeys) => { Iif (permanentView === view) { dispatch(setPermanentView(PermanentDrawerTypes.DEFAULT)); dispatch(setCurrentVisibleTask(null)); dispatch(setAdditionalState({})); return; } dispatch(setPermanentView(view)); }; const closeDrawerFunction = () => { dispatch(setPermanentView(PermanentDrawerTypes.DEFAULT)); dispatch(setCurrentVisibleTask(null)); dispatch(setAdditionalState({})); }; const addAdditionalData = (data: any) => { dispatch(setCurrentVisibleTask(null)); dispatch(setAdditionalState(data)); }; return { isOpen, openDrawer: openDrawerFunction, closeDrawer: closeDrawerFunction, toggle: toggleDrawerFunction, addAdditionalData, additionalData, permanentView, }; } export default usePermanentDrawerState; |