@lukoweb/apitogo 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +168 -57
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +2 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
|
@@ -1,616 +1,620 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { Button, type ButtonProps } from "@lukoweb/apitogo/ui/Button.js";
|
|
8
|
-
import {
|
|
9
|
-
CardContent,
|
|
10
|
-
CardDescription,
|
|
11
|
-
CardHeader,
|
|
12
|
-
CardTitle,
|
|
13
|
-
} from "@lukoweb/apitogo/ui/Card.js";
|
|
14
|
-
import { Input } from "@lukoweb/apitogo/ui/Input.js";
|
|
15
|
-
import { Separator } from "@lukoweb/apitogo/ui/Separator.js";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
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
|
-
enableUsernamePassword
|
|
145
|
-
enableEmailLink
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
const
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
</
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
>
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
</
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
<
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
>
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
1
|
+
import { ActionButton } from "@lukoweb/apitogo/ui/ActionButton.js";
|
|
2
|
+
import {
|
|
3
|
+
Alert,
|
|
4
|
+
AlertDescription,
|
|
5
|
+
AlertTitle,
|
|
6
|
+
} from "@lukoweb/apitogo/ui/Alert.js";
|
|
7
|
+
import { Button, type ButtonProps } from "@lukoweb/apitogo/ui/Button.js";
|
|
8
|
+
import {
|
|
9
|
+
CardContent,
|
|
10
|
+
CardDescription,
|
|
11
|
+
CardHeader,
|
|
12
|
+
CardTitle,
|
|
13
|
+
} from "@lukoweb/apitogo/ui/Card.js";
|
|
14
|
+
import { Input } from "@lukoweb/apitogo/ui/Input.js";
|
|
15
|
+
import { Separator } from "@lukoweb/apitogo/ui/Separator.js";
|
|
16
|
+
import { useMutation } from "@tanstack/react-query";
|
|
17
|
+
import React from "react";
|
|
18
|
+
import { useForm } from "react-hook-form";
|
|
19
|
+
import { Link, useNavigate, useSearchParams } from "react-router";
|
|
20
|
+
import {
|
|
21
|
+
Form,
|
|
22
|
+
FormControl,
|
|
23
|
+
FormItem,
|
|
24
|
+
FormLabel,
|
|
25
|
+
FormMessage,
|
|
26
|
+
} from "../../ui/Form.js";
|
|
27
|
+
import { cn } from "../../util/cn.js";
|
|
28
|
+
import { getRelativeRedirectUrl } from "../utils/relativeRedirectUrl.js";
|
|
29
|
+
import { AuthCard } from "./AuthCard.js";
|
|
30
|
+
import AppleIcon from "./icons/Apple.js";
|
|
31
|
+
import FacebookIcon from "./icons/Facebook.js";
|
|
32
|
+
import GithubIcon from "./icons/Github.js";
|
|
33
|
+
import GoogleIcon from "./icons/Google.js";
|
|
34
|
+
import MicrosoftIcon from "./icons/Microsoft.js";
|
|
35
|
+
import XIcon from "./icons/X.js";
|
|
36
|
+
|
|
37
|
+
export const AUTH_PROVIDER_NAMES: Record<AuthProviderId, string> = {
|
|
38
|
+
google: "Google",
|
|
39
|
+
github: "GitHub",
|
|
40
|
+
facebook: "Facebook",
|
|
41
|
+
twitter: "X",
|
|
42
|
+
x: "X",
|
|
43
|
+
microsoft: "Microsoft",
|
|
44
|
+
apple: "Apple",
|
|
45
|
+
yahoo: "Yahoo",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type AuthProviderId = keyof typeof ProviderIcons;
|
|
49
|
+
|
|
50
|
+
const ProviderIcons = {
|
|
51
|
+
google: GoogleIcon,
|
|
52
|
+
github: GithubIcon,
|
|
53
|
+
facebook: FacebookIcon,
|
|
54
|
+
twitter: XIcon,
|
|
55
|
+
x: XIcon,
|
|
56
|
+
apple: AppleIcon,
|
|
57
|
+
microsoft: MicrosoftIcon,
|
|
58
|
+
yahoo: React.Fragment,
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
const isValidAuthProviderId = (
|
|
62
|
+
provider: string,
|
|
63
|
+
): provider is AuthProviderId => {
|
|
64
|
+
return provider in ProviderIcons;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const isAuthProviderIdArray = (
|
|
68
|
+
providers: string[],
|
|
69
|
+
): providers is AuthProviderId[] => {
|
|
70
|
+
return providers.every(isValidAuthProviderId);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const AuthProviderButton = ({
|
|
74
|
+
providerId,
|
|
75
|
+
onClick,
|
|
76
|
+
...buttonProps
|
|
77
|
+
}: { providerId: AuthProviderId; onClick?: () => void } & ButtonProps) => {
|
|
78
|
+
const IconRenderer = ProviderIcons[providerId];
|
|
79
|
+
return (
|
|
80
|
+
<Button
|
|
81
|
+
variant="outline"
|
|
82
|
+
className="gap-2"
|
|
83
|
+
onClick={onClick}
|
|
84
|
+
{...buttonProps}
|
|
85
|
+
>
|
|
86
|
+
<IconRenderer className="w-4 h-4 fill-foreground" />
|
|
87
|
+
{AUTH_PROVIDER_NAMES[providerId]}
|
|
88
|
+
</Button>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
type FormFields = {
|
|
93
|
+
email: string;
|
|
94
|
+
password: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const EmailPasswordForm = ({
|
|
98
|
+
form,
|
|
99
|
+
onSubmit,
|
|
100
|
+
submitLabel,
|
|
101
|
+
isPending,
|
|
102
|
+
}: {
|
|
103
|
+
form: ReturnType<typeof useForm<FormFields>>;
|
|
104
|
+
onSubmit: (data: FormFields) => void;
|
|
105
|
+
submitLabel: string;
|
|
106
|
+
isPending: boolean;
|
|
107
|
+
}) => {
|
|
108
|
+
return (
|
|
109
|
+
<Form {...form}>
|
|
110
|
+
<form
|
|
111
|
+
onSubmit={form.handleSubmit(onSubmit)}
|
|
112
|
+
className="flex flex-col gap-2"
|
|
113
|
+
>
|
|
114
|
+
<FormItem>
|
|
115
|
+
<FormLabel>E-Mail</FormLabel>
|
|
116
|
+
<FormControl>
|
|
117
|
+
<Input placeholder="Email" {...form.register("email")} />
|
|
118
|
+
</FormControl>
|
|
119
|
+
<FormMessage />
|
|
120
|
+
</FormItem>
|
|
121
|
+
<FormItem>
|
|
122
|
+
<FormLabel>Password</FormLabel>
|
|
123
|
+
<FormControl>
|
|
124
|
+
<Input
|
|
125
|
+
placeholder="Password"
|
|
126
|
+
{...form.register("password")}
|
|
127
|
+
type="password"
|
|
128
|
+
/>
|
|
129
|
+
</FormControl>
|
|
130
|
+
<FormMessage />
|
|
131
|
+
</FormItem>
|
|
132
|
+
<ActionButton type="submit" isPending={isPending}>
|
|
133
|
+
{submitLabel}
|
|
134
|
+
</ActionButton>
|
|
135
|
+
</form>
|
|
136
|
+
</Form>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const ZudokuSignInUi = ({
|
|
141
|
+
providers,
|
|
142
|
+
onOAuthSignIn,
|
|
143
|
+
onUsernamePasswordSignIn,
|
|
144
|
+
enableUsernamePassword,
|
|
145
|
+
enableEmailLink,
|
|
146
|
+
}: {
|
|
147
|
+
providers: string[];
|
|
148
|
+
enableUsernamePassword: boolean;
|
|
149
|
+
enableEmailLink?: boolean;
|
|
150
|
+
onOAuthSignIn: (providerId: string) => Promise<void>;
|
|
151
|
+
onUsernamePasswordSignIn: (email: string, password: string) => Promise<void>;
|
|
152
|
+
}) => {
|
|
153
|
+
const navigate = useNavigate();
|
|
154
|
+
const [searchParams] = useSearchParams();
|
|
155
|
+
const redirectTo = searchParams.get("redirectTo");
|
|
156
|
+
|
|
157
|
+
const relativeRedirectTo = getRelativeRedirectUrl(redirectTo);
|
|
158
|
+
|
|
159
|
+
const invalidProviders = providers.filter(
|
|
160
|
+
(provider) => !isValidAuthProviderId(provider),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (invalidProviders.length > 0) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Unsupported auth provider: ${invalidProviders.join(", ")}`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!isAuthProviderIdArray(providers)) {
|
|
170
|
+
throw new Error(`Unsupported auth provider: ${providers.join(", ")}`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const signInUsernameMutation = useMutation({
|
|
174
|
+
mutationFn: ({ email, password }: FormFields) =>
|
|
175
|
+
onUsernamePasswordSignIn(email, password),
|
|
176
|
+
onSuccess: () => {
|
|
177
|
+
void navigate(relativeRedirectTo);
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const signInByProviderMutation = useMutation({
|
|
181
|
+
mutationFn: ({ providerId }: { providerId: string }) =>
|
|
182
|
+
onOAuthSignIn(providerId),
|
|
183
|
+
onSuccess: () => {
|
|
184
|
+
void navigate(relativeRedirectTo);
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
const form = useForm<FormFields>({
|
|
188
|
+
defaultValues: {
|
|
189
|
+
email: "",
|
|
190
|
+
password: "",
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const pending =
|
|
195
|
+
signInUsernameMutation.isPending || signInByProviderMutation.isPending;
|
|
196
|
+
|
|
197
|
+
const error = signInUsernameMutation.error ?? signInByProviderMutation.error;
|
|
198
|
+
|
|
199
|
+
const hasEmailMethod = enableUsernamePassword || enableEmailLink;
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<AuthCard>
|
|
203
|
+
<CardHeader>
|
|
204
|
+
<CardTitle>Sign in</CardTitle>
|
|
205
|
+
<CardDescription>Sign in to your account to continue.</CardDescription>
|
|
206
|
+
</CardHeader>
|
|
207
|
+
<CardContent className="flex flex-col gap-4">
|
|
208
|
+
{error && (
|
|
209
|
+
<Alert variant="destructive">
|
|
210
|
+
<AlertTitle>Error</AlertTitle>
|
|
211
|
+
<AlertDescription>{error?.message}</AlertDescription>
|
|
212
|
+
</Alert>
|
|
213
|
+
)}
|
|
214
|
+
{enableUsernamePassword && (
|
|
215
|
+
<>
|
|
216
|
+
<EmailPasswordForm
|
|
217
|
+
form={form}
|
|
218
|
+
onSubmit={(data) =>
|
|
219
|
+
void signInUsernameMutation.mutate({
|
|
220
|
+
email: data.email,
|
|
221
|
+
password: data.password,
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
submitLabel="Sign in"
|
|
225
|
+
isPending={pending}
|
|
226
|
+
/>
|
|
227
|
+
<Link
|
|
228
|
+
to="/reset-password"
|
|
229
|
+
className="text-sm text-muted-foreground text-right -mt-2"
|
|
230
|
+
>
|
|
231
|
+
Forgot password?
|
|
232
|
+
</Link>
|
|
233
|
+
</>
|
|
234
|
+
)}
|
|
235
|
+
{hasEmailMethod && providers.length > 0 && (
|
|
236
|
+
<ProviderSeparator providers={providers} />
|
|
237
|
+
)}
|
|
238
|
+
{providers.length > 0 && (
|
|
239
|
+
<ProviderButtons
|
|
240
|
+
providers={providers}
|
|
241
|
+
onClick={(providerId) =>
|
|
242
|
+
signInByProviderMutation.mutate({ providerId })
|
|
243
|
+
}
|
|
244
|
+
/>
|
|
245
|
+
)}
|
|
246
|
+
<div className="flex flex-col gap-1">
|
|
247
|
+
{enableEmailLink && (
|
|
248
|
+
<Link
|
|
249
|
+
to={
|
|
250
|
+
redirectTo
|
|
251
|
+
? `/signin/email-link?redirectTo=${encodeURIComponent(redirectTo)}`
|
|
252
|
+
: "/signin/email-link"
|
|
253
|
+
}
|
|
254
|
+
className="text-sm text-muted-foreground"
|
|
255
|
+
>
|
|
256
|
+
Sign in with email link
|
|
257
|
+
</Link>
|
|
258
|
+
)}
|
|
259
|
+
<Link to="/signup" className="text-sm text-muted-foreground">
|
|
260
|
+
Don't have an account? Sign up.
|
|
261
|
+
</Link>
|
|
262
|
+
</div>
|
|
263
|
+
</CardContent>
|
|
264
|
+
</AuthCard>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const ZudokuSignUpUi = ({
|
|
269
|
+
providers,
|
|
270
|
+
enableUsernamePassword,
|
|
271
|
+
enableEmailLink,
|
|
272
|
+
onOAuthSignUp,
|
|
273
|
+
onUsernamePasswordSignUp,
|
|
274
|
+
}: {
|
|
275
|
+
providers: string[];
|
|
276
|
+
enableUsernamePassword: boolean;
|
|
277
|
+
enableEmailLink?: boolean;
|
|
278
|
+
onOAuthSignUp: (providerId: string) => Promise<void>;
|
|
279
|
+
onUsernamePasswordSignUp: (email: string, password: string) => Promise<void>;
|
|
280
|
+
}) => {
|
|
281
|
+
const navigate = useNavigate();
|
|
282
|
+
const [searchParams] = useSearchParams();
|
|
283
|
+
const redirectTo = searchParams.get("redirectTo");
|
|
284
|
+
|
|
285
|
+
const relativeRedirectTo = getRelativeRedirectUrl(redirectTo);
|
|
286
|
+
|
|
287
|
+
if (!isAuthProviderIdArray(providers)) {
|
|
288
|
+
throw new Error("Invalid auth provider IDs");
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const signUpUsernameMutation = useMutation({
|
|
292
|
+
mutationFn: async ({ email, password }: FormFields) => {
|
|
293
|
+
await onUsernamePasswordSignUp(email, password);
|
|
294
|
+
},
|
|
295
|
+
onSuccess: () => {
|
|
296
|
+
void navigate(relativeRedirectTo);
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
const signUpByProviderMutation = useMutation({
|
|
301
|
+
mutationFn: async ({ providerId }: { providerId: string }) => {
|
|
302
|
+
await onOAuthSignUp(providerId);
|
|
303
|
+
},
|
|
304
|
+
onSuccess: () => {
|
|
305
|
+
void navigate(relativeRedirectTo);
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const form = useForm<FormFields>({
|
|
310
|
+
defaultValues: {
|
|
311
|
+
email: "",
|
|
312
|
+
password: "",
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const pending =
|
|
317
|
+
signUpUsernameMutation.isPending || signUpByProviderMutation.isPending;
|
|
318
|
+
|
|
319
|
+
const error = signUpUsernameMutation.error ?? signUpByProviderMutation.error;
|
|
320
|
+
|
|
321
|
+
const hasEmailMethod = enableUsernamePassword || enableEmailLink;
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<AuthCard>
|
|
325
|
+
<CardHeader>
|
|
326
|
+
<CardTitle>Sign up</CardTitle>
|
|
327
|
+
<CardDescription>Sign up to your account to continue.</CardDescription>
|
|
328
|
+
</CardHeader>
|
|
329
|
+
<CardContent className="flex flex-col gap-4">
|
|
330
|
+
{error && (
|
|
331
|
+
<Alert variant="destructive">
|
|
332
|
+
<AlertTitle>Error</AlertTitle>
|
|
333
|
+
<AlertDescription>{error?.message}</AlertDescription>
|
|
334
|
+
</Alert>
|
|
335
|
+
)}
|
|
336
|
+
|
|
337
|
+
{enableUsernamePassword && (
|
|
338
|
+
<EmailPasswordForm
|
|
339
|
+
form={form}
|
|
340
|
+
onSubmit={(data) =>
|
|
341
|
+
void signUpUsernameMutation.mutate({
|
|
342
|
+
email: data.email,
|
|
343
|
+
password: data.password,
|
|
344
|
+
})
|
|
345
|
+
}
|
|
346
|
+
submitLabel="Sign up"
|
|
347
|
+
isPending={pending}
|
|
348
|
+
/>
|
|
349
|
+
)}
|
|
350
|
+
{hasEmailMethod && providers.length > 0 && (
|
|
351
|
+
<ProviderSeparator providers={providers} />
|
|
352
|
+
)}
|
|
353
|
+
{providers.length > 0 && (
|
|
354
|
+
<ProviderButtons
|
|
355
|
+
providers={providers}
|
|
356
|
+
onClick={(providerId) =>
|
|
357
|
+
signUpByProviderMutation.mutate({ providerId })
|
|
358
|
+
}
|
|
359
|
+
/>
|
|
360
|
+
)}
|
|
361
|
+
<div className="flex flex-col gap-1">
|
|
362
|
+
{enableEmailLink && (
|
|
363
|
+
<Link
|
|
364
|
+
to={
|
|
365
|
+
redirectTo
|
|
366
|
+
? `/signin/email-link?redirectTo=${encodeURIComponent(redirectTo)}`
|
|
367
|
+
: "/signin/email-link"
|
|
368
|
+
}
|
|
369
|
+
className="text-sm text-muted-foreground"
|
|
370
|
+
>
|
|
371
|
+
Sign in with email link
|
|
372
|
+
</Link>
|
|
373
|
+
)}
|
|
374
|
+
<Link to="/signin" className="text-sm text-muted-foreground">
|
|
375
|
+
Already have an account? Sign in.
|
|
376
|
+
</Link>
|
|
377
|
+
</div>
|
|
378
|
+
</CardContent>
|
|
379
|
+
</AuthCard>
|
|
380
|
+
);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const ProviderButtons = ({
|
|
384
|
+
providers,
|
|
385
|
+
onClick,
|
|
386
|
+
}: {
|
|
387
|
+
providers: AuthProviderId[];
|
|
388
|
+
onClick: (providerId: string) => void;
|
|
389
|
+
}) => {
|
|
390
|
+
return (
|
|
391
|
+
<div
|
|
392
|
+
className={cn(
|
|
393
|
+
"grid grid-cols-2 gap-2",
|
|
394
|
+
providers.length % 2 === 0 ? "grid-cols-2" : "grid-cols-1",
|
|
395
|
+
)}
|
|
396
|
+
>
|
|
397
|
+
{providers.map((provider) => (
|
|
398
|
+
<AuthProviderButton
|
|
399
|
+
key={provider}
|
|
400
|
+
providerId={provider}
|
|
401
|
+
onClick={() => onClick(provider)}
|
|
402
|
+
/>
|
|
403
|
+
))}
|
|
404
|
+
</div>
|
|
405
|
+
);
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
const ProviderSeparator = ({ providers }: { providers: AuthProviderId[] }) => {
|
|
409
|
+
return (
|
|
410
|
+
providers.length > 0 && (
|
|
411
|
+
<Separator className="my-3 relative">
|
|
412
|
+
<span className="bg-card text-muted-foreground text-sm px-2 absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">
|
|
413
|
+
or continue with
|
|
414
|
+
</span>
|
|
415
|
+
</Separator>
|
|
416
|
+
)
|
|
417
|
+
);
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export const ZudokuPasswordResetUi = ({
|
|
421
|
+
onPasswordReset,
|
|
422
|
+
}: {
|
|
423
|
+
onPasswordReset: (email: string) => Promise<void>;
|
|
424
|
+
}) => {
|
|
425
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
426
|
+
|
|
427
|
+
const passwordResetMutation = useMutation({
|
|
428
|
+
mutationFn: async ({ email }: { email: string }) => {
|
|
429
|
+
await onPasswordReset(email);
|
|
430
|
+
},
|
|
431
|
+
onSuccess: () => {
|
|
432
|
+
setIsSubmitted(true);
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
const form = useForm<{ email: string }>({
|
|
437
|
+
defaultValues: {
|
|
438
|
+
email: "",
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
const error = passwordResetMutation.error;
|
|
443
|
+
|
|
444
|
+
return (
|
|
445
|
+
<AuthCard>
|
|
446
|
+
<CardHeader>
|
|
447
|
+
<CardTitle>Reset password</CardTitle>
|
|
448
|
+
<CardDescription>
|
|
449
|
+
{isSubmitted
|
|
450
|
+
? "Check your email for a password reset link."
|
|
451
|
+
: "Enter your email address and we'll send you a link to reset your password."}
|
|
452
|
+
</CardDescription>
|
|
453
|
+
</CardHeader>
|
|
454
|
+
<CardContent className="flex flex-col gap-4">
|
|
455
|
+
{error && (
|
|
456
|
+
<Alert variant="destructive">
|
|
457
|
+
<AlertTitle>Error</AlertTitle>
|
|
458
|
+
<AlertDescription>{error?.message}</AlertDescription>
|
|
459
|
+
</Alert>
|
|
460
|
+
)}
|
|
461
|
+
{isSubmitted ? (
|
|
462
|
+
<div className="flex flex-col gap-4">
|
|
463
|
+
<Alert>
|
|
464
|
+
<AlertTitle>Email sent</AlertTitle>
|
|
465
|
+
<AlertDescription>
|
|
466
|
+
If an account exists with that email address, you will receive a
|
|
467
|
+
password reset link shortly.
|
|
468
|
+
</AlertDescription>
|
|
469
|
+
</Alert>
|
|
470
|
+
<Link to="/signin">
|
|
471
|
+
<Button variant="outline" className="w-full">
|
|
472
|
+
Back to sign in
|
|
473
|
+
</Button>
|
|
474
|
+
</Link>
|
|
475
|
+
</div>
|
|
476
|
+
) : (
|
|
477
|
+
<>
|
|
478
|
+
<Form {...form}>
|
|
479
|
+
<form
|
|
480
|
+
onSubmit={form.handleSubmit((data) =>
|
|
481
|
+
passwordResetMutation.mutate({ email: data.email }),
|
|
482
|
+
)}
|
|
483
|
+
className="flex flex-col gap-2"
|
|
484
|
+
>
|
|
485
|
+
<FormItem>
|
|
486
|
+
<FormLabel>Email</FormLabel>
|
|
487
|
+
<FormControl>
|
|
488
|
+
<Input
|
|
489
|
+
placeholder="you@example.com"
|
|
490
|
+
{...form.register("email")}
|
|
491
|
+
/>
|
|
492
|
+
</FormControl>
|
|
493
|
+
<FormMessage />
|
|
494
|
+
</FormItem>
|
|
495
|
+
<ActionButton
|
|
496
|
+
type="submit"
|
|
497
|
+
isPending={passwordResetMutation.isPending}
|
|
498
|
+
>
|
|
499
|
+
Reset password
|
|
500
|
+
</ActionButton>
|
|
501
|
+
</form>
|
|
502
|
+
</Form>
|
|
503
|
+
<Link to="/signin" className="text-sm text-muted-foreground">
|
|
504
|
+
Sign in
|
|
505
|
+
</Link>
|
|
506
|
+
</>
|
|
507
|
+
)}
|
|
508
|
+
</CardContent>
|
|
509
|
+
</AuthCard>
|
|
510
|
+
);
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
export const ZudokuPasswordUpdateUi = ({
|
|
514
|
+
onPasswordUpdate,
|
|
515
|
+
}: {
|
|
516
|
+
onPasswordUpdate: (password: string) => Promise<void>;
|
|
517
|
+
}) => {
|
|
518
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
519
|
+
|
|
520
|
+
const passwordUpdateMutation = useMutation({
|
|
521
|
+
mutationFn: async ({ password }: { password: string }) => {
|
|
522
|
+
await onPasswordUpdate(password);
|
|
523
|
+
},
|
|
524
|
+
onSuccess: () => {
|
|
525
|
+
setIsSubmitted(true);
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
const form = useForm<{ password: string; confirmPassword: string }>({
|
|
530
|
+
defaultValues: {
|
|
531
|
+
password: "",
|
|
532
|
+
confirmPassword: "",
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
const error = passwordUpdateMutation.error;
|
|
537
|
+
|
|
538
|
+
const onSubmit = (data: { password: string; confirmPassword: string }) => {
|
|
539
|
+
if (data.password !== data.confirmPassword) {
|
|
540
|
+
form.setError("confirmPassword", {
|
|
541
|
+
message: "Passwords do not match",
|
|
542
|
+
});
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
passwordUpdateMutation.mutate({ password: data.password });
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
return (
|
|
549
|
+
<AuthCard>
|
|
550
|
+
<CardHeader>
|
|
551
|
+
<CardTitle>Set new password</CardTitle>
|
|
552
|
+
<CardDescription>
|
|
553
|
+
{isSubmitted
|
|
554
|
+
? "Your password has been updated successfully."
|
|
555
|
+
: "Enter your new password below."}
|
|
556
|
+
</CardDescription>
|
|
557
|
+
</CardHeader>
|
|
558
|
+
<CardContent className="flex flex-col gap-4">
|
|
559
|
+
{error && (
|
|
560
|
+
<Alert variant="destructive">
|
|
561
|
+
<AlertTitle>Error</AlertTitle>
|
|
562
|
+
<AlertDescription>{error?.message}</AlertDescription>
|
|
563
|
+
</Alert>
|
|
564
|
+
)}
|
|
565
|
+
{isSubmitted ? (
|
|
566
|
+
<div className="flex flex-col gap-4">
|
|
567
|
+
<Alert>
|
|
568
|
+
<AlertTitle>Password updated</AlertTitle>
|
|
569
|
+
<AlertDescription>
|
|
570
|
+
Your password has been successfully updated. You can now sign in
|
|
571
|
+
with your new password.
|
|
572
|
+
</AlertDescription>
|
|
573
|
+
</Alert>
|
|
574
|
+
<Link to="/signin">
|
|
575
|
+
<Button variant="outline" className="w-full">
|
|
576
|
+
Sign in
|
|
577
|
+
</Button>
|
|
578
|
+
</Link>
|
|
579
|
+
</div>
|
|
580
|
+
) : (
|
|
581
|
+
<Form {...form}>
|
|
582
|
+
<form
|
|
583
|
+
onSubmit={form.handleSubmit(onSubmit)}
|
|
584
|
+
className="flex flex-col gap-2"
|
|
585
|
+
>
|
|
586
|
+
<FormItem>
|
|
587
|
+
<FormLabel>New password</FormLabel>
|
|
588
|
+
<FormControl>
|
|
589
|
+
<Input
|
|
590
|
+
type="password"
|
|
591
|
+
placeholder="Enter new password"
|
|
592
|
+
{...form.register("password")}
|
|
593
|
+
/>
|
|
594
|
+
</FormControl>
|
|
595
|
+
<FormMessage />
|
|
596
|
+
</FormItem>
|
|
597
|
+
<FormItem>
|
|
598
|
+
<FormLabel>Confirm password</FormLabel>
|
|
599
|
+
<FormControl>
|
|
600
|
+
<Input
|
|
601
|
+
type="password"
|
|
602
|
+
placeholder="Confirm new password"
|
|
603
|
+
{...form.register("confirmPassword")}
|
|
604
|
+
/>
|
|
605
|
+
</FormControl>
|
|
606
|
+
<FormMessage />
|
|
607
|
+
</FormItem>
|
|
608
|
+
<ActionButton
|
|
609
|
+
type="submit"
|
|
610
|
+
isPending={passwordUpdateMutation.isPending}
|
|
611
|
+
>
|
|
612
|
+
Update password
|
|
613
|
+
</ActionButton>
|
|
614
|
+
</form>
|
|
615
|
+
</Form>
|
|
616
|
+
)}
|
|
617
|
+
</CardContent>
|
|
618
|
+
</AuthCard>
|
|
619
|
+
);
|
|
620
|
+
};
|