diff --git a/apps/web/src/navigation/route.js b/apps/web/src/navigation/route.js index 82ba5c1d1..83366fa23 100644 --- a/apps/web/src/navigation/route.js +++ b/apps/web/src/navigation/route.js @@ -6,96 +6,12 @@ import { useStore } from "../stores/app-store"; import { useStore as useSelectionStore } from "../stores/selection-store"; function Route(props) { - const toggleSideMenu = useStore((store) => store.toggleSideMenu); - const isSelectionMode = useSelectionStore((store) => store.isSelectionMode); - const toggleSelectionMode = useSelectionStore( - (store) => store.toggleSelectionMode - ); - const selectAll = useSelectionStore((store) => store.selectAll); - const shouldSelectAll = useSelectionStore((store) => store.shouldSelectAll); const navigator = props.params.navigator || props.navigator; + return ( - {(props.route.title || props.route.params.title) && ( - <> - - - {props.canGoBack && ( - - - - )} - - - - - {props.route.title || props.route.params.title} - - - {props.route.options && isSelectionMode && ( - - {props.route.options.map((option) => ( - - - - ))} - - )} - - {props.route.params.subtitle && ( - - {props.route.params.subtitle} - - )} - {isSelectionMode && ( - { - if (shouldSelectAll) { - toggleSelectionMode(false); - } else { - selectAll(); - } - }} - > - {shouldSelectAll ? : } - - {shouldSelectAll ? "Unselect" : "Select all"} - - - )} - - )} +
{props.route.component && ( @@ -104,3 +20,104 @@ function Route(props) { ); } export default Route; + +function Header(props) { + const { route, canGoBack, backAction } = props; + const { title, titleColor, params, options } = route; + + const toggleSideMenu = useStore((store) => store.toggleSideMenu); + + if (!title && !params.title) return null; + return ( + <> + + + {canGoBack && ( + + + + )} + + + + + {title || params.title} + + + + + {params.subtitle && ( + + {params.subtitle} + + )} + + + ); +} + +function SelectionOptions(props) { + const { options } = props; + + const isSelectionMode = useSelectionStore((store) => store.isSelectionMode); + + if (!isSelectionMode || !options) return null; + return ( + + {options.map((option) => ( + + + + ))} + + ); +} + +function SelectionBox() { + const toggleSelectionMode = useSelectionStore( + (store) => store.toggleSelectionMode + ); + const selectAll = useSelectionStore((store) => store.selectAll); + const shouldSelectAll = useSelectionStore((store) => store.shouldSelectAll); + const isSelectionMode = useSelectionStore((store) => store.isSelectionMode); + + if (!isSelectionMode) return null; + return ( + { + if (shouldSelectAll) { + toggleSelectionMode(false); + } else { + selectAll(); + } + }} + > + {shouldSelectAll ? : } + + {shouldSelectAll ? "Unselect all" : "Select all"} + + + ); +}