|
1 | | -import { ErrorNotFound } from '#components/ErrorNotFound' |
2 | 1 | import { appRoutes } from '#data/routes' |
3 | | -import { |
4 | | - Button, |
5 | | - EmptyState, |
6 | | - HomePageLayout, |
7 | | - Spacer, |
8 | | - useTokenProvider |
9 | | -} from '@commercelayer/app-elements' |
| 2 | +import { Routes } from '@commercelayer/app-elements' |
10 | 3 | import type { FC } from 'react' |
11 | | -import { Route, Router, Switch } from 'wouter' |
| 4 | +import { Router } from 'wouter' |
12 | 5 |
|
13 | 6 | interface AppProps { |
14 | 7 | routerBase?: string |
15 | 8 | } |
16 | 9 |
|
17 | 10 | export const App: FC<AppProps> = ({ routerBase }) => { |
18 | | - const { canUser } = useTokenProvider() |
19 | | - |
20 | 11 | return ( |
21 | 12 | <Router base={routerBase}> |
22 | | - <Switch> |
23 | | - <Route path={appRoutes.home.path}> |
24 | | - <HomePageLayout title='My Sample App'> |
25 | | - <Spacer top='14'> |
26 | | - <EmptyState |
27 | | - title='Welcome' |
28 | | - description='This is a starter template. Start building your application by modifying this `App.tsx` component.' |
29 | | - /> |
30 | | - </Spacer> |
31 | | - <Spacer top='14'> |
32 | | - {canUser('create', 'orders') ? ( |
33 | | - <EmptyState |
34 | | - title="canUser('create', 'orders') ?" |
35 | | - description={ |
36 | | - <> |
37 | | - You can use the helper <code>canUser()</code> to check |
38 | | - user permissions. |
39 | | - <br /> |
40 | | - In this case, you can see that the user has permission to |
41 | | - create orders. |
42 | | - </> |
43 | | - } |
44 | | - action={ |
45 | | - <Button variant='primary'> |
46 | | - Create an Order (not implemented) |
47 | | - </Button> |
48 | | - } |
49 | | - /> |
50 | | - ) : canUser('read', 'orders') ? ( |
51 | | - <EmptyState |
52 | | - title="canUser('read', 'orders') ?" |
53 | | - description={ |
54 | | - <> |
55 | | - You can use the helper <code>canUser()</code> to check |
56 | | - user permissions. |
57 | | - <br /> |
58 | | - In this case, you can see that the user has permission to |
59 | | - read orders. |
60 | | - </> |
61 | | - } |
62 | | - /> |
63 | | - ) : ( |
64 | | - <EmptyState |
65 | | - title="canUser('read', 'orders') ?" |
66 | | - description={ |
67 | | - <> |
68 | | - You can use the helper <code>canUser()</code> to check |
69 | | - user permissions. |
70 | | - <br /> |
71 | | - In this case, you can see that the user does not have |
72 | | - permission to read orders. This is the classic "Not |
73 | | - Authorized" case. |
74 | | - </> |
75 | | - } |
76 | | - /> |
77 | | - )} |
78 | | - </Spacer> |
79 | | - </HomePageLayout> |
80 | | - </Route> |
81 | | - <Route> |
82 | | - <ErrorNotFound /> |
83 | | - </Route> |
84 | | - </Switch> |
| 13 | + <Routes |
| 14 | + routes={appRoutes} |
| 15 | + list={{ |
| 16 | + home: { |
| 17 | + component: async () => await import('#pages/Home') |
| 18 | + }, |
| 19 | + list: { |
| 20 | + component: async () => await import('#pages/List') |
| 21 | + }, |
| 22 | + details: { |
| 23 | + component: async () => await import('#pages/Details'), |
| 24 | + overlay: true |
| 25 | + } |
| 26 | + }} |
| 27 | + /> |
85 | 28 | </Router> |
86 | 29 | ) |
87 | 30 | } |
0 commit comments