-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathmantine.tsx
211 lines (206 loc) · 8.96 KB
/
mantine.tsx
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import { Sandpack } from "@site/src/components/sandpack";
import React from "react";
export function MantineAuth() {
return (
<Sandpack
showNavigator
previewOnly
dependencies={{
"@refinedev/mantine": "latest",
"@refinedev/core": "latest",
"@refinedev/simple-rest": "latest",
"@refinedev/react-router": "latest",
"@refinedev/react-table": "latest",
"react-router": "^7.0.2",
"@tabler/icons-react": "^3.1.0",
"@emotion/react": "^11.8.2",
"@mantine/core": "^7.12.2",
"@mantine/hooks": "^7.12.2",
"@mantine/notifications": "^7.12.2",
}}
startRoute="/login"
files={{
"/App.tsx": {
code: AppTsxCode,
},
}}
/>
);
}
const AppTsxCode = /* tsx */ `
import React from "react";
import { Global, MantineProvider } from "@mantine/core";
import { Notifications } from "@mantine/notifications";
import { BrowserRouter, Outlet, Route, Routes } from "react-router";
import { Authenticated, Refine } from "@refinedev/core";
import {
AuthPage,
ErrorComponent,
RefineThemes,
ThemedLayoutV2,
} from "@refinedev/mantine";
import routerProvider, {
CatchAllNavigate,
NavigateToResource,
} from "@refinedev/react-router";
import dataProvider from "@refinedev/simple-rest";
export default function App() {
return (
<BrowserRouter>
<MantineProvider
theme={RefineThemes.Blue}
withNormalizeCSS
withGlobalStyles
>
<Global styles={{ body: { WebkitFontSmoothing: "auto" } }} />
<Notifications position="top-right">
<Refine
routerProvider={routerProvider}
dataProvider={dataProvider(
"https://api.fake-rest.refine.dev",
)}
authProvider={{
check: async () => ({
authenticated: false,
redirectTo: "/login",
}),
login: async () => {
return {
success: false,
};
},
logout: async () => {
return {
success: false,
};
},
onError: async () => ({}),
getIdentity: async () => ({
id: 1,
name: "John Doe",
avatar: "https://i.pravatar.cc/300",
}),
}}
resources={[
{
name: "dashboard",
list: "/",
},
]}
options={{ syncWithLocation: true }}
>
<Routes>
<Route
element={
<Authenticated
fallback={
<CatchAllNavigate to="/login" />
}
>
<ThemedLayoutV2>
<Outlet />
</ThemedLayoutV2>
</Authenticated>
}
>
<Route index element={<div>Welcome</div>} />
</Route>
<Route
element={
<Authenticated fallback={<Outlet />}>
<NavigateToResource resource="dashboard" />
</Authenticated>
}
>
<Route
path="/login"
element={
<AuthPage
type="login"
wrapperProps={{
style: {
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
minHeight: "100vh",
margin: "24px auto",
},
}}
/>
}
/>
<Route
path="/register"
element={
<AuthPage
type="register"
wrapperProps={{
style: {
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
minHeight: "100vh",
margin: "24px auto",
},
}}
/>
}
/>
<Route
path="/forgot-password"
element={
<AuthPage
type="forgotPassword"
wrapperProps={{
style: {
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
minHeight: "100vh",
margin: "24px auto",
},
}}
/>
}
/>
<Route
path="/update-password"
element={
<AuthPage
type="updatePassword"
wrapperProps={{
style: {
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
minHeight: "100vh",
margin: "24px auto",
},
}}
/>
}
/>
</Route>
<Route
element={
<Authenticated>
<ThemedLayoutV2>
<Outlet />
</ThemedLayoutV2>
</Authenticated>
}
>
<Route path="*" element={<ErrorComponent />} />
</Route>
</Routes>
</Refine>
</Notifications>
</MantineProvider>
</BrowserRouter>
);
}
`.trim();