1 import { type FC } from 'react';
2 import type { RouteChildrenProps, RouteProps } from 'react-router-dom';
3 import { Route, Switch } from 'react-router-dom';
5 import { useBulkSelect } from '@proton/pass/components/Bulk/BulkSelectProvider';
6 import { BulkView } from '@proton/pass/components/Bulk/BulkView';
7 import { ItemEdit } from '@proton/pass/components/Item/Containers/ItemEdit';
8 import { ItemHistory } from '@proton/pass/components/Item/Containers/ItemHistory';
9 import { ItemNew } from '@proton/pass/components/Item/Containers/ItemNew';
10 import { ItemView } from '@proton/pass/components/Item/Containers/ItemView';
12 import { ItemRouteContext } from './ItemRouteContext';
14 type Props = RouteChildrenProps & {
15 fallback: RouteProps['component'];
19 const ItemRoutes: FC<Props> = ({ match, fallback }) => {
20 const sub = (path: string) => `${match?.path}/${path}`;
21 const { enabled } = useBulkSelect();
23 if (enabled) return <BulkView />;
27 <Route exact path={sub('item/new/:type')} component={ItemNew} />
28 <Route exact path={sub('(trash/)?share/:shareId/item/:itemId')} component={ItemView} />
29 <Route exact path={sub('share/:shareId/item/:itemId/edit')} component={ItemEdit} />
30 <Route path={sub('(trash/)?share/:shareId/item/:itemId/history')} component={ItemHistory} />
31 <Route component={fallback} />
36 export const ItemSwitch: FC<Props> = ({ prefix, ...props }) => (
37 <ItemRouteContext.Provider value={{ prefix }}>
38 <ItemRoutes {...props} />
39 </ItemRouteContext.Provider>