@pelatform/starter 0.1.6 → 0.1.8
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/{chunk-2ZAZ77F6.js → chunk-IEJXTIKE.js} +51 -44
- package/dist/extend.d.ts +2 -7
- package/dist/extend.js +4 -39
- package/dist/index.d.ts +123 -169
- package/dist/index.js +1565 -820
- package/dist/server.js +1 -1
- package/dist/{ui-BjeCRH96.d.ts → workspace-CcGHPtq0.d.ts} +74 -225
- package/package.json +40 -21
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
defaultAuthQueryOptions,
|
|
4
|
-
fileToBase64,
|
|
5
4
|
getPasswordSchema,
|
|
6
5
|
getTranslations,
|
|
7
|
-
|
|
6
|
+
request,
|
|
7
|
+
setLastVisitedWorkspace,
|
|
8
8
|
socialProviders
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IEJXTIKE.js";
|
|
10
|
+
import {
|
|
11
|
+
WORKSPACE_SCOPED_PREFIXES
|
|
12
|
+
} from "./chunk-K5RU54UL.js";
|
|
10
13
|
|
|
11
14
|
// src/config/hook.ts
|
|
12
15
|
import { useContext } from "react";
|
|
@@ -133,7 +136,8 @@ var defaultConfig = {
|
|
|
133
136
|
},
|
|
134
137
|
custom: {
|
|
135
138
|
ACCEPT_INVITATION: "/join",
|
|
136
|
-
NEW_WORKSPACE: "/new"
|
|
139
|
+
NEW_WORKSPACE: "/new",
|
|
140
|
+
VERIFY_EMAIL: "/verify"
|
|
137
141
|
}
|
|
138
142
|
},
|
|
139
143
|
ui: {
|
|
@@ -416,6 +420,7 @@ function useDeletePasskey(options) {
|
|
|
416
420
|
const { queryKey } = useContext8(QueryContext);
|
|
417
421
|
return useAuthMutation({
|
|
418
422
|
queryKey: queryKey.listPasskeys,
|
|
423
|
+
// @ts-expect-error - passkeyClient does not exist
|
|
419
424
|
mutationFn: authClient.passkey.deletePasskey,
|
|
420
425
|
options
|
|
421
426
|
});
|
|
@@ -425,6 +430,7 @@ function useListPasskeys(options) {
|
|
|
425
430
|
const { queryKey } = useContext8(QueryContext);
|
|
426
431
|
return useAuthQuery({
|
|
427
432
|
queryKey: queryKey.listPasskeys,
|
|
433
|
+
// @ts-expect-error - passkeyClient does not exist
|
|
428
434
|
queryFn: authClient.passkey.listUserPasskeys,
|
|
429
435
|
options
|
|
430
436
|
});
|
|
@@ -469,11 +475,27 @@ function useRevokeSessions(options) {
|
|
|
469
475
|
});
|
|
470
476
|
}
|
|
471
477
|
|
|
478
|
+
// src/hooks/use-invitation.ts
|
|
479
|
+
import { useContext as useContext10 } from "react";
|
|
480
|
+
function useInvitation(params, options) {
|
|
481
|
+
const { authClient } = useConfig();
|
|
482
|
+
const { queryKey: key } = useContext10(QueryContext);
|
|
483
|
+
const queryKey = [key.invitationKey, JSON.stringify(params)];
|
|
484
|
+
return useAuthQuery({
|
|
485
|
+
queryKey,
|
|
486
|
+
queryFn: (fnParams) => authClient.organization.getInvitation({
|
|
487
|
+
...params,
|
|
488
|
+
...fnParams
|
|
489
|
+
}),
|
|
490
|
+
options
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
472
494
|
// src/hooks/use-layout.ts
|
|
473
|
-
import { createContext as createContext2, useContext as
|
|
495
|
+
import { createContext as createContext2, useContext as useContext11 } from "react";
|
|
474
496
|
var LayoutContext = createContext2(void 0);
|
|
475
497
|
var useLayout = () => {
|
|
476
|
-
const context =
|
|
498
|
+
const context = useContext11(LayoutContext);
|
|
477
499
|
if (!context) {
|
|
478
500
|
throw new Error("useLayout must be used within a LayoutProvider");
|
|
479
501
|
}
|
|
@@ -483,13 +505,12 @@ var useLayout = () => {
|
|
|
483
505
|
// src/hooks/use-onsuccess-transition.ts
|
|
484
506
|
import { useCallback, useEffect, useState, useTransition } from "react";
|
|
485
507
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
486
|
-
import { REDIRECT_QUERY_PARAM } from "@pelatform/utils";
|
|
487
508
|
function useOnSuccessTransition(redirectToProp) {
|
|
488
509
|
const { auth } = useConfig();
|
|
489
510
|
const router = useRouter();
|
|
490
511
|
const searchParams = useSearchParams();
|
|
491
512
|
const { refetch: refetchSession } = useSession();
|
|
492
|
-
const redirectTo = redirectToProp || searchParams?.get(
|
|
513
|
+
const redirectTo = redirectToProp || searchParams?.get("redirectTo") || auth.redirectAfterSignIn;
|
|
493
514
|
const [isPending, startTransition] = useTransition();
|
|
494
515
|
const [success, setSuccess] = useState(false);
|
|
495
516
|
useEffect(() => {
|
|
@@ -507,10 +528,10 @@ function useOnSuccessTransition(redirectToProp) {
|
|
|
507
528
|
}
|
|
508
529
|
|
|
509
530
|
// src/hooks/use-update-user.ts
|
|
510
|
-
import { useContext as
|
|
531
|
+
import { useContext as useContext12 } from "react";
|
|
511
532
|
function useUpdateUser(options) {
|
|
512
533
|
const { authClient } = useConfig();
|
|
513
|
-
const { queryKey } =
|
|
534
|
+
const { queryKey } = useContext12(QueryContext);
|
|
514
535
|
return useAuthMutation({
|
|
515
536
|
queryKey: queryKey.session,
|
|
516
537
|
mutationFn: authClient.updateUser,
|
|
@@ -522,31 +543,27 @@ function useUpdateUser(options) {
|
|
|
522
543
|
});
|
|
523
544
|
}
|
|
524
545
|
|
|
525
|
-
// src/hooks/use-
|
|
526
|
-
import { useContext as
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
...params,
|
|
535
|
-
...fnParams
|
|
536
|
-
}),
|
|
537
|
-
options
|
|
538
|
-
});
|
|
546
|
+
// src/hooks/use-workspace.ts
|
|
547
|
+
import { createContext as createContext3, useContext as useContext13 } from "react";
|
|
548
|
+
var WorkspaceContext = createContext3(void 0);
|
|
549
|
+
function useWorkspace() {
|
|
550
|
+
const context = useContext13(WorkspaceContext);
|
|
551
|
+
if (context === void 0) {
|
|
552
|
+
throw new Error("useWorkspace must be used within a WorkspaceProvider");
|
|
553
|
+
}
|
|
554
|
+
return context;
|
|
539
555
|
}
|
|
540
556
|
|
|
541
557
|
// src/ui/account/dialogs/backup-codes.tsx
|
|
542
558
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
543
559
|
import { useTranslations as useTranslations2 } from "next-intl";
|
|
560
|
+
import { cn as cn2 } from "pelatform-ui";
|
|
544
561
|
import { Button as Button2 } from "pelatform-ui/default";
|
|
545
562
|
import { useCopyToClipboard } from "pelatform-ui/hooks";
|
|
546
|
-
import { cn as cn2 } from "@pelatform/utils";
|
|
547
563
|
|
|
548
564
|
// src/ui/shared/components/dialog.tsx
|
|
549
565
|
import { useTranslations } from "next-intl";
|
|
566
|
+
import { cn } from "pelatform-ui";
|
|
550
567
|
import {
|
|
551
568
|
Button,
|
|
552
569
|
Dialog,
|
|
@@ -556,7 +573,6 @@ import {
|
|
|
556
573
|
DialogHeader,
|
|
557
574
|
DialogTitle
|
|
558
575
|
} from "pelatform-ui/default";
|
|
559
|
-
import { cn } from "@pelatform/utils";
|
|
560
576
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
561
577
|
function DialogComponent({
|
|
562
578
|
children,
|
|
@@ -677,6 +693,9 @@ function BackupCodesDialog({
|
|
|
677
693
|
import { useRouter as useRouter2 } from "next/navigation";
|
|
678
694
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
679
695
|
import { useTranslations as useTranslations5 } from "next-intl";
|
|
696
|
+
import { useForm } from "react-hook-form";
|
|
697
|
+
import { z } from "zod";
|
|
698
|
+
import { cn as cn6 } from "pelatform-ui";
|
|
680
699
|
import { AlertToast } from "pelatform-ui/components";
|
|
681
700
|
import {
|
|
682
701
|
Button as Button4,
|
|
@@ -689,15 +708,12 @@ import {
|
|
|
689
708
|
FormMessage,
|
|
690
709
|
Spinner
|
|
691
710
|
} from "pelatform-ui/default";
|
|
692
|
-
import { useForm } from "react-hook-form";
|
|
693
|
-
import { z } from "zod";
|
|
694
|
-
import { cn as cn6 } from "@pelatform/utils";
|
|
695
711
|
|
|
696
712
|
// src/ui/shared/password-input.tsx
|
|
697
713
|
import { useState as useState2 } from "react";
|
|
698
714
|
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
|
715
|
+
import { cn as cn3 } from "pelatform-ui";
|
|
699
716
|
import { Button as Button3, Input } from "pelatform-ui/default";
|
|
700
|
-
import { cn as cn3 } from "@pelatform/utils";
|
|
701
717
|
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
702
718
|
function PasswordInput({
|
|
703
719
|
className,
|
|
@@ -750,15 +766,15 @@ function PasswordInput({
|
|
|
750
766
|
// src/ui/shared/view.tsx
|
|
751
767
|
import { KeyRoundIcon } from "lucide-react";
|
|
752
768
|
import { useLocale, useTranslations as useTranslations4 } from "next-intl";
|
|
769
|
+
import { cn as cn5 } from "pelatform-ui";
|
|
753
770
|
import { Skeleton as Skeleton2 } from "pelatform-ui/default";
|
|
754
|
-
import { cn as cn5 } from "@pelatform/utils";
|
|
755
771
|
|
|
756
772
|
// src/ui/shared/avatar.tsx
|
|
757
773
|
import { BuildingIcon, UserRoundIcon } from "lucide-react";
|
|
758
774
|
import { useTranslations as useTranslations3 } from "next-intl";
|
|
775
|
+
import { cn as cn4 } from "pelatform-ui";
|
|
759
776
|
import { getInitials } from "pelatform-ui/components";
|
|
760
777
|
import { Avatar, AvatarFallback, AvatarImage, Skeleton } from "pelatform-ui/default";
|
|
761
|
-
import { cn as cn4 } from "@pelatform/utils";
|
|
762
778
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
763
779
|
function getSize(size) {
|
|
764
780
|
return size === "sm" ? "size-6" : size === "lg" ? "size-10" : "size-8";
|
|
@@ -1148,8 +1164,8 @@ function DeleteAccountDialog({
|
|
|
1148
1164
|
// src/ui/account/dialogs/session-freshness.tsx
|
|
1149
1165
|
import { useRouter as useRouter3 } from "next/navigation";
|
|
1150
1166
|
import { useTranslations as useTranslations6 } from "next-intl";
|
|
1167
|
+
import { cn as cn7 } from "pelatform-ui";
|
|
1151
1168
|
import { Button as Button5 } from "pelatform-ui/default";
|
|
1152
|
-
import { cn as cn7 } from "@pelatform/utils";
|
|
1153
1169
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1154
1170
|
function SessionFreshnessDialog({
|
|
1155
1171
|
classNames,
|
|
@@ -1192,6 +1208,9 @@ import { useState as useState3 } from "react";
|
|
|
1192
1208
|
import { useRouter as useRouter4 } from "next/navigation";
|
|
1193
1209
|
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
|
|
1194
1210
|
import { useTranslations as useTranslations7 } from "next-intl";
|
|
1211
|
+
import { useForm as useForm2 } from "react-hook-form";
|
|
1212
|
+
import { z as z2 } from "zod";
|
|
1213
|
+
import { cn as cn8 } from "pelatform-ui";
|
|
1195
1214
|
import { AlertToast as AlertToast2 } from "pelatform-ui/components";
|
|
1196
1215
|
import {
|
|
1197
1216
|
Button as Button6,
|
|
@@ -1203,9 +1222,6 @@ import {
|
|
|
1203
1222
|
FormMessage as FormMessage2,
|
|
1204
1223
|
Spinner as Spinner2
|
|
1205
1224
|
} from "pelatform-ui/default";
|
|
1206
|
-
import { useForm as useForm2 } from "react-hook-form";
|
|
1207
|
-
import { z as z2 } from "zod";
|
|
1208
|
-
import { cn as cn8 } from "@pelatform/utils";
|
|
1209
1225
|
import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1210
1226
|
function TwoFactorPasswordDialog({
|
|
1211
1227
|
classNames,
|
|
@@ -1352,9 +1368,9 @@ import { useState as useState4 } from "react";
|
|
|
1352
1368
|
import { useTranslations as useTranslations8 } from "next-intl";
|
|
1353
1369
|
|
|
1354
1370
|
// src/ui/shared/components/card.tsx
|
|
1355
|
-
import { Button as Button7, Card as Card2, CardContent, CardFooter, Skeleton as Skeleton3, Spinner as Spinner3 } from "pelatform-ui/default";
|
|
1356
1371
|
import { useFormState } from "react-hook-form";
|
|
1357
|
-
import { cn as cn9 } from "
|
|
1372
|
+
import { cn as cn9 } from "pelatform-ui";
|
|
1373
|
+
import { Button as Button7, Card as Card2, CardContent, CardFooter, Skeleton as Skeleton3, Spinner as Spinner3 } from "pelatform-ui/default";
|
|
1358
1374
|
import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1359
1375
|
function CardComponent({
|
|
1360
1376
|
children,
|
|
@@ -1569,6 +1585,7 @@ function DeleteAccountCard({
|
|
|
1569
1585
|
import { useRef, useState as useState5 } from "react";
|
|
1570
1586
|
import { Trash2Icon, UploadCloudIcon } from "lucide-react";
|
|
1571
1587
|
import { useTranslations as useTranslations9 } from "next-intl";
|
|
1588
|
+
import { fileToBase64, resizeAndCropImage } from "pelatform-ui";
|
|
1572
1589
|
import { AlertToast as AlertToast3 } from "pelatform-ui/components";
|
|
1573
1590
|
import {
|
|
1574
1591
|
Button as Button8,
|
|
@@ -1701,6 +1718,9 @@ function FormAvatarCard({
|
|
|
1701
1718
|
import { useState as useState6 } from "react";
|
|
1702
1719
|
import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
|
|
1703
1720
|
import { useTranslations as useTranslations10 } from "next-intl";
|
|
1721
|
+
import { useForm as useForm3 } from "react-hook-form";
|
|
1722
|
+
import { z as z3 } from "zod";
|
|
1723
|
+
import { cn as cn10 } from "pelatform-ui";
|
|
1704
1724
|
import { AlertToast as AlertToast4 } from "pelatform-ui/components";
|
|
1705
1725
|
import {
|
|
1706
1726
|
Form as Form3,
|
|
@@ -1711,9 +1731,6 @@ import {
|
|
|
1711
1731
|
Input as Input2,
|
|
1712
1732
|
Skeleton as Skeleton4
|
|
1713
1733
|
} from "pelatform-ui/default";
|
|
1714
|
-
import { useForm as useForm3 } from "react-hook-form";
|
|
1715
|
-
import { z as z3 } from "zod";
|
|
1716
|
-
import { cn as cn10 } from "@pelatform/utils";
|
|
1717
1734
|
import { Fragment as Fragment7, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1718
1735
|
function FormEmailCard({ className, classNames, ...props }) {
|
|
1719
1736
|
const { authClient, auth } = useConfig();
|
|
@@ -1834,6 +1851,9 @@ function FormEmailCard({ className, classNames, ...props }) {
|
|
|
1834
1851
|
// src/ui/account/partials/form-fields.tsx
|
|
1835
1852
|
import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
|
|
1836
1853
|
import { useTranslations as useTranslations11 } from "next-intl";
|
|
1854
|
+
import { useForm as useForm4 } from "react-hook-form";
|
|
1855
|
+
import { z as z4 } from "zod";
|
|
1856
|
+
import { cn as cn11 } from "pelatform-ui";
|
|
1837
1857
|
import { AlertToast as AlertToast5 } from "pelatform-ui/components";
|
|
1838
1858
|
import {
|
|
1839
1859
|
Checkbox,
|
|
@@ -1847,9 +1867,6 @@ import {
|
|
|
1847
1867
|
Skeleton as Skeleton5,
|
|
1848
1868
|
Textarea
|
|
1849
1869
|
} from "pelatform-ui/default";
|
|
1850
|
-
import { useForm as useForm4 } from "react-hook-form";
|
|
1851
|
-
import { z as z4 } from "zod";
|
|
1852
|
-
import { cn as cn11 } from "@pelatform/utils";
|
|
1853
1870
|
import { Fragment as Fragment8, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1854
1871
|
function FormFieldsCard({
|
|
1855
1872
|
className,
|
|
@@ -2034,6 +2051,9 @@ function FormNameCard({ className, classNames, ...props }) {
|
|
|
2034
2051
|
// src/ui/account/partials/form-password.tsx
|
|
2035
2052
|
import { zodResolver as zodResolver5 } from "@hookform/resolvers/zod";
|
|
2036
2053
|
import { useTranslations as useTranslations13 } from "next-intl";
|
|
2054
|
+
import { useForm as useForm5 } from "react-hook-form";
|
|
2055
|
+
import { z as z5 } from "zod";
|
|
2056
|
+
import { cn as cn13 } from "pelatform-ui";
|
|
2037
2057
|
import { AlertToast as AlertToast6 } from "pelatform-ui/components";
|
|
2038
2058
|
import {
|
|
2039
2059
|
Form as Form5,
|
|
@@ -2043,13 +2063,10 @@ import {
|
|
|
2043
2063
|
FormLabel as FormLabel4,
|
|
2044
2064
|
FormMessage as FormMessage5
|
|
2045
2065
|
} from "pelatform-ui/default";
|
|
2046
|
-
import { useForm as useForm5 } from "react-hook-form";
|
|
2047
|
-
import { z as z5 } from "zod";
|
|
2048
|
-
import { cn as cn13 } from "@pelatform/utils";
|
|
2049
2066
|
|
|
2050
2067
|
// src/ui/shared/components/skeleton.tsx
|
|
2068
|
+
import { cn as cn12 } from "pelatform-ui";
|
|
2051
2069
|
import { Card as Card3, Skeleton as Skeleton6 } from "pelatform-ui/default";
|
|
2052
|
-
import { cn as cn12 } from "@pelatform/utils";
|
|
2053
2070
|
import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2054
2071
|
function SkeletonViewComponent({ classNames }) {
|
|
2055
2072
|
return /* @__PURE__ */ jsxs13(Card3, { className: cn12("flex-row items-center gap-3 px-4 py-3", classNames?.cell), children: [
|
|
@@ -2273,6 +2290,7 @@ import { useState as useState7 } from "react";
|
|
|
2273
2290
|
import { useRouter as useRouter5 } from "next/navigation";
|
|
2274
2291
|
import { EllipsisIcon, LogOutIcon, RepeatIcon, UserX2Icon } from "lucide-react";
|
|
2275
2292
|
import { useTranslations as useTranslations15 } from "next-intl";
|
|
2293
|
+
import { cn as cn14 } from "pelatform-ui";
|
|
2276
2294
|
import { AlertToast as AlertToast7 } from "pelatform-ui/components";
|
|
2277
2295
|
import {
|
|
2278
2296
|
Button as Button9,
|
|
@@ -2283,7 +2301,6 @@ import {
|
|
|
2283
2301
|
DropdownMenuTrigger as DropdownMenuTrigger2,
|
|
2284
2302
|
Spinner as Spinner4
|
|
2285
2303
|
} from "pelatform-ui/default";
|
|
2286
|
-
import { cn as cn14 } from "@pelatform/utils";
|
|
2287
2304
|
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2288
2305
|
function MultiAccountCard({ className, classNames, ...props }) {
|
|
2289
2306
|
const { path } = useConfig();
|
|
@@ -2425,10 +2442,10 @@ function MultiAccountCell({
|
|
|
2425
2442
|
import { useState as useState8 } from "react";
|
|
2426
2443
|
import { FingerprintIcon } from "lucide-react";
|
|
2427
2444
|
import { useTranslations as useTranslations16 } from "next-intl";
|
|
2445
|
+
import { useForm as useForm6 } from "react-hook-form";
|
|
2446
|
+
import { cn as cn15 } from "pelatform-ui";
|
|
2428
2447
|
import { AlertToast as AlertToast8 } from "pelatform-ui/components";
|
|
2429
2448
|
import { Button as Button10, Card as Card5, Form as Form6, Spinner as Spinner5 } from "pelatform-ui/default";
|
|
2430
|
-
import { useForm as useForm6 } from "react-hook-form";
|
|
2431
|
-
import { cn as cn15 } from "@pelatform/utils";
|
|
2432
2449
|
import { Fragment as Fragment10, jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2433
2450
|
function PasskeysCard({ className, classNames, ...props }) {
|
|
2434
2451
|
const { authClient, auth } = useConfig();
|
|
@@ -2439,6 +2456,7 @@ function PasskeysCard({ className, classNames, ...props }) {
|
|
|
2439
2456
|
isPending: passkeysPending,
|
|
2440
2457
|
refetch: refetchPasskeys
|
|
2441
2458
|
} = useListPasskeys();
|
|
2459
|
+
const typedPasskeys = passkeys;
|
|
2442
2460
|
const isPending = sessionPending || passkeysPending;
|
|
2443
2461
|
const isFresh = session ? Date.now() - new Date(session?.createdAt).getTime() < auth.freshAge * 1e3 : false;
|
|
2444
2462
|
const [showFreshnessDialog, setShowFreshnessDialog] = useState8(false);
|
|
@@ -2480,7 +2498,7 @@ function PasskeysCard({ className, classNames, ...props }) {
|
|
|
2480
2498
|
actionLabel: t("systems.ADD_PASSKEY"),
|
|
2481
2499
|
isPending,
|
|
2482
2500
|
...props,
|
|
2483
|
-
children: isPending ? /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: /* @__PURE__ */ jsx20(SkeletonViewComponent, { classNames }) }) :
|
|
2501
|
+
children: isPending ? /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: /* @__PURE__ */ jsx20(SkeletonViewComponent, { classNames }) }) : typedPasskeys && typedPasskeys.length > 0 && /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: typedPasskeys.map((passkey) => /* @__PURE__ */ jsx20(PasskeyCell, { classNames, passkey }, passkey.id)) })
|
|
2484
2502
|
}
|
|
2485
2503
|
) }) })
|
|
2486
2504
|
] });
|
|
@@ -2551,9 +2569,9 @@ function PasskeyCell({
|
|
|
2551
2569
|
// src/ui/account/partials/providers.tsx
|
|
2552
2570
|
import { useState as useState9 } from "react";
|
|
2553
2571
|
import { useTranslations as useTranslations17 } from "next-intl";
|
|
2572
|
+
import { cn as cn16 } from "pelatform-ui";
|
|
2554
2573
|
import { AlertToast as AlertToast9 } from "pelatform-ui/components";
|
|
2555
2574
|
import { Button as Button11, Card as Card6, Skeleton as Skeleton7, Spinner as Spinner6 } from "pelatform-ui/default";
|
|
2556
|
-
import { cn as cn16 } from "@pelatform/utils";
|
|
2557
2575
|
import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2558
2576
|
function ProvidersCard({
|
|
2559
2577
|
className,
|
|
@@ -2682,10 +2700,10 @@ import { useState as useState10 } from "react";
|
|
|
2682
2700
|
import { useRouter as useRouter6 } from "next/navigation";
|
|
2683
2701
|
import { LaptopIcon, SmartphoneIcon } from "lucide-react";
|
|
2684
2702
|
import { useTranslations as useTranslations18 } from "next-intl";
|
|
2703
|
+
import { UAParser } from "ua-parser-js";
|
|
2704
|
+
import { cn as cn17 } from "pelatform-ui";
|
|
2685
2705
|
import { AlertToast as AlertToast10 } from "pelatform-ui/components";
|
|
2686
2706
|
import { Button as Button12, Card as Card7, Spinner as Spinner7 } from "pelatform-ui/default";
|
|
2687
|
-
import { UAParser } from "ua-parser-js";
|
|
2688
|
-
import { cn as cn17 } from "@pelatform/utils";
|
|
2689
2707
|
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2690
2708
|
function SessionsCard({ className, classNames, ...props }) {
|
|
2691
2709
|
const t = useTranslations18();
|
|
@@ -2806,7 +2824,7 @@ function TwoFactorCard({ className, classNames, ...props }) {
|
|
|
2806
2824
|
}
|
|
2807
2825
|
|
|
2808
2826
|
// src/ui/account/security.tsx
|
|
2809
|
-
import { cn as cn18 } from "
|
|
2827
|
+
import { cn as cn18 } from "pelatform-ui";
|
|
2810
2828
|
import { jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2811
2829
|
function SecurityCards({
|
|
2812
2830
|
className,
|
|
@@ -2853,12 +2871,13 @@ function SecurityCards({
|
|
|
2853
2871
|
|
|
2854
2872
|
// src/ui/account/settings.tsx
|
|
2855
2873
|
import { useTranslations as useTranslations21 } from "next-intl";
|
|
2856
|
-
import { cn as cn20 } from "
|
|
2874
|
+
import { cn as cn20 } from "pelatform-ui";
|
|
2857
2875
|
|
|
2858
2876
|
// src/ui/shared/display-id.tsx
|
|
2859
2877
|
import { useRef as useRef2 } from "react";
|
|
2860
2878
|
import { CheckIcon as CheckIcon2, CopyIcon as CopyIcon2 } from "lucide-react";
|
|
2861
2879
|
import { useTranslations as useTranslations20 } from "next-intl";
|
|
2880
|
+
import { cn as cn19 } from "pelatform-ui";
|
|
2862
2881
|
import {
|
|
2863
2882
|
Button as Button13,
|
|
2864
2883
|
Input as Input4,
|
|
@@ -2869,7 +2888,6 @@ import {
|
|
|
2869
2888
|
TooltipTrigger
|
|
2870
2889
|
} from "pelatform-ui/default";
|
|
2871
2890
|
import { useCopyToClipboard as useCopyToClipboard2 } from "pelatform-ui/hooks";
|
|
2872
|
-
import { cn as cn19 } from "@pelatform/utils";
|
|
2873
2891
|
import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2874
2892
|
function DisplayIdCard({
|
|
2875
2893
|
className,
|
|
@@ -2949,12 +2967,15 @@ function SettingsCards({
|
|
|
2949
2967
|
// src/ui/apikeys/apikeys.tsx
|
|
2950
2968
|
import { useMemo as useMemo2, useState as useState13 } from "react";
|
|
2951
2969
|
import { useTranslations as useTranslations25 } from "next-intl";
|
|
2970
|
+
import { cn as cn24 } from "pelatform-ui";
|
|
2952
2971
|
import { Button as Button17, Card as Card9 } from "pelatform-ui/default";
|
|
2953
|
-
import { cn as cn24 } from "@pelatform/utils";
|
|
2954
2972
|
|
|
2955
2973
|
// src/ui/apikeys/create-apikey.tsx
|
|
2956
2974
|
import { zodResolver as zodResolver6 } from "@hookform/resolvers/zod";
|
|
2957
2975
|
import { useLocale as useLocale2, useTranslations as useTranslations22 } from "next-intl";
|
|
2976
|
+
import { useForm as useForm7 } from "react-hook-form";
|
|
2977
|
+
import { z as z6 } from "zod";
|
|
2978
|
+
import { cn as cn21 } from "pelatform-ui";
|
|
2958
2979
|
import { AlertToast as AlertToast11 } from "pelatform-ui/components";
|
|
2959
2980
|
import {
|
|
2960
2981
|
Button as Button14,
|
|
@@ -2972,9 +2993,6 @@ import {
|
|
|
2972
2993
|
SelectValue,
|
|
2973
2994
|
Spinner as Spinner8
|
|
2974
2995
|
} from "pelatform-ui/default";
|
|
2975
|
-
import { useForm as useForm7 } from "react-hook-form";
|
|
2976
|
-
import { z as z6 } from "zod";
|
|
2977
|
-
import { cn as cn21 } from "@pelatform/utils";
|
|
2978
2996
|
import { jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2979
2997
|
function CreateApiKeyDialog({
|
|
2980
2998
|
classNames,
|
|
@@ -3113,9 +3131,9 @@ function CreateApiKeyDialog({
|
|
|
3113
3131
|
// src/ui/apikeys/delete-apikey.tsx
|
|
3114
3132
|
import { useState as useState12 } from "react";
|
|
3115
3133
|
import { useTranslations as useTranslations23 } from "next-intl";
|
|
3134
|
+
import { cn as cn22 } from "pelatform-ui";
|
|
3116
3135
|
import { AlertToast as AlertToast12 } from "pelatform-ui/components";
|
|
3117
3136
|
import { Button as Button15, Card as Card8, Spinner as Spinner9 } from "pelatform-ui/default";
|
|
3118
|
-
import { cn as cn22 } from "@pelatform/utils";
|
|
3119
3137
|
import { jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3120
3138
|
function ApiKeyDeleteDialog({
|
|
3121
3139
|
classNames,
|
|
@@ -3175,9 +3193,9 @@ function ApiKeyDeleteDialog({
|
|
|
3175
3193
|
// src/ui/apikeys/display-apikey.tsx
|
|
3176
3194
|
import { CheckIcon as CheckIcon3, CopyIcon as CopyIcon3 } from "lucide-react";
|
|
3177
3195
|
import { useTranslations as useTranslations24 } from "next-intl";
|
|
3196
|
+
import { cn as cn23 } from "pelatform-ui";
|
|
3178
3197
|
import { Button as Button16 } from "pelatform-ui/default";
|
|
3179
3198
|
import { useCopyToClipboard as useCopyToClipboard3 } from "pelatform-ui/hooks";
|
|
3180
|
-
import { cn as cn23 } from "@pelatform/utils";
|
|
3181
3199
|
import { Fragment as Fragment12, jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3182
3200
|
function ApiKeyDisplayDialog({
|
|
3183
3201
|
classNames,
|
|
@@ -3339,13 +3357,13 @@ function ApiKeyCell({
|
|
|
3339
3357
|
import { useRouter as useRouter7 } from "next/navigation";
|
|
3340
3358
|
import { LockIcon, MailIcon } from "lucide-react";
|
|
3341
3359
|
import { useTranslations as useTranslations27 } from "next-intl";
|
|
3360
|
+
import { cn as cn26 } from "pelatform-ui";
|
|
3342
3361
|
import { Button as Button18 } from "pelatform-ui/default";
|
|
3343
|
-
import { cn as cn26 } from "@pelatform/utils";
|
|
3344
3362
|
|
|
3345
3363
|
// src/ui/auth/partials/last-used-button.tsx
|
|
3346
3364
|
import { useTranslations as useTranslations26 } from "next-intl";
|
|
3365
|
+
import { cn as cn25 } from "pelatform-ui";
|
|
3347
3366
|
import { Badge } from "pelatform-ui/default";
|
|
3348
|
-
import { cn as cn25 } from "@pelatform/utils";
|
|
3349
3367
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3350
3368
|
function LastUsedButton({
|
|
3351
3369
|
className,
|
|
@@ -3406,8 +3424,8 @@ function EmailOTPButton({ className, classNames, isSubmitting, view }) {
|
|
|
3406
3424
|
import { useRouter as useRouter8 } from "next/navigation";
|
|
3407
3425
|
import { LockIcon as LockIcon2, MailIcon as MailIcon2 } from "lucide-react";
|
|
3408
3426
|
import { useTranslations as useTranslations28 } from "next-intl";
|
|
3427
|
+
import { cn as cn27 } from "pelatform-ui";
|
|
3409
3428
|
import { Button as Button19 } from "pelatform-ui/default";
|
|
3410
|
-
import { cn as cn27 } from "@pelatform/utils";
|
|
3411
3429
|
import { jsx as jsx33, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
3412
3430
|
function MagicLinkButton({ className, classNames, isSubmitting, view }) {
|
|
3413
3431
|
const { path } = useConfig();
|
|
@@ -3475,9 +3493,9 @@ function OneTap({ redirectTo }) {
|
|
|
3475
3493
|
// src/ui/auth/partials/passkey-button.tsx
|
|
3476
3494
|
import { FingerprintIcon as FingerprintIcon2 } from "lucide-react";
|
|
3477
3495
|
import { useTranslations as useTranslations30 } from "next-intl";
|
|
3496
|
+
import { cn as cn28 } from "pelatform-ui";
|
|
3478
3497
|
import { AlertToast as AlertToast14 } from "pelatform-ui/components";
|
|
3479
3498
|
import { Button as Button20 } from "pelatform-ui/default";
|
|
3480
|
-
import { cn as cn28 } from "@pelatform/utils";
|
|
3481
3499
|
import { jsx as jsx34, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
3482
3500
|
function PasskeyButton({
|
|
3483
3501
|
className,
|
|
@@ -3541,9 +3559,9 @@ function PasskeyButton({
|
|
|
3541
3559
|
// src/ui/auth/partials/provider-button.tsx
|
|
3542
3560
|
import { useSearchParams as useSearchParams2 } from "next/navigation";
|
|
3543
3561
|
import { useTranslations as useTranslations31 } from "next-intl";
|
|
3562
|
+
import { cn as cn29, REDIRECT_QUERY_PARAM } from "pelatform-ui";
|
|
3544
3563
|
import { AlertToast as AlertToast15 } from "pelatform-ui/components";
|
|
3545
3564
|
import { Button as Button21 } from "pelatform-ui/default";
|
|
3546
|
-
import { cn as cn29, REDIRECT_QUERY_PARAM as REDIRECT_QUERY_PARAM2 } from "@pelatform/utils";
|
|
3547
3565
|
import { jsx as jsx35, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
3548
3566
|
function ProviderButton({
|
|
3549
3567
|
className,
|
|
@@ -3561,7 +3579,7 @@ function ProviderButton({
|
|
|
3561
3579
|
try {
|
|
3562
3580
|
await authClient.signIn.social({
|
|
3563
3581
|
provider: provider.provider,
|
|
3564
|
-
callbackURL: `${app.url}${path.auth.CALLBACK}?redirectTo=${searchParams?.get(
|
|
3582
|
+
callbackURL: `${app.url}${path.auth.CALLBACK}?redirectTo=${searchParams?.get(REDIRECT_QUERY_PARAM)}`,
|
|
3565
3583
|
fetchOptions: { throw: true }
|
|
3566
3584
|
});
|
|
3567
3585
|
} catch (error) {
|
|
@@ -3603,228 +3621,31 @@ function ProviderButton({
|
|
|
3603
3621
|
);
|
|
3604
3622
|
}
|
|
3605
3623
|
|
|
3606
|
-
// src/ui/auth/accept-invitation.tsx
|
|
3607
|
-
import { useEffect as useEffect3, useState as useState14 } from "react";
|
|
3608
|
-
import { useRouter as useRouter9, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
3609
|
-
import { CheckIcon as CheckIcon4, XIcon } from "lucide-react";
|
|
3610
|
-
import { useTranslations as useTranslations32 } from "next-intl";
|
|
3611
|
-
import { AlertToast as AlertToast16 } from "pelatform-ui/components";
|
|
3612
|
-
import { Button as Button22, Card as Card10, CardContent as CardContent2, CardHeader, Skeleton as Skeleton9, Spinner as Spinner10 } from "pelatform-ui/default";
|
|
3613
|
-
import { cn as cn30 } from "@pelatform/utils";
|
|
3614
|
-
import { jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
3615
|
-
function AcceptInvitation({
|
|
3616
|
-
className,
|
|
3617
|
-
classNames,
|
|
3618
|
-
redirectTo: redirectToProp
|
|
3619
|
-
}) {
|
|
3620
|
-
const router = useRouter9();
|
|
3621
|
-
const searchParams = useSearchParams3();
|
|
3622
|
-
const t = useTranslations32();
|
|
3623
|
-
const { data: sessionData } = useSession();
|
|
3624
|
-
const { redirectTo } = useOnSuccessTransition(redirectToProp);
|
|
3625
|
-
const [invitationId, setInvitationId] = useState14(null);
|
|
3626
|
-
useEffect3(() => {
|
|
3627
|
-
const invitationIdParam = searchParams.get("invitationId");
|
|
3628
|
-
if (!invitationIdParam) {
|
|
3629
|
-
AlertToast16({
|
|
3630
|
-
message: t("systems.INVITATION_NOT_FOUND"),
|
|
3631
|
-
icon: "destructive"
|
|
3632
|
-
});
|
|
3633
|
-
router.replace(redirectTo);
|
|
3634
|
-
return;
|
|
3635
|
-
}
|
|
3636
|
-
setInvitationId(invitationIdParam);
|
|
3637
|
-
}, [router, redirectTo, searchParams.get, t]);
|
|
3638
|
-
if (!sessionData || !invitationId) {
|
|
3639
|
-
return /* @__PURE__ */ jsx36(AcceptInvitationSkeleton, { className, classNames });
|
|
3640
|
-
}
|
|
3641
|
-
return /* @__PURE__ */ jsx36(
|
|
3642
|
-
AcceptInvitationContent,
|
|
3643
|
-
{
|
|
3644
|
-
className,
|
|
3645
|
-
classNames,
|
|
3646
|
-
invitationId,
|
|
3647
|
-
redirectTo
|
|
3648
|
-
}
|
|
3649
|
-
);
|
|
3650
|
-
}
|
|
3651
|
-
function AcceptInvitationContent({
|
|
3652
|
-
className,
|
|
3653
|
-
classNames,
|
|
3654
|
-
invitationId,
|
|
3655
|
-
redirectTo
|
|
3656
|
-
}) {
|
|
3657
|
-
const { authClient } = useConfig();
|
|
3658
|
-
const router = useRouter9();
|
|
3659
|
-
const t = useTranslations32();
|
|
3660
|
-
const { data: invitation, isPending } = useInvitation({
|
|
3661
|
-
query: {
|
|
3662
|
-
id: invitationId
|
|
3663
|
-
}
|
|
3664
|
-
});
|
|
3665
|
-
const [isRejecting, setIsRejecting] = useState14(false);
|
|
3666
|
-
const [isAccepting, setIsAccepting] = useState14(false);
|
|
3667
|
-
const isProcessing = isRejecting || isAccepting;
|
|
3668
|
-
useEffect3(() => {
|
|
3669
|
-
if (isPending || !invitationId) return;
|
|
3670
|
-
if (!invitation) {
|
|
3671
|
-
AlertToast16({
|
|
3672
|
-
message: t("systems.INVITATION_NOT_FOUND"),
|
|
3673
|
-
icon: "destructive"
|
|
3674
|
-
});
|
|
3675
|
-
router.replace(redirectTo);
|
|
3676
|
-
return;
|
|
3677
|
-
}
|
|
3678
|
-
if (invitation.status !== "pending" || new Date(invitation.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
3679
|
-
AlertToast16({
|
|
3680
|
-
message: new Date(invitation.expiresAt) < /* @__PURE__ */ new Date() ? t("systems.INVITATION_EXPIRED") : t("systems.INVITATION_NOT_FOUND"),
|
|
3681
|
-
icon: "destructive"
|
|
3682
|
-
});
|
|
3683
|
-
router.replace(redirectTo);
|
|
3684
|
-
}
|
|
3685
|
-
}, [invitation, isPending, invitationId, router, redirectTo, t]);
|
|
3686
|
-
const acceptInvitation = async () => {
|
|
3687
|
-
setIsAccepting(true);
|
|
3688
|
-
try {
|
|
3689
|
-
await authClient.organization.acceptInvitation({
|
|
3690
|
-
invitationId,
|
|
3691
|
-
fetchOptions: { throw: true }
|
|
3692
|
-
});
|
|
3693
|
-
AlertToast16({
|
|
3694
|
-
message: t("systems.INVITATION_ACCEPTED")
|
|
3695
|
-
});
|
|
3696
|
-
router.replace(redirectTo);
|
|
3697
|
-
} catch (error) {
|
|
3698
|
-
AlertToast16({
|
|
3699
|
-
message: getTranslations({ error, t }),
|
|
3700
|
-
icon: "destructive"
|
|
3701
|
-
});
|
|
3702
|
-
setIsAccepting(false);
|
|
3703
|
-
}
|
|
3704
|
-
};
|
|
3705
|
-
const rejectInvitation = async () => {
|
|
3706
|
-
setIsRejecting(true);
|
|
3707
|
-
try {
|
|
3708
|
-
await authClient.organization.rejectInvitation({
|
|
3709
|
-
invitationId,
|
|
3710
|
-
fetchOptions: { throw: true }
|
|
3711
|
-
});
|
|
3712
|
-
AlertToast16({
|
|
3713
|
-
message: t("systems.INVITATION_REJECTED")
|
|
3714
|
-
});
|
|
3715
|
-
router.replace(redirectTo);
|
|
3716
|
-
} catch (error) {
|
|
3717
|
-
AlertToast16({
|
|
3718
|
-
message: getTranslations({ error, t }),
|
|
3719
|
-
icon: "destructive"
|
|
3720
|
-
});
|
|
3721
|
-
setIsRejecting(false);
|
|
3722
|
-
}
|
|
3723
|
-
};
|
|
3724
|
-
if (!invitation) {
|
|
3725
|
-
return /* @__PURE__ */ jsx36(AcceptInvitationSkeleton, { className, classNames });
|
|
3726
|
-
}
|
|
3727
|
-
return /* @__PURE__ */ jsxs31(Card10, { className: cn30("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
|
|
3728
|
-
/* @__PURE__ */ jsx36(CardHeader, { className: "py-4", children: /* @__PURE__ */ jsx36(
|
|
3729
|
-
CardHeaderComponent,
|
|
3730
|
-
{
|
|
3731
|
-
title: t("systems.ACCEPT_INVITATION"),
|
|
3732
|
-
description: t("systems.ACCEPT_INVITATION_DESCRIPTION")
|
|
3733
|
-
}
|
|
3734
|
-
) }),
|
|
3735
|
-
/* @__PURE__ */ jsxs31(CardContent2, { className: cn30("flex flex-col gap-6 truncate", classNames?.content), children: [
|
|
3736
|
-
/* @__PURE__ */ jsxs31(Card10, { className: cn30("flex-row items-center p-4"), children: [
|
|
3737
|
-
/* @__PURE__ */ jsx36(
|
|
3738
|
-
WorkspaceView,
|
|
3739
|
-
{
|
|
3740
|
-
workspace: {
|
|
3741
|
-
id: invitation.organizationId,
|
|
3742
|
-
name: invitation.organizationName,
|
|
3743
|
-
slug: invitation.organizationSlug,
|
|
3744
|
-
// logo: invitation.organizationLogo,
|
|
3745
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
3746
|
-
}
|
|
3747
|
-
}
|
|
3748
|
-
),
|
|
3749
|
-
/* @__PURE__ */ jsx36("p", { className: "ms-auto font-semibold text-muted-foreground text-sm", children: t(`systems.${invitation?.role.toUpperCase()}`) || invitation?.role })
|
|
3750
|
-
] }),
|
|
3751
|
-
/* @__PURE__ */ jsxs31("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
3752
|
-
/* @__PURE__ */ jsxs31(
|
|
3753
|
-
Button22,
|
|
3754
|
-
{
|
|
3755
|
-
variant: "destructive",
|
|
3756
|
-
className: cn30(classNames?.button, classNames?.destructiveButton),
|
|
3757
|
-
onClick: rejectInvitation,
|
|
3758
|
-
disabled: isProcessing,
|
|
3759
|
-
children: [
|
|
3760
|
-
isRejecting ? /* @__PURE__ */ jsx36(Spinner10, {}) : /* @__PURE__ */ jsx36(XIcon, {}),
|
|
3761
|
-
t("systems.REJECT")
|
|
3762
|
-
]
|
|
3763
|
-
}
|
|
3764
|
-
),
|
|
3765
|
-
/* @__PURE__ */ jsxs31(
|
|
3766
|
-
Button22,
|
|
3767
|
-
{
|
|
3768
|
-
className: cn30(classNames?.button, classNames?.primaryButton),
|
|
3769
|
-
onClick: acceptInvitation,
|
|
3770
|
-
disabled: isProcessing,
|
|
3771
|
-
children: [
|
|
3772
|
-
isAccepting ? /* @__PURE__ */ jsx36(Spinner10, {}) : /* @__PURE__ */ jsx36(CheckIcon4, {}),
|
|
3773
|
-
t("systems.ACCEPT")
|
|
3774
|
-
]
|
|
3775
|
-
}
|
|
3776
|
-
)
|
|
3777
|
-
] })
|
|
3778
|
-
] })
|
|
3779
|
-
] });
|
|
3780
|
-
}
|
|
3781
|
-
function AcceptInvitationSkeleton({ className, classNames }) {
|
|
3782
|
-
const t = useTranslations32();
|
|
3783
|
-
return /* @__PURE__ */ jsxs31(Card10, { className: cn30("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
|
|
3784
|
-
/* @__PURE__ */ jsx36(CardHeader, { className: "py-4", children: /* @__PURE__ */ jsx36(
|
|
3785
|
-
CardHeaderComponent,
|
|
3786
|
-
{
|
|
3787
|
-
className: "w-full",
|
|
3788
|
-
title: t("systems.ACCEPT_INVITATION"),
|
|
3789
|
-
description: t("systems.ACCEPT_INVITATION_DESCRIPTION"),
|
|
3790
|
-
isPending: true
|
|
3791
|
-
}
|
|
3792
|
-
) }),
|
|
3793
|
-
/* @__PURE__ */ jsxs31(CardContent2, { className: cn30("flex flex-col gap-6 truncate", classNames?.content), children: [
|
|
3794
|
-
/* @__PURE__ */ jsxs31(Card10, { className: cn30("flex-row items-center p-4"), children: [
|
|
3795
|
-
/* @__PURE__ */ jsx36(WorkspaceView, { isPending: true }),
|
|
3796
|
-
/* @__PURE__ */ jsx36(Skeleton9, { className: "ms-auto mt-0.5 h-4 w-full max-w-14 shrink-2" })
|
|
3797
|
-
] }),
|
|
3798
|
-
/* @__PURE__ */ jsxs31("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
3799
|
-
/* @__PURE__ */ jsx36(Skeleton9, { className: "h-9 w-full" }),
|
|
3800
|
-
/* @__PURE__ */ jsx36(Skeleton9, { className: "h-9 w-full" })
|
|
3801
|
-
] })
|
|
3802
|
-
] })
|
|
3803
|
-
] });
|
|
3804
|
-
}
|
|
3805
|
-
|
|
3806
3624
|
// src/ui/auth/callback.tsx
|
|
3807
|
-
import { useEffect as
|
|
3808
|
-
import { Spinner as
|
|
3809
|
-
import { jsx as
|
|
3625
|
+
import { useEffect as useEffect3, useRef as useRef4 } from "react";
|
|
3626
|
+
import { Spinner as Spinner10 } from "pelatform-ui/default";
|
|
3627
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
3810
3628
|
function AuthCallback({ redirectTo }) {
|
|
3811
3629
|
const { onSuccess } = useOnSuccessTransition(redirectTo);
|
|
3812
3630
|
const isRedirecting = useRef4(false);
|
|
3813
|
-
|
|
3631
|
+
useEffect3(() => {
|
|
3814
3632
|
if (isRedirecting.current) return;
|
|
3815
3633
|
isRedirecting.current = true;
|
|
3816
3634
|
onSuccess();
|
|
3817
3635
|
}, [onSuccess]);
|
|
3818
|
-
return /* @__PURE__ */
|
|
3636
|
+
return /* @__PURE__ */ jsx36("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx36(Spinner10, { className: "size-12" }) });
|
|
3819
3637
|
}
|
|
3820
3638
|
|
|
3821
3639
|
// src/ui/auth/email-otp.tsx
|
|
3822
|
-
import { useEffect as
|
|
3640
|
+
import { useEffect as useEffect4, useState as useState14 } from "react";
|
|
3823
3641
|
import { zodResolver as zodResolver7 } from "@hookform/resolvers/zod";
|
|
3824
|
-
import { useTranslations as
|
|
3825
|
-
import {
|
|
3642
|
+
import { useTranslations as useTranslations32 } from "next-intl";
|
|
3643
|
+
import { useForm as useForm8 } from "react-hook-form";
|
|
3644
|
+
import { z as z7 } from "zod";
|
|
3645
|
+
import { cn as cn30 } from "pelatform-ui";
|
|
3646
|
+
import { AlertToast as AlertToast16 } from "pelatform-ui/components";
|
|
3826
3647
|
import {
|
|
3827
|
-
Button as
|
|
3648
|
+
Button as Button22,
|
|
3828
3649
|
Form as Form8,
|
|
3829
3650
|
FormControl as FormControl7,
|
|
3830
3651
|
FormField as FormField7,
|
|
@@ -3833,67 +3654,64 @@ import {
|
|
|
3833
3654
|
FormMessage as FormMessage7,
|
|
3834
3655
|
Input as Input6,
|
|
3835
3656
|
InputOTP,
|
|
3836
|
-
Spinner as
|
|
3657
|
+
Spinner as Spinner11
|
|
3837
3658
|
} from "pelatform-ui/default";
|
|
3838
|
-
import { useForm as useForm8 } from "react-hook-form";
|
|
3839
|
-
import { z as z7 } from "zod";
|
|
3840
|
-
import { cn as cn31 } from "@pelatform/utils";
|
|
3841
3659
|
|
|
3842
3660
|
// src/ui/shared/otp-input-group.tsx
|
|
3843
3661
|
import { InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "pelatform-ui/default";
|
|
3844
|
-
import { Fragment as Fragment14, jsx as
|
|
3662
|
+
import { Fragment as Fragment14, jsx as jsx37, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
3845
3663
|
function OTPInputGroup({ otpSeparators = 0 }) {
|
|
3846
3664
|
if (otpSeparators === 0) {
|
|
3847
|
-
return /* @__PURE__ */
|
|
3848
|
-
/* @__PURE__ */
|
|
3849
|
-
/* @__PURE__ */
|
|
3850
|
-
/* @__PURE__ */
|
|
3851
|
-
/* @__PURE__ */
|
|
3852
|
-
/* @__PURE__ */
|
|
3853
|
-
/* @__PURE__ */
|
|
3665
|
+
return /* @__PURE__ */ jsxs31(InputOTPGroup, { children: [
|
|
3666
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 0 }),
|
|
3667
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 1 }),
|
|
3668
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 2 }),
|
|
3669
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 3 }),
|
|
3670
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 4 }),
|
|
3671
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 5 })
|
|
3854
3672
|
] });
|
|
3855
3673
|
}
|
|
3856
3674
|
if (otpSeparators === 1) {
|
|
3857
|
-
return /* @__PURE__ */
|
|
3858
|
-
/* @__PURE__ */
|
|
3859
|
-
/* @__PURE__ */
|
|
3860
|
-
/* @__PURE__ */
|
|
3861
|
-
/* @__PURE__ */
|
|
3675
|
+
return /* @__PURE__ */ jsxs31(Fragment14, { children: [
|
|
3676
|
+
/* @__PURE__ */ jsxs31(InputOTPGroup, { children: [
|
|
3677
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 0 }),
|
|
3678
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 1 }),
|
|
3679
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 2 })
|
|
3862
3680
|
] }),
|
|
3863
|
-
/* @__PURE__ */
|
|
3864
|
-
/* @__PURE__ */
|
|
3865
|
-
/* @__PURE__ */
|
|
3866
|
-
/* @__PURE__ */
|
|
3867
|
-
/* @__PURE__ */
|
|
3681
|
+
/* @__PURE__ */ jsx37(InputOTPSeparator, {}),
|
|
3682
|
+
/* @__PURE__ */ jsxs31(InputOTPGroup, { children: [
|
|
3683
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 3 }),
|
|
3684
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 4 }),
|
|
3685
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 5 })
|
|
3868
3686
|
] })
|
|
3869
3687
|
] });
|
|
3870
3688
|
}
|
|
3871
|
-
return /* @__PURE__ */
|
|
3872
|
-
/* @__PURE__ */
|
|
3873
|
-
/* @__PURE__ */
|
|
3874
|
-
/* @__PURE__ */
|
|
3689
|
+
return /* @__PURE__ */ jsxs31(Fragment14, { children: [
|
|
3690
|
+
/* @__PURE__ */ jsxs31(InputOTPGroup, { children: [
|
|
3691
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 0 }),
|
|
3692
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 1 })
|
|
3875
3693
|
] }),
|
|
3876
|
-
/* @__PURE__ */
|
|
3877
|
-
/* @__PURE__ */
|
|
3878
|
-
/* @__PURE__ */
|
|
3879
|
-
/* @__PURE__ */
|
|
3694
|
+
/* @__PURE__ */ jsx37(InputOTPSeparator, {}),
|
|
3695
|
+
/* @__PURE__ */ jsxs31(InputOTPGroup, { children: [
|
|
3696
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 2 }),
|
|
3697
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 3 })
|
|
3880
3698
|
] }),
|
|
3881
|
-
/* @__PURE__ */
|
|
3882
|
-
/* @__PURE__ */
|
|
3883
|
-
/* @__PURE__ */
|
|
3884
|
-
/* @__PURE__ */
|
|
3699
|
+
/* @__PURE__ */ jsx37(InputOTPSeparator, {}),
|
|
3700
|
+
/* @__PURE__ */ jsxs31(InputOTPGroup, { children: [
|
|
3701
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 4 }),
|
|
3702
|
+
/* @__PURE__ */ jsx37(InputOTPSlot, { index: 5 })
|
|
3885
3703
|
] })
|
|
3886
3704
|
] });
|
|
3887
3705
|
}
|
|
3888
3706
|
|
|
3889
3707
|
// src/ui/auth/email-otp.tsx
|
|
3890
|
-
import { jsx as
|
|
3708
|
+
import { jsx as jsx38, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
3891
3709
|
function EmailOTPForm(props) {
|
|
3892
|
-
const [email, setEmail] =
|
|
3710
|
+
const [email, setEmail] = useState14();
|
|
3893
3711
|
if (!email) {
|
|
3894
|
-
return /* @__PURE__ */
|
|
3712
|
+
return /* @__PURE__ */ jsx38(EmailForm, { ...props, setEmail });
|
|
3895
3713
|
}
|
|
3896
|
-
return /* @__PURE__ */
|
|
3714
|
+
return /* @__PURE__ */ jsx38(OTPForm, { ...props, email });
|
|
3897
3715
|
}
|
|
3898
3716
|
function EmailForm({
|
|
3899
3717
|
className,
|
|
@@ -3903,7 +3721,7 @@ function EmailForm({
|
|
|
3903
3721
|
setEmail
|
|
3904
3722
|
}) {
|
|
3905
3723
|
const { authClient } = useConfig();
|
|
3906
|
-
const t =
|
|
3724
|
+
const t = useTranslations32();
|
|
3907
3725
|
const formSchema = z7.object({
|
|
3908
3726
|
email: z7.email({
|
|
3909
3727
|
error: `${t("systems.EMAIL")} ${t("systems.IS_INVALID")}`
|
|
@@ -3916,7 +3734,7 @@ function EmailForm({
|
|
|
3916
3734
|
}
|
|
3917
3735
|
});
|
|
3918
3736
|
const submitting = isSubmitting || form.formState.isSubmitting;
|
|
3919
|
-
|
|
3737
|
+
useEffect4(() => {
|
|
3920
3738
|
setIsSubmitting?.(form.formState.isSubmitting);
|
|
3921
3739
|
}, [form.formState.isSubmitting, setIsSubmitting]);
|
|
3922
3740
|
async function onSubmit({ email }) {
|
|
@@ -3926,29 +3744,29 @@ function EmailForm({
|
|
|
3926
3744
|
type: "sign-in",
|
|
3927
3745
|
fetchOptions: { throw: true }
|
|
3928
3746
|
});
|
|
3929
|
-
|
|
3747
|
+
AlertToast16({ message: t("systems.EMAIL_OTP_VERIFICATION_SENT") });
|
|
3930
3748
|
setEmail(email);
|
|
3931
3749
|
} catch (error) {
|
|
3932
|
-
|
|
3750
|
+
AlertToast16({
|
|
3933
3751
|
message: getTranslations({ error, t }),
|
|
3934
3752
|
icon: "destructive"
|
|
3935
3753
|
});
|
|
3936
3754
|
}
|
|
3937
3755
|
}
|
|
3938
|
-
return /* @__PURE__ */
|
|
3756
|
+
return /* @__PURE__ */ jsx38(Form8, { ...form, children: /* @__PURE__ */ jsxs32(
|
|
3939
3757
|
"form",
|
|
3940
3758
|
{
|
|
3941
3759
|
onSubmit: form.handleSubmit(onSubmit),
|
|
3942
|
-
className:
|
|
3760
|
+
className: cn30("grid w-full gap-6", className, classNames?.base),
|
|
3943
3761
|
children: [
|
|
3944
|
-
/* @__PURE__ */
|
|
3762
|
+
/* @__PURE__ */ jsx38(
|
|
3945
3763
|
FormField7,
|
|
3946
3764
|
{
|
|
3947
3765
|
control: form.control,
|
|
3948
3766
|
name: "email",
|
|
3949
|
-
render: ({ field }) => /* @__PURE__ */
|
|
3950
|
-
/* @__PURE__ */
|
|
3951
|
-
/* @__PURE__ */
|
|
3767
|
+
render: ({ field }) => /* @__PURE__ */ jsxs32(FormItem7, { children: [
|
|
3768
|
+
/* @__PURE__ */ jsx38(FormLabel6, { className: classNames?.label, children: t("systems.EMAIL") }),
|
|
3769
|
+
/* @__PURE__ */ jsx38(FormControl7, { children: /* @__PURE__ */ jsx38(
|
|
3952
3770
|
Input6,
|
|
3953
3771
|
{
|
|
3954
3772
|
type: "email",
|
|
@@ -3959,17 +3777,17 @@ function EmailForm({
|
|
|
3959
3777
|
...field
|
|
3960
3778
|
}
|
|
3961
3779
|
) }),
|
|
3962
|
-
/* @__PURE__ */
|
|
3780
|
+
/* @__PURE__ */ jsx38(FormMessage7, { className: classNames?.error })
|
|
3963
3781
|
] })
|
|
3964
3782
|
}
|
|
3965
3783
|
),
|
|
3966
|
-
/* @__PURE__ */
|
|
3967
|
-
|
|
3784
|
+
/* @__PURE__ */ jsx38(
|
|
3785
|
+
Button22,
|
|
3968
3786
|
{
|
|
3969
3787
|
type: "submit",
|
|
3970
|
-
className:
|
|
3788
|
+
className: cn30("w-full", classNames?.button, classNames?.primaryButton),
|
|
3971
3789
|
disabled: submitting,
|
|
3972
|
-
children: submitting ? /* @__PURE__ */
|
|
3790
|
+
children: submitting ? /* @__PURE__ */ jsx38(Spinner11, {}) : t("systems.EMAIL_OTP_SEND_ACTION")
|
|
3973
3791
|
}
|
|
3974
3792
|
)
|
|
3975
3793
|
]
|
|
@@ -3986,7 +3804,7 @@ function OTPForm({
|
|
|
3986
3804
|
email
|
|
3987
3805
|
}) {
|
|
3988
3806
|
const { authClient } = useConfig();
|
|
3989
|
-
const t =
|
|
3807
|
+
const t = useTranslations32();
|
|
3990
3808
|
const { onSuccess, isPending: transitionPending } = useOnSuccessTransition(redirectTo);
|
|
3991
3809
|
const formSchema = z7.object({
|
|
3992
3810
|
code: z7.string().min(1, {
|
|
@@ -4002,7 +3820,7 @@ function OTPForm({
|
|
|
4002
3820
|
}
|
|
4003
3821
|
});
|
|
4004
3822
|
const submitting = isSubmitting || form.formState.isSubmitting || transitionPending;
|
|
4005
|
-
|
|
3823
|
+
useEffect4(() => {
|
|
4006
3824
|
setIsSubmitting?.(form.formState.isSubmitting || transitionPending);
|
|
4007
3825
|
}, [form.formState.isSubmitting, setIsSubmitting, transitionPending]);
|
|
4008
3826
|
async function onSubmit({ code }) {
|
|
@@ -4014,27 +3832,27 @@ function OTPForm({
|
|
|
4014
3832
|
});
|
|
4015
3833
|
await onSuccess();
|
|
4016
3834
|
} catch (error) {
|
|
4017
|
-
|
|
3835
|
+
AlertToast16({
|
|
4018
3836
|
message: getTranslations({ error, t }),
|
|
4019
3837
|
icon: "destructive"
|
|
4020
3838
|
});
|
|
4021
3839
|
form.reset();
|
|
4022
3840
|
}
|
|
4023
3841
|
}
|
|
4024
|
-
return /* @__PURE__ */
|
|
3842
|
+
return /* @__PURE__ */ jsx38(Form8, { ...form, children: /* @__PURE__ */ jsxs32(
|
|
4025
3843
|
"form",
|
|
4026
3844
|
{
|
|
4027
3845
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4028
|
-
className:
|
|
3846
|
+
className: cn30("grid w-full gap-6", className, classNames?.base),
|
|
4029
3847
|
children: [
|
|
4030
|
-
/* @__PURE__ */
|
|
3848
|
+
/* @__PURE__ */ jsx38(
|
|
4031
3849
|
FormField7,
|
|
4032
3850
|
{
|
|
4033
3851
|
control: form.control,
|
|
4034
3852
|
name: "code",
|
|
4035
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4036
|
-
/* @__PURE__ */
|
|
4037
|
-
/* @__PURE__ */
|
|
3853
|
+
render: ({ field }) => /* @__PURE__ */ jsxs32(FormItem7, { children: [
|
|
3854
|
+
/* @__PURE__ */ jsx38(FormLabel6, { className: classNames?.label, children: t("systems.EMAIL_OTP") }),
|
|
3855
|
+
/* @__PURE__ */ jsx38(FormControl7, { children: /* @__PURE__ */ jsx38(
|
|
4038
3856
|
InputOTP,
|
|
4039
3857
|
{
|
|
4040
3858
|
...field,
|
|
@@ -4048,20 +3866,20 @@ function OTPForm({
|
|
|
4048
3866
|
containerClassName: classNames?.otpInputContainer,
|
|
4049
3867
|
className: classNames?.otpInput,
|
|
4050
3868
|
disabled: submitting,
|
|
4051
|
-
children: /* @__PURE__ */
|
|
3869
|
+
children: /* @__PURE__ */ jsx38(OTPInputGroup, { otpSeparators })
|
|
4052
3870
|
}
|
|
4053
3871
|
) }),
|
|
4054
|
-
/* @__PURE__ */
|
|
3872
|
+
/* @__PURE__ */ jsx38(FormMessage7, { className: classNames?.error })
|
|
4055
3873
|
] })
|
|
4056
3874
|
}
|
|
4057
3875
|
),
|
|
4058
|
-
/* @__PURE__ */
|
|
4059
|
-
|
|
3876
|
+
/* @__PURE__ */ jsx38(
|
|
3877
|
+
Button22,
|
|
4060
3878
|
{
|
|
4061
3879
|
type: "submit",
|
|
4062
|
-
className:
|
|
3880
|
+
className: cn30("w-full", classNames?.button, classNames?.primaryButton),
|
|
4063
3881
|
disabled: submitting,
|
|
4064
|
-
children: submitting ? /* @__PURE__ */
|
|
3882
|
+
children: submitting ? /* @__PURE__ */ jsx38(Spinner11, {}) : t("systems.EMAIL_OTP_VERIFY_ACTION")
|
|
4065
3883
|
}
|
|
4066
3884
|
)
|
|
4067
3885
|
]
|
|
@@ -4070,13 +3888,16 @@ function OTPForm({
|
|
|
4070
3888
|
}
|
|
4071
3889
|
|
|
4072
3890
|
// src/ui/auth/forgot-password.tsx
|
|
4073
|
-
import { useEffect as
|
|
4074
|
-
import { useRouter as
|
|
3891
|
+
import { useEffect as useEffect5 } from "react";
|
|
3892
|
+
import { useRouter as useRouter9 } from "next/navigation";
|
|
4075
3893
|
import { zodResolver as zodResolver8 } from "@hookform/resolvers/zod";
|
|
4076
|
-
import { useTranslations as
|
|
4077
|
-
import {
|
|
3894
|
+
import { useTranslations as useTranslations33 } from "next-intl";
|
|
3895
|
+
import { useForm as useForm9 } from "react-hook-form";
|
|
3896
|
+
import { z as z8 } from "zod";
|
|
3897
|
+
import { cn as cn31 } from "pelatform-ui";
|
|
3898
|
+
import { AlertToast as AlertToast17 } from "pelatform-ui/components";
|
|
4078
3899
|
import {
|
|
4079
|
-
Button as
|
|
3900
|
+
Button as Button23,
|
|
4080
3901
|
Form as Form9,
|
|
4081
3902
|
FormControl as FormControl8,
|
|
4082
3903
|
FormField as FormField8,
|
|
@@ -4084,12 +3905,9 @@ import {
|
|
|
4084
3905
|
FormLabel as FormLabel7,
|
|
4085
3906
|
FormMessage as FormMessage8,
|
|
4086
3907
|
Input as Input7,
|
|
4087
|
-
Spinner as
|
|
3908
|
+
Spinner as Spinner12
|
|
4088
3909
|
} from "pelatform-ui/default";
|
|
4089
|
-
import {
|
|
4090
|
-
import { z as z8 } from "zod";
|
|
4091
|
-
import { cn as cn32 } from "@pelatform/utils";
|
|
4092
|
-
import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3910
|
+
import { jsx as jsx39, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
4093
3911
|
function ForgotPasswordForm({
|
|
4094
3912
|
className,
|
|
4095
3913
|
classNames,
|
|
@@ -4097,8 +3915,8 @@ function ForgotPasswordForm({
|
|
|
4097
3915
|
setIsSubmitting
|
|
4098
3916
|
}) {
|
|
4099
3917
|
const { authClient, app, path } = useConfig();
|
|
4100
|
-
const router =
|
|
4101
|
-
const t =
|
|
3918
|
+
const router = useRouter9();
|
|
3919
|
+
const t = useTranslations33();
|
|
4102
3920
|
const formSchema = z8.object({
|
|
4103
3921
|
email: z8.email({
|
|
4104
3922
|
error: `${t("systems.EMAIL")} ${t("systems.IS_INVALID")}`
|
|
@@ -4111,7 +3929,7 @@ function ForgotPasswordForm({
|
|
|
4111
3929
|
}
|
|
4112
3930
|
});
|
|
4113
3931
|
const submitting = isSubmitting || form.formState.isSubmitting;
|
|
4114
|
-
|
|
3932
|
+
useEffect5(() => {
|
|
4115
3933
|
setIsSubmitting?.(form.formState.isSubmitting);
|
|
4116
3934
|
}, [form.formState.isSubmitting, setIsSubmitting]);
|
|
4117
3935
|
async function onSubmit({ email }) {
|
|
@@ -4121,31 +3939,31 @@ function ForgotPasswordForm({
|
|
|
4121
3939
|
redirectTo: `${app.url}${path.auth.RESET_PASSWORD}`,
|
|
4122
3940
|
fetchOptions: { throw: true }
|
|
4123
3941
|
});
|
|
4124
|
-
|
|
3942
|
+
AlertToast17({
|
|
4125
3943
|
message: t("systems.FORGOT_PASSWORD_EMAIL")
|
|
4126
3944
|
});
|
|
4127
3945
|
router.push(`${path.auth.SIGN_IN}${window.location.search}`);
|
|
4128
3946
|
} catch (error) {
|
|
4129
|
-
|
|
3947
|
+
AlertToast17({
|
|
4130
3948
|
message: getTranslations({ error, t }),
|
|
4131
3949
|
icon: "destructive"
|
|
4132
3950
|
});
|
|
4133
3951
|
}
|
|
4134
3952
|
}
|
|
4135
|
-
return /* @__PURE__ */
|
|
3953
|
+
return /* @__PURE__ */ jsx39(Form9, { ...form, children: /* @__PURE__ */ jsxs33(
|
|
4136
3954
|
"form",
|
|
4137
3955
|
{
|
|
4138
3956
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4139
|
-
className:
|
|
3957
|
+
className: cn31("grid w-full gap-6", className, classNames?.base),
|
|
4140
3958
|
children: [
|
|
4141
|
-
/* @__PURE__ */
|
|
3959
|
+
/* @__PURE__ */ jsx39(
|
|
4142
3960
|
FormField8,
|
|
4143
3961
|
{
|
|
4144
3962
|
control: form.control,
|
|
4145
3963
|
name: "email",
|
|
4146
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4147
|
-
/* @__PURE__ */
|
|
4148
|
-
/* @__PURE__ */
|
|
3964
|
+
render: ({ field }) => /* @__PURE__ */ jsxs33(FormItem8, { children: [
|
|
3965
|
+
/* @__PURE__ */ jsx39(FormLabel7, { className: classNames?.label, children: t("systems.EMAIL") }),
|
|
3966
|
+
/* @__PURE__ */ jsx39(FormControl8, { children: /* @__PURE__ */ jsx39(
|
|
4149
3967
|
Input7,
|
|
4150
3968
|
{
|
|
4151
3969
|
type: "email",
|
|
@@ -4156,17 +3974,17 @@ function ForgotPasswordForm({
|
|
|
4156
3974
|
...field
|
|
4157
3975
|
}
|
|
4158
3976
|
) }),
|
|
4159
|
-
/* @__PURE__ */
|
|
3977
|
+
/* @__PURE__ */ jsx39(FormMessage8, { className: classNames?.error })
|
|
4160
3978
|
] })
|
|
4161
3979
|
}
|
|
4162
3980
|
),
|
|
4163
|
-
/* @__PURE__ */
|
|
4164
|
-
|
|
3981
|
+
/* @__PURE__ */ jsx39(
|
|
3982
|
+
Button23,
|
|
4165
3983
|
{
|
|
4166
3984
|
type: "submit",
|
|
4167
|
-
className:
|
|
3985
|
+
className: cn31("w-full", classNames?.button, classNames?.primaryButton),
|
|
4168
3986
|
disabled: submitting,
|
|
4169
|
-
children: submitting ? /* @__PURE__ */
|
|
3987
|
+
children: submitting ? /* @__PURE__ */ jsx39(Spinner12, {}) : t("systems.FORGOT_PASSWORD_ACTION")
|
|
4170
3988
|
}
|
|
4171
3989
|
)
|
|
4172
3990
|
]
|
|
@@ -4175,13 +3993,16 @@ function ForgotPasswordForm({
|
|
|
4175
3993
|
}
|
|
4176
3994
|
|
|
4177
3995
|
// src/ui/auth/magic-link.tsx
|
|
4178
|
-
import { useEffect as
|
|
4179
|
-
import { useSearchParams as
|
|
3996
|
+
import { useEffect as useEffect6 } from "react";
|
|
3997
|
+
import { useSearchParams as useSearchParams3 } from "next/navigation";
|
|
4180
3998
|
import { zodResolver as zodResolver9 } from "@hookform/resolvers/zod";
|
|
4181
|
-
import { useTranslations as
|
|
4182
|
-
import {
|
|
3999
|
+
import { useTranslations as useTranslations34 } from "next-intl";
|
|
4000
|
+
import { useForm as useForm10 } from "react-hook-form";
|
|
4001
|
+
import { z as z9 } from "zod";
|
|
4002
|
+
import { cn as cn32, REDIRECT_QUERY_PARAM as REDIRECT_QUERY_PARAM2 } from "pelatform-ui";
|
|
4003
|
+
import { AlertToast as AlertToast18 } from "pelatform-ui/components";
|
|
4183
4004
|
import {
|
|
4184
|
-
Button as
|
|
4005
|
+
Button as Button24,
|
|
4185
4006
|
Form as Form10,
|
|
4186
4007
|
FormControl as FormControl9,
|
|
4187
4008
|
FormField as FormField9,
|
|
@@ -4189,12 +4010,9 @@ import {
|
|
|
4189
4010
|
FormLabel as FormLabel8,
|
|
4190
4011
|
FormMessage as FormMessage9,
|
|
4191
4012
|
Input as Input8,
|
|
4192
|
-
Spinner as
|
|
4013
|
+
Spinner as Spinner13
|
|
4193
4014
|
} from "pelatform-ui/default";
|
|
4194
|
-
import {
|
|
4195
|
-
import { z as z9 } from "zod";
|
|
4196
|
-
import { cn as cn33, REDIRECT_QUERY_PARAM as REDIRECT_QUERY_PARAM3 } from "@pelatform/utils";
|
|
4197
|
-
import { jsx as jsx41, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
4015
|
+
import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
4198
4016
|
function MagicLinkForm({
|
|
4199
4017
|
className,
|
|
4200
4018
|
classNames,
|
|
@@ -4202,8 +4020,8 @@ function MagicLinkForm({
|
|
|
4202
4020
|
setIsSubmitting
|
|
4203
4021
|
}) {
|
|
4204
4022
|
const { authClient, app, path } = useConfig();
|
|
4205
|
-
const searchParams =
|
|
4206
|
-
const t =
|
|
4023
|
+
const searchParams = useSearchParams3();
|
|
4024
|
+
const t = useTranslations34();
|
|
4207
4025
|
const formSchema = z9.object({
|
|
4208
4026
|
email: z9.email({
|
|
4209
4027
|
error: `${t("systems.EMAIL")} ${t("systems.IS_INVALID")}`
|
|
@@ -4216,41 +4034,41 @@ function MagicLinkForm({
|
|
|
4216
4034
|
}
|
|
4217
4035
|
});
|
|
4218
4036
|
const submitting = isSubmitting || form.formState.isSubmitting;
|
|
4219
|
-
|
|
4037
|
+
useEffect6(() => {
|
|
4220
4038
|
setIsSubmitting?.(form.formState.isSubmitting);
|
|
4221
4039
|
}, [form.formState.isSubmitting, setIsSubmitting]);
|
|
4222
4040
|
async function onSubmit({ email }) {
|
|
4223
4041
|
try {
|
|
4224
4042
|
await authClient.signIn.magicLink({
|
|
4225
4043
|
email,
|
|
4226
|
-
callbackURL: `${app.url}${path.auth.CALLBACK}?redirectTo=${searchParams?.get(
|
|
4044
|
+
callbackURL: `${app.url}${path.auth.CALLBACK}?redirectTo=${searchParams?.get(REDIRECT_QUERY_PARAM2)}`,
|
|
4227
4045
|
fetchOptions: { throw: true }
|
|
4228
4046
|
});
|
|
4229
|
-
|
|
4047
|
+
AlertToast18({
|
|
4230
4048
|
message: t("systems.MAGIC_LINK_EMAIL")
|
|
4231
4049
|
});
|
|
4232
4050
|
form.reset();
|
|
4233
4051
|
} catch (error) {
|
|
4234
|
-
|
|
4052
|
+
AlertToast18({
|
|
4235
4053
|
message: getTranslations({ error, t }),
|
|
4236
4054
|
icon: "destructive"
|
|
4237
4055
|
});
|
|
4238
4056
|
}
|
|
4239
4057
|
}
|
|
4240
|
-
return /* @__PURE__ */
|
|
4058
|
+
return /* @__PURE__ */ jsx40(Form10, { ...form, children: /* @__PURE__ */ jsxs34(
|
|
4241
4059
|
"form",
|
|
4242
4060
|
{
|
|
4243
4061
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4244
|
-
className:
|
|
4062
|
+
className: cn32("grid w-full gap-6", className, classNames?.base),
|
|
4245
4063
|
children: [
|
|
4246
|
-
/* @__PURE__ */
|
|
4064
|
+
/* @__PURE__ */ jsx40(
|
|
4247
4065
|
FormField9,
|
|
4248
4066
|
{
|
|
4249
4067
|
control: form.control,
|
|
4250
4068
|
name: "email",
|
|
4251
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4252
|
-
/* @__PURE__ */
|
|
4253
|
-
/* @__PURE__ */
|
|
4069
|
+
render: ({ field }) => /* @__PURE__ */ jsxs34(FormItem9, { children: [
|
|
4070
|
+
/* @__PURE__ */ jsx40(FormLabel8, { className: classNames?.label, children: t("systems.EMAIL") }),
|
|
4071
|
+
/* @__PURE__ */ jsx40(FormControl9, { children: /* @__PURE__ */ jsx40(
|
|
4254
4072
|
Input8,
|
|
4255
4073
|
{
|
|
4256
4074
|
type: "email",
|
|
@@ -4261,17 +4079,17 @@ function MagicLinkForm({
|
|
|
4261
4079
|
...field
|
|
4262
4080
|
}
|
|
4263
4081
|
) }),
|
|
4264
|
-
/* @__PURE__ */
|
|
4082
|
+
/* @__PURE__ */ jsx40(FormMessage9, { className: classNames?.error })
|
|
4265
4083
|
] })
|
|
4266
4084
|
}
|
|
4267
4085
|
),
|
|
4268
|
-
/* @__PURE__ */
|
|
4269
|
-
|
|
4086
|
+
/* @__PURE__ */ jsx40(
|
|
4087
|
+
Button24,
|
|
4270
4088
|
{
|
|
4271
4089
|
type: "submit",
|
|
4272
|
-
className:
|
|
4090
|
+
className: cn32("w-full", classNames?.button, classNames?.primaryButton),
|
|
4273
4091
|
disabled: submitting,
|
|
4274
|
-
children: submitting ? /* @__PURE__ */
|
|
4092
|
+
children: submitting ? /* @__PURE__ */ jsx40(Spinner13, {}) : t("systems.MAGIC_LINK_ACTION")
|
|
4275
4093
|
}
|
|
4276
4094
|
)
|
|
4277
4095
|
]
|
|
@@ -4280,12 +4098,15 @@ function MagicLinkForm({
|
|
|
4280
4098
|
}
|
|
4281
4099
|
|
|
4282
4100
|
// src/ui/auth/recover-account.tsx
|
|
4283
|
-
import { useEffect as
|
|
4101
|
+
import { useEffect as useEffect7 } from "react";
|
|
4284
4102
|
import { zodResolver as zodResolver10 } from "@hookform/resolvers/zod";
|
|
4285
|
-
import { useTranslations as
|
|
4286
|
-
import {
|
|
4103
|
+
import { useTranslations as useTranslations35 } from "next-intl";
|
|
4104
|
+
import { useForm as useForm11 } from "react-hook-form";
|
|
4105
|
+
import { z as z10 } from "zod";
|
|
4106
|
+
import { cn as cn33 } from "pelatform-ui";
|
|
4107
|
+
import { AlertToast as AlertToast19 } from "pelatform-ui/components";
|
|
4287
4108
|
import {
|
|
4288
|
-
Button as
|
|
4109
|
+
Button as Button25,
|
|
4289
4110
|
Form as Form11,
|
|
4290
4111
|
FormControl as FormControl10,
|
|
4291
4112
|
FormField as FormField10,
|
|
@@ -4293,12 +4114,9 @@ import {
|
|
|
4293
4114
|
FormLabel as FormLabel9,
|
|
4294
4115
|
FormMessage as FormMessage10,
|
|
4295
4116
|
Input as Input9,
|
|
4296
|
-
Spinner as
|
|
4117
|
+
Spinner as Spinner14
|
|
4297
4118
|
} from "pelatform-ui/default";
|
|
4298
|
-
import {
|
|
4299
|
-
import { z as z10 } from "zod";
|
|
4300
|
-
import { cn as cn34 } from "@pelatform/utils";
|
|
4301
|
-
import { jsx as jsx42, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
4119
|
+
import { jsx as jsx41, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
4302
4120
|
function RecoverAccountForm({
|
|
4303
4121
|
className,
|
|
4304
4122
|
classNames,
|
|
@@ -4307,7 +4125,7 @@ function RecoverAccountForm({
|
|
|
4307
4125
|
setIsSubmitting
|
|
4308
4126
|
}) {
|
|
4309
4127
|
const { authClient } = useConfig();
|
|
4310
|
-
const t =
|
|
4128
|
+
const t = useTranslations35();
|
|
4311
4129
|
const { onSuccess, isPending: transitionPending } = useOnSuccessTransition(redirectTo);
|
|
4312
4130
|
const formSchema = z10.object({
|
|
4313
4131
|
code: z10.string().min(1, { error: t("systems.BACKUP_CODE_REQUIRED") })
|
|
@@ -4319,7 +4137,7 @@ function RecoverAccountForm({
|
|
|
4319
4137
|
}
|
|
4320
4138
|
});
|
|
4321
4139
|
const submitting = isSubmitting || form.formState.isSubmitting || transitionPending;
|
|
4322
|
-
|
|
4140
|
+
useEffect7(() => {
|
|
4323
4141
|
setIsSubmitting?.(form.formState.isSubmitting || transitionPending);
|
|
4324
4142
|
}, [setIsSubmitting, form.formState.isSubmitting, transitionPending]);
|
|
4325
4143
|
async function onSubmit({ code }) {
|
|
@@ -4330,27 +4148,27 @@ function RecoverAccountForm({
|
|
|
4330
4148
|
});
|
|
4331
4149
|
await onSuccess();
|
|
4332
4150
|
} catch (error) {
|
|
4333
|
-
|
|
4151
|
+
AlertToast19({
|
|
4334
4152
|
message: getTranslations({ error, t }),
|
|
4335
4153
|
icon: "destructive"
|
|
4336
4154
|
});
|
|
4337
4155
|
form.reset();
|
|
4338
4156
|
}
|
|
4339
4157
|
}
|
|
4340
|
-
return /* @__PURE__ */
|
|
4158
|
+
return /* @__PURE__ */ jsx41(Form11, { ...form, children: /* @__PURE__ */ jsxs35(
|
|
4341
4159
|
"form",
|
|
4342
4160
|
{
|
|
4343
4161
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4344
|
-
className:
|
|
4162
|
+
className: cn33("grid w-full gap-6", className, classNames?.base),
|
|
4345
4163
|
children: [
|
|
4346
|
-
/* @__PURE__ */
|
|
4164
|
+
/* @__PURE__ */ jsx41(
|
|
4347
4165
|
FormField10,
|
|
4348
4166
|
{
|
|
4349
4167
|
control: form.control,
|
|
4350
4168
|
name: "code",
|
|
4351
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4352
|
-
/* @__PURE__ */
|
|
4353
|
-
/* @__PURE__ */
|
|
4169
|
+
render: ({ field }) => /* @__PURE__ */ jsxs35(FormItem10, { children: [
|
|
4170
|
+
/* @__PURE__ */ jsx41(FormLabel9, { className: classNames?.label, children: t("systems.BACKUP_CODE") }),
|
|
4171
|
+
/* @__PURE__ */ jsx41(FormControl10, { children: /* @__PURE__ */ jsx41(
|
|
4354
4172
|
Input9,
|
|
4355
4173
|
{
|
|
4356
4174
|
autoComplete: "off",
|
|
@@ -4360,17 +4178,17 @@ function RecoverAccountForm({
|
|
|
4360
4178
|
...field
|
|
4361
4179
|
}
|
|
4362
4180
|
) }),
|
|
4363
|
-
/* @__PURE__ */
|
|
4181
|
+
/* @__PURE__ */ jsx41(FormMessage10, { className: classNames?.error })
|
|
4364
4182
|
] })
|
|
4365
4183
|
}
|
|
4366
4184
|
),
|
|
4367
|
-
/* @__PURE__ */
|
|
4368
|
-
|
|
4185
|
+
/* @__PURE__ */ jsx41(
|
|
4186
|
+
Button25,
|
|
4369
4187
|
{
|
|
4370
4188
|
type: "submit",
|
|
4371
|
-
className:
|
|
4189
|
+
className: cn33("w-full", classNames?.button, classNames?.primaryButton),
|
|
4372
4190
|
disabled: submitting,
|
|
4373
|
-
children: submitting ? /* @__PURE__ */
|
|
4191
|
+
children: submitting ? /* @__PURE__ */ jsx41(Spinner14, {}) : t("systems.RECOVER_ACCOUNT_ACTION")
|
|
4374
4192
|
}
|
|
4375
4193
|
)
|
|
4376
4194
|
]
|
|
@@ -4379,25 +4197,25 @@ function RecoverAccountForm({
|
|
|
4379
4197
|
}
|
|
4380
4198
|
|
|
4381
4199
|
// src/ui/auth/reset-password.tsx
|
|
4382
|
-
import { useEffect as
|
|
4383
|
-
import { useRouter as
|
|
4200
|
+
import { useEffect as useEffect8, useMemo as useMemo3, useRef as useRef5 } from "react";
|
|
4201
|
+
import { useRouter as useRouter10, useSearchParams as useSearchParams4 } from "next/navigation";
|
|
4384
4202
|
import { zodResolver as zodResolver11 } from "@hookform/resolvers/zod";
|
|
4385
|
-
import { useTranslations as
|
|
4386
|
-
import {
|
|
4203
|
+
import { useTranslations as useTranslations36 } from "next-intl";
|
|
4204
|
+
import { useForm as useForm12 } from "react-hook-form";
|
|
4205
|
+
import { z as z11 } from "zod";
|
|
4206
|
+
import { cn as cn34 } from "pelatform-ui";
|
|
4207
|
+
import { AlertToast as AlertToast20 } from "pelatform-ui/components";
|
|
4387
4208
|
import {
|
|
4388
|
-
Button as
|
|
4209
|
+
Button as Button26,
|
|
4389
4210
|
Form as Form12,
|
|
4390
4211
|
FormControl as FormControl11,
|
|
4391
4212
|
FormField as FormField11,
|
|
4392
4213
|
FormItem as FormItem11,
|
|
4393
4214
|
FormLabel as FormLabel10,
|
|
4394
4215
|
FormMessage as FormMessage11,
|
|
4395
|
-
Spinner as
|
|
4216
|
+
Spinner as Spinner15
|
|
4396
4217
|
} from "pelatform-ui/default";
|
|
4397
|
-
import {
|
|
4398
|
-
import { z as z11 } from "zod";
|
|
4399
|
-
import { cn as cn35 } from "@pelatform/utils";
|
|
4400
|
-
import { jsx as jsx43, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
4218
|
+
import { jsx as jsx42, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
4401
4219
|
function ResetPasswordForm({
|
|
4402
4220
|
className,
|
|
4403
4221
|
classNames,
|
|
@@ -4405,9 +4223,9 @@ function ResetPasswordForm({
|
|
|
4405
4223
|
setIsSubmitting
|
|
4406
4224
|
}) {
|
|
4407
4225
|
const { authClient, path } = useConfig();
|
|
4408
|
-
const router =
|
|
4409
|
-
const searchParams =
|
|
4410
|
-
const t =
|
|
4226
|
+
const router = useRouter10();
|
|
4227
|
+
const searchParams = useSearchParams4();
|
|
4228
|
+
const t = useTranslations36();
|
|
4411
4229
|
const token = searchParams?.get("token");
|
|
4412
4230
|
const tokenChecked = useRef5(false);
|
|
4413
4231
|
const formSchema = useMemo3(
|
|
@@ -4428,14 +4246,14 @@ function ResetPasswordForm({
|
|
|
4428
4246
|
}
|
|
4429
4247
|
});
|
|
4430
4248
|
const submitting = isSubmitting || form.formState.isSubmitting;
|
|
4431
|
-
|
|
4249
|
+
useEffect8(() => {
|
|
4432
4250
|
setIsSubmitting?.(form.formState.isSubmitting);
|
|
4433
4251
|
}, [form.formState.isSubmitting, setIsSubmitting]);
|
|
4434
|
-
|
|
4252
|
+
useEffect8(() => {
|
|
4435
4253
|
if (tokenChecked.current) return;
|
|
4436
4254
|
tokenChecked.current = true;
|
|
4437
4255
|
if (!token || token === "INVALID_TOKEN") {
|
|
4438
|
-
|
|
4256
|
+
AlertToast20({
|
|
4439
4257
|
message: t("systems.INVALID_TOKEN"),
|
|
4440
4258
|
icon: "destructive"
|
|
4441
4259
|
});
|
|
@@ -4444,7 +4262,7 @@ function ResetPasswordForm({
|
|
|
4444
4262
|
}, [path.auth.SIGN_IN, router, t, token]);
|
|
4445
4263
|
async function onSubmit({ newPassword }) {
|
|
4446
4264
|
if (!token) {
|
|
4447
|
-
|
|
4265
|
+
AlertToast20({
|
|
4448
4266
|
message: t("systems.INVALID_TOKEN"),
|
|
4449
4267
|
icon: "destructive"
|
|
4450
4268
|
});
|
|
@@ -4456,32 +4274,32 @@ function ResetPasswordForm({
|
|
|
4456
4274
|
token,
|
|
4457
4275
|
fetchOptions: { throw: true }
|
|
4458
4276
|
});
|
|
4459
|
-
|
|
4277
|
+
AlertToast20({
|
|
4460
4278
|
message: t("systems.RESET_PASSWORD_SUCCESS")
|
|
4461
4279
|
});
|
|
4462
4280
|
router.push(`${path.auth.SIGN_IN}${window.location.search}`);
|
|
4463
4281
|
} catch (error) {
|
|
4464
|
-
|
|
4282
|
+
AlertToast20({
|
|
4465
4283
|
message: getTranslations({ error, t }),
|
|
4466
4284
|
icon: "destructive"
|
|
4467
4285
|
});
|
|
4468
4286
|
form.reset();
|
|
4469
4287
|
}
|
|
4470
4288
|
}
|
|
4471
|
-
return /* @__PURE__ */
|
|
4289
|
+
return /* @__PURE__ */ jsx42(Form12, { ...form, children: /* @__PURE__ */ jsxs36(
|
|
4472
4290
|
"form",
|
|
4473
4291
|
{
|
|
4474
4292
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4475
|
-
className:
|
|
4293
|
+
className: cn34("grid w-full gap-6", className, classNames?.base),
|
|
4476
4294
|
children: [
|
|
4477
|
-
/* @__PURE__ */
|
|
4295
|
+
/* @__PURE__ */ jsx42(
|
|
4478
4296
|
FormField11,
|
|
4479
4297
|
{
|
|
4480
4298
|
control: form.control,
|
|
4481
4299
|
name: "newPassword",
|
|
4482
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4483
|
-
/* @__PURE__ */
|
|
4484
|
-
/* @__PURE__ */
|
|
4300
|
+
render: ({ field }) => /* @__PURE__ */ jsxs36(FormItem11, { children: [
|
|
4301
|
+
/* @__PURE__ */ jsx42(FormLabel10, { className: classNames?.label, children: t("systems.NEW_PASSWORD") }),
|
|
4302
|
+
/* @__PURE__ */ jsx42(FormControl11, { children: /* @__PURE__ */ jsx42(
|
|
4485
4303
|
PasswordInput,
|
|
4486
4304
|
{
|
|
4487
4305
|
autoComplete: "new-password",
|
|
@@ -4492,18 +4310,18 @@ function ResetPasswordForm({
|
|
|
4492
4310
|
...field
|
|
4493
4311
|
}
|
|
4494
4312
|
) }),
|
|
4495
|
-
/* @__PURE__ */
|
|
4313
|
+
/* @__PURE__ */ jsx42(FormMessage11, { className: classNames?.error })
|
|
4496
4314
|
] })
|
|
4497
4315
|
}
|
|
4498
4316
|
),
|
|
4499
|
-
/* @__PURE__ */
|
|
4317
|
+
/* @__PURE__ */ jsx42(
|
|
4500
4318
|
FormField11,
|
|
4501
4319
|
{
|
|
4502
4320
|
control: form.control,
|
|
4503
4321
|
name: "confirmPassword",
|
|
4504
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4505
|
-
/* @__PURE__ */
|
|
4506
|
-
/* @__PURE__ */
|
|
4322
|
+
render: ({ field }) => /* @__PURE__ */ jsxs36(FormItem11, { children: [
|
|
4323
|
+
/* @__PURE__ */ jsx42(FormLabel10, { className: classNames?.label, children: t("systems.CONFIRM_PASSWORD") }),
|
|
4324
|
+
/* @__PURE__ */ jsx42(FormControl11, { children: /* @__PURE__ */ jsx42(
|
|
4507
4325
|
PasswordInput,
|
|
4508
4326
|
{
|
|
4509
4327
|
autoComplete: "new-password",
|
|
@@ -4514,17 +4332,17 @@ function ResetPasswordForm({
|
|
|
4514
4332
|
...field
|
|
4515
4333
|
}
|
|
4516
4334
|
) }),
|
|
4517
|
-
/* @__PURE__ */
|
|
4335
|
+
/* @__PURE__ */ jsx42(FormMessage11, { className: classNames?.error })
|
|
4518
4336
|
] })
|
|
4519
4337
|
}
|
|
4520
4338
|
),
|
|
4521
|
-
/* @__PURE__ */
|
|
4522
|
-
|
|
4339
|
+
/* @__PURE__ */ jsx42(
|
|
4340
|
+
Button26,
|
|
4523
4341
|
{
|
|
4524
4342
|
type: "submit",
|
|
4525
|
-
className:
|
|
4343
|
+
className: cn34("w-full", classNames?.button, classNames?.primaryButton),
|
|
4526
4344
|
disabled: submitting || !token,
|
|
4527
|
-
children: submitting ? /* @__PURE__ */
|
|
4345
|
+
children: submitting ? /* @__PURE__ */ jsx42(Spinner15, {}) : t("systems.RESET_PASSWORD_ACTION")
|
|
4528
4346
|
}
|
|
4529
4347
|
)
|
|
4530
4348
|
]
|
|
@@ -4533,14 +4351,17 @@ function ResetPasswordForm({
|
|
|
4533
4351
|
}
|
|
4534
4352
|
|
|
4535
4353
|
// src/ui/auth/sign-in.tsx
|
|
4536
|
-
import { useEffect as
|
|
4354
|
+
import { useEffect as useEffect9 } from "react";
|
|
4537
4355
|
import Link from "next/link";
|
|
4538
|
-
import { useRouter as
|
|
4356
|
+
import { useRouter as useRouter11 } from "next/navigation";
|
|
4539
4357
|
import { zodResolver as zodResolver12 } from "@hookform/resolvers/zod";
|
|
4540
|
-
import { useTranslations as
|
|
4541
|
-
import {
|
|
4358
|
+
import { useTranslations as useTranslations37 } from "next-intl";
|
|
4359
|
+
import { useForm as useForm13 } from "react-hook-form";
|
|
4360
|
+
import { z as z12 } from "zod";
|
|
4361
|
+
import { cn as cn35, validateEmail } from "pelatform-ui";
|
|
4362
|
+
import { AlertToast as AlertToast21 } from "pelatform-ui/components";
|
|
4542
4363
|
import {
|
|
4543
|
-
Button as
|
|
4364
|
+
Button as Button27,
|
|
4544
4365
|
Checkbox as Checkbox2,
|
|
4545
4366
|
Form as Form13,
|
|
4546
4367
|
FormControl as FormControl12,
|
|
@@ -4549,12 +4370,9 @@ import {
|
|
|
4549
4370
|
FormLabel as FormLabel11,
|
|
4550
4371
|
FormMessage as FormMessage12,
|
|
4551
4372
|
Input as Input10,
|
|
4552
|
-
Spinner as
|
|
4373
|
+
Spinner as Spinner16
|
|
4553
4374
|
} from "pelatform-ui/default";
|
|
4554
|
-
import {
|
|
4555
|
-
import { z as z12 } from "zod";
|
|
4556
|
-
import { cn as cn36, validateEmail } from "@pelatform/utils";
|
|
4557
|
-
import { jsx as jsx44, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
4375
|
+
import { jsx as jsx43, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
4558
4376
|
function SignInForm({
|
|
4559
4377
|
className,
|
|
4560
4378
|
classNames,
|
|
@@ -4563,8 +4381,8 @@ function SignInForm({
|
|
|
4563
4381
|
setIsSubmitting
|
|
4564
4382
|
}) {
|
|
4565
4383
|
const { authClient, auth, path } = useConfig();
|
|
4566
|
-
const t =
|
|
4567
|
-
const router =
|
|
4384
|
+
const t = useTranslations37();
|
|
4385
|
+
const router = useRouter11();
|
|
4568
4386
|
const { onSuccess, isPending: transitionPending } = useOnSuccessTransition(redirectToProp);
|
|
4569
4387
|
const usernameEnabled = auth.authentication.username;
|
|
4570
4388
|
const formSchema = z12.object({
|
|
@@ -4585,7 +4403,7 @@ function SignInForm({
|
|
|
4585
4403
|
}
|
|
4586
4404
|
});
|
|
4587
4405
|
const submitting = isSubmitting || form.formState.isSubmitting || transitionPending;
|
|
4588
|
-
|
|
4406
|
+
useEffect9(() => {
|
|
4589
4407
|
setIsSubmitting?.(form.formState.isSubmitting || transitionPending);
|
|
4590
4408
|
}, [form.formState.isSubmitting, setIsSubmitting, transitionPending]);
|
|
4591
4409
|
async function onSubmit({ email, password, rememberMe }) {
|
|
@@ -4613,27 +4431,27 @@ function SignInForm({
|
|
|
4613
4431
|
await onSuccess();
|
|
4614
4432
|
}
|
|
4615
4433
|
} catch (error) {
|
|
4616
|
-
|
|
4434
|
+
AlertToast21({
|
|
4617
4435
|
message: getTranslations({ error, t }),
|
|
4618
4436
|
icon: "destructive"
|
|
4619
4437
|
});
|
|
4620
4438
|
form.resetField("password");
|
|
4621
4439
|
}
|
|
4622
4440
|
}
|
|
4623
|
-
return /* @__PURE__ */
|
|
4441
|
+
return /* @__PURE__ */ jsx43(Form13, { ...form, children: /* @__PURE__ */ jsxs37(
|
|
4624
4442
|
"form",
|
|
4625
4443
|
{
|
|
4626
4444
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4627
|
-
className:
|
|
4445
|
+
className: cn35("grid w-full gap-6", className, classNames?.base),
|
|
4628
4446
|
children: [
|
|
4629
|
-
/* @__PURE__ */
|
|
4447
|
+
/* @__PURE__ */ jsx43(
|
|
4630
4448
|
FormField12,
|
|
4631
4449
|
{
|
|
4632
4450
|
control: form.control,
|
|
4633
4451
|
name: "email",
|
|
4634
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4635
|
-
/* @__PURE__ */
|
|
4636
|
-
/* @__PURE__ */
|
|
4452
|
+
render: ({ field }) => /* @__PURE__ */ jsxs37(FormItem12, { children: [
|
|
4453
|
+
/* @__PURE__ */ jsx43(FormLabel11, { className: classNames?.label, children: usernameEnabled ? t("systems.USERNAME") : t("systems.EMAIL") }),
|
|
4454
|
+
/* @__PURE__ */ jsx43(FormControl12, { children: /* @__PURE__ */ jsx43(
|
|
4637
4455
|
Input10,
|
|
4638
4456
|
{
|
|
4639
4457
|
type: usernameEnabled ? "text" : "email",
|
|
@@ -4644,30 +4462,30 @@ function SignInForm({
|
|
|
4644
4462
|
...field
|
|
4645
4463
|
}
|
|
4646
4464
|
) }),
|
|
4647
|
-
/* @__PURE__ */
|
|
4465
|
+
/* @__PURE__ */ jsx43(FormMessage12, { className: classNames?.error })
|
|
4648
4466
|
] })
|
|
4649
4467
|
}
|
|
4650
4468
|
),
|
|
4651
|
-
/* @__PURE__ */
|
|
4469
|
+
/* @__PURE__ */ jsx43(
|
|
4652
4470
|
FormField12,
|
|
4653
4471
|
{
|
|
4654
4472
|
control: form.control,
|
|
4655
4473
|
name: "password",
|
|
4656
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4657
|
-
/* @__PURE__ */
|
|
4658
|
-
/* @__PURE__ */
|
|
4659
|
-
/* @__PURE__ */
|
|
4660
|
-
|
|
4474
|
+
render: ({ field }) => /* @__PURE__ */ jsxs37(FormItem12, { children: [
|
|
4475
|
+
/* @__PURE__ */ jsxs37("div", { className: "flex items-center justify-between", children: [
|
|
4476
|
+
/* @__PURE__ */ jsx43(FormLabel11, { className: classNames?.label, children: t("systems.PASSWORD") }),
|
|
4477
|
+
/* @__PURE__ */ jsx43(Link, { href: `${path.auth.FORGOT_PASSWORD}${window.location.search}`, children: /* @__PURE__ */ jsx43(
|
|
4478
|
+
Button27,
|
|
4661
4479
|
{
|
|
4662
4480
|
mode: "link",
|
|
4663
4481
|
underline: "dashed",
|
|
4664
4482
|
size: "sm",
|
|
4665
|
-
className:
|
|
4483
|
+
className: cn35("px-0 text-foreground text-sm", classNames?.forgotPasswordLink),
|
|
4666
4484
|
children: t("systems.FORGOT_PASSWORD_LINK")
|
|
4667
4485
|
}
|
|
4668
4486
|
) })
|
|
4669
4487
|
] }),
|
|
4670
|
-
/* @__PURE__ */
|
|
4488
|
+
/* @__PURE__ */ jsx43(FormControl12, { children: /* @__PURE__ */ jsx43(
|
|
4671
4489
|
PasswordInput,
|
|
4672
4490
|
{
|
|
4673
4491
|
autoComplete: "current-password",
|
|
@@ -4678,17 +4496,17 @@ function SignInForm({
|
|
|
4678
4496
|
...field
|
|
4679
4497
|
}
|
|
4680
4498
|
) }),
|
|
4681
|
-
/* @__PURE__ */
|
|
4499
|
+
/* @__PURE__ */ jsx43(FormMessage12, { className: classNames?.error })
|
|
4682
4500
|
] })
|
|
4683
4501
|
}
|
|
4684
4502
|
),
|
|
4685
|
-
/* @__PURE__ */
|
|
4503
|
+
/* @__PURE__ */ jsx43(
|
|
4686
4504
|
FormField12,
|
|
4687
4505
|
{
|
|
4688
4506
|
control: form.control,
|
|
4689
4507
|
name: "rememberMe",
|
|
4690
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4691
|
-
/* @__PURE__ */
|
|
4508
|
+
render: ({ field }) => /* @__PURE__ */ jsx43(FormItem12, { children: /* @__PURE__ */ jsxs37("div", { className: "flex items-center space-x-2", children: [
|
|
4509
|
+
/* @__PURE__ */ jsx43(FormControl12, { children: /* @__PURE__ */ jsx43(
|
|
4692
4510
|
Checkbox2,
|
|
4693
4511
|
{
|
|
4694
4512
|
checked: field.value,
|
|
@@ -4696,18 +4514,18 @@ function SignInForm({
|
|
|
4696
4514
|
disabled: submitting
|
|
4697
4515
|
}
|
|
4698
4516
|
) }),
|
|
4699
|
-
/* @__PURE__ */
|
|
4517
|
+
/* @__PURE__ */ jsx43(FormLabel11, { children: t("systems.REMEMBER_ME") })
|
|
4700
4518
|
] }) })
|
|
4701
4519
|
}
|
|
4702
4520
|
),
|
|
4703
|
-
/* @__PURE__ */
|
|
4704
|
-
|
|
4521
|
+
/* @__PURE__ */ jsxs37(
|
|
4522
|
+
Button27,
|
|
4705
4523
|
{
|
|
4706
4524
|
type: "submit",
|
|
4707
|
-
className:
|
|
4525
|
+
className: cn35("relative w-full", classNames?.button, classNames?.primaryButton),
|
|
4708
4526
|
disabled: submitting,
|
|
4709
4527
|
children: [
|
|
4710
|
-
/* @__PURE__ */
|
|
4528
|
+
/* @__PURE__ */ jsx43(
|
|
4711
4529
|
LastUsedButton,
|
|
4712
4530
|
{
|
|
4713
4531
|
className: classNames?.lastLoginMethod,
|
|
@@ -4715,7 +4533,7 @@ function SignInForm({
|
|
|
4715
4533
|
variant: "secondary"
|
|
4716
4534
|
}
|
|
4717
4535
|
),
|
|
4718
|
-
submitting ? /* @__PURE__ */
|
|
4536
|
+
submitting ? /* @__PURE__ */ jsx43(Spinner16, {}) : t("systems.SIGN_IN_ACTION")
|
|
4719
4537
|
]
|
|
4720
4538
|
}
|
|
4721
4539
|
)
|
|
@@ -4725,29 +4543,32 @@ function SignInForm({
|
|
|
4725
4543
|
}
|
|
4726
4544
|
|
|
4727
4545
|
// src/ui/auth/sign-out.tsx
|
|
4728
|
-
import { useEffect as
|
|
4729
|
-
import { Spinner as
|
|
4730
|
-
import { jsx as
|
|
4546
|
+
import { useEffect as useEffect10, useRef as useRef6 } from "react";
|
|
4547
|
+
import { Spinner as Spinner17 } from "pelatform-ui/default";
|
|
4548
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
4731
4549
|
function SignOut({ redirectTo }) {
|
|
4732
4550
|
const { authClient, auth } = useConfig();
|
|
4733
4551
|
const { onSuccess } = useOnSuccessTransition(redirectTo || auth.redirectAfterLogout || "/");
|
|
4734
4552
|
const signingOut = useRef6(false);
|
|
4735
|
-
|
|
4553
|
+
useEffect10(() => {
|
|
4736
4554
|
if (signingOut.current) return;
|
|
4737
4555
|
signingOut.current = true;
|
|
4738
4556
|
authClient.signOut().finally(onSuccess);
|
|
4739
4557
|
}, [authClient, onSuccess]);
|
|
4740
|
-
return /* @__PURE__ */
|
|
4558
|
+
return /* @__PURE__ */ jsx44("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx44(Spinner17, { className: "size-12" }) });
|
|
4741
4559
|
}
|
|
4742
4560
|
|
|
4743
4561
|
// src/ui/auth/sign-up.tsx
|
|
4744
|
-
import { useEffect as
|
|
4745
|
-
import { useRouter as
|
|
4562
|
+
import { useEffect as useEffect11 } from "react";
|
|
4563
|
+
import { useRouter as useRouter12 } from "next/navigation";
|
|
4746
4564
|
import { zodResolver as zodResolver13 } from "@hookform/resolvers/zod";
|
|
4747
|
-
import { useTranslations as
|
|
4748
|
-
import {
|
|
4565
|
+
import { useTranslations as useTranslations38 } from "next-intl";
|
|
4566
|
+
import { useForm as useForm14 } from "react-hook-form";
|
|
4567
|
+
import { z as z13 } from "zod";
|
|
4568
|
+
import { cn as cn36 } from "pelatform-ui";
|
|
4569
|
+
import { AlertToast as AlertToast22 } from "pelatform-ui/components";
|
|
4749
4570
|
import {
|
|
4750
|
-
Button as
|
|
4571
|
+
Button as Button28,
|
|
4751
4572
|
Form as Form14,
|
|
4752
4573
|
FormControl as FormControl13,
|
|
4753
4574
|
FormField as FormField13,
|
|
@@ -4755,12 +4576,9 @@ import {
|
|
|
4755
4576
|
FormLabel as FormLabel12,
|
|
4756
4577
|
FormMessage as FormMessage13,
|
|
4757
4578
|
Input as Input11,
|
|
4758
|
-
Spinner as
|
|
4579
|
+
Spinner as Spinner18
|
|
4759
4580
|
} from "pelatform-ui/default";
|
|
4760
|
-
import {
|
|
4761
|
-
import { z as z13 } from "zod";
|
|
4762
|
-
import { cn as cn37 } from "@pelatform/utils";
|
|
4763
|
-
import { jsx as jsx46, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
4581
|
+
import { jsx as jsx45, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
4764
4582
|
function SignUpForm({
|
|
4765
4583
|
className,
|
|
4766
4584
|
classNames,
|
|
@@ -4769,8 +4587,8 @@ function SignUpForm({
|
|
|
4769
4587
|
setIsSubmitting
|
|
4770
4588
|
}) {
|
|
4771
4589
|
const { authClient, app, path } = useConfig();
|
|
4772
|
-
const t =
|
|
4773
|
-
const router =
|
|
4590
|
+
const t = useTranslations38();
|
|
4591
|
+
const router = useRouter12();
|
|
4774
4592
|
const {
|
|
4775
4593
|
onSuccess,
|
|
4776
4594
|
isPending: transitionPending,
|
|
@@ -4794,7 +4612,7 @@ function SignUpForm({
|
|
|
4794
4612
|
}
|
|
4795
4613
|
});
|
|
4796
4614
|
const submitting = isSubmitting || form.formState.isSubmitting || transitionPending;
|
|
4797
|
-
|
|
4615
|
+
useEffect11(() => {
|
|
4798
4616
|
setIsSubmitting?.(form.formState.isSubmitting || transitionPending);
|
|
4799
4617
|
}, [form.formState.isSubmitting, setIsSubmitting, transitionPending]);
|
|
4800
4618
|
async function onSubmit({ name, email, password }) {
|
|
@@ -4809,33 +4627,33 @@ function SignUpForm({
|
|
|
4809
4627
|
if ("token" in data && data.token) {
|
|
4810
4628
|
await onSuccess();
|
|
4811
4629
|
} else {
|
|
4812
|
-
|
|
4630
|
+
AlertToast22({
|
|
4813
4631
|
message: t("systems.SIGN_UP_EMAIL")
|
|
4814
4632
|
});
|
|
4815
4633
|
router.push(`${path.auth.SIGN_IN}${window.location.search}`);
|
|
4816
4634
|
}
|
|
4817
4635
|
} catch (error) {
|
|
4818
|
-
|
|
4636
|
+
AlertToast22({
|
|
4819
4637
|
message: getTranslations({ error, t }),
|
|
4820
4638
|
icon: "destructive"
|
|
4821
4639
|
});
|
|
4822
4640
|
form.resetField("password");
|
|
4823
4641
|
}
|
|
4824
4642
|
}
|
|
4825
|
-
return /* @__PURE__ */
|
|
4643
|
+
return /* @__PURE__ */ jsx45(Form14, { ...form, children: /* @__PURE__ */ jsxs38(
|
|
4826
4644
|
"form",
|
|
4827
4645
|
{
|
|
4828
4646
|
onSubmit: form.handleSubmit(onSubmit),
|
|
4829
|
-
className:
|
|
4647
|
+
className: cn36("grid w-full gap-6", className, classNames?.base),
|
|
4830
4648
|
children: [
|
|
4831
|
-
/* @__PURE__ */
|
|
4649
|
+
/* @__PURE__ */ jsx45(
|
|
4832
4650
|
FormField13,
|
|
4833
4651
|
{
|
|
4834
4652
|
control: form.control,
|
|
4835
4653
|
name: "name",
|
|
4836
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4837
|
-
/* @__PURE__ */
|
|
4838
|
-
/* @__PURE__ */
|
|
4654
|
+
render: ({ field }) => /* @__PURE__ */ jsxs38(FormItem13, { children: [
|
|
4655
|
+
/* @__PURE__ */ jsx45(FormLabel12, { className: classNames?.label, children: t("systems.NAME") }),
|
|
4656
|
+
/* @__PURE__ */ jsx45(FormControl13, { children: /* @__PURE__ */ jsx45(
|
|
4839
4657
|
Input11,
|
|
4840
4658
|
{
|
|
4841
4659
|
type: "text",
|
|
@@ -4846,18 +4664,18 @@ function SignUpForm({
|
|
|
4846
4664
|
...field
|
|
4847
4665
|
}
|
|
4848
4666
|
) }),
|
|
4849
|
-
/* @__PURE__ */
|
|
4667
|
+
/* @__PURE__ */ jsx45(FormMessage13, { className: classNames?.error })
|
|
4850
4668
|
] })
|
|
4851
4669
|
}
|
|
4852
4670
|
),
|
|
4853
|
-
/* @__PURE__ */
|
|
4671
|
+
/* @__PURE__ */ jsx45(
|
|
4854
4672
|
FormField13,
|
|
4855
4673
|
{
|
|
4856
4674
|
control: form.control,
|
|
4857
4675
|
name: "email",
|
|
4858
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4859
|
-
/* @__PURE__ */
|
|
4860
|
-
/* @__PURE__ */
|
|
4676
|
+
render: ({ field }) => /* @__PURE__ */ jsxs38(FormItem13, { children: [
|
|
4677
|
+
/* @__PURE__ */ jsx45(FormLabel12, { className: classNames?.label, children: t("systems.EMAIL") }),
|
|
4678
|
+
/* @__PURE__ */ jsx45(FormControl13, { children: /* @__PURE__ */ jsx45(
|
|
4861
4679
|
Input11,
|
|
4862
4680
|
{
|
|
4863
4681
|
type: "email",
|
|
@@ -4868,18 +4686,18 @@ function SignUpForm({
|
|
|
4868
4686
|
...field
|
|
4869
4687
|
}
|
|
4870
4688
|
) }),
|
|
4871
|
-
/* @__PURE__ */
|
|
4689
|
+
/* @__PURE__ */ jsx45(FormMessage13, { className: classNames?.error })
|
|
4872
4690
|
] })
|
|
4873
4691
|
}
|
|
4874
4692
|
),
|
|
4875
|
-
/* @__PURE__ */
|
|
4693
|
+
/* @__PURE__ */ jsx45(
|
|
4876
4694
|
FormField13,
|
|
4877
4695
|
{
|
|
4878
4696
|
control: form.control,
|
|
4879
4697
|
name: "password",
|
|
4880
|
-
render: ({ field }) => /* @__PURE__ */
|
|
4881
|
-
/* @__PURE__ */
|
|
4882
|
-
/* @__PURE__ */
|
|
4698
|
+
render: ({ field }) => /* @__PURE__ */ jsxs38(FormItem13, { children: [
|
|
4699
|
+
/* @__PURE__ */ jsx45(FormLabel12, { className: classNames?.label, children: t("systems.PASSWORD") }),
|
|
4700
|
+
/* @__PURE__ */ jsx45(FormControl13, { children: /* @__PURE__ */ jsx45(
|
|
4883
4701
|
PasswordInput,
|
|
4884
4702
|
{
|
|
4885
4703
|
autoComplete: "new-password",
|
|
@@ -4890,17 +4708,17 @@ function SignUpForm({
|
|
|
4890
4708
|
...field
|
|
4891
4709
|
}
|
|
4892
4710
|
) }),
|
|
4893
|
-
/* @__PURE__ */
|
|
4711
|
+
/* @__PURE__ */ jsx45(FormMessage13, { className: classNames?.error })
|
|
4894
4712
|
] })
|
|
4895
4713
|
}
|
|
4896
4714
|
),
|
|
4897
|
-
/* @__PURE__ */
|
|
4898
|
-
|
|
4715
|
+
/* @__PURE__ */ jsx45(
|
|
4716
|
+
Button28,
|
|
4899
4717
|
{
|
|
4900
4718
|
type: "submit",
|
|
4901
|
-
className:
|
|
4719
|
+
className: cn36("w-full", classNames?.button, classNames?.primaryButton),
|
|
4902
4720
|
disabled: submitting,
|
|
4903
|
-
children: submitting ? /* @__PURE__ */
|
|
4721
|
+
children: submitting ? /* @__PURE__ */ jsx45(Spinner18, {}) : t("systems.SIGN_UP_ACTION")
|
|
4904
4722
|
}
|
|
4905
4723
|
)
|
|
4906
4724
|
]
|
|
@@ -4909,15 +4727,19 @@ function SignUpForm({
|
|
|
4909
4727
|
}
|
|
4910
4728
|
|
|
4911
4729
|
// src/ui/auth/two-factor.tsx
|
|
4912
|
-
import { useCallback as useCallback2, useEffect as
|
|
4730
|
+
import { useCallback as useCallback2, useEffect as useEffect12, useMemo as useMemo4, useRef as useRef7, useState as useState15 } from "react";
|
|
4913
4731
|
import Link2 from "next/link";
|
|
4914
|
-
import { useSearchParams as
|
|
4732
|
+
import { useSearchParams as useSearchParams5 } from "next/navigation";
|
|
4915
4733
|
import { zodResolver as zodResolver14 } from "@hookform/resolvers/zod";
|
|
4916
4734
|
import { QrCodeIcon, SendIcon } from "lucide-react";
|
|
4917
|
-
import { useTranslations as
|
|
4918
|
-
import
|
|
4735
|
+
import { useTranslations as useTranslations39 } from "next-intl";
|
|
4736
|
+
import QRCode from "qrcode";
|
|
4737
|
+
import { useForm as useForm15 } from "react-hook-form";
|
|
4738
|
+
import { z as z14 } from "zod";
|
|
4739
|
+
import { cn as cn37 } from "pelatform-ui";
|
|
4740
|
+
import { AlertToast as AlertToast23 } from "pelatform-ui/components";
|
|
4919
4741
|
import {
|
|
4920
|
-
Button as
|
|
4742
|
+
Button as Button29,
|
|
4921
4743
|
Checkbox as Checkbox3,
|
|
4922
4744
|
Form as Form15,
|
|
4923
4745
|
FormControl as FormControl14,
|
|
@@ -4927,13 +4749,9 @@ import {
|
|
|
4927
4749
|
FormMessage as FormMessage14,
|
|
4928
4750
|
InputOTP as InputOTP2,
|
|
4929
4751
|
Label,
|
|
4930
|
-
Spinner as
|
|
4752
|
+
Spinner as Spinner19
|
|
4931
4753
|
} from "pelatform-ui/default";
|
|
4932
|
-
import
|
|
4933
|
-
import { useForm as useForm15 } from "react-hook-form";
|
|
4934
|
-
import { z as z14 } from "zod";
|
|
4935
|
-
import { cn as cn38 } from "@pelatform/utils";
|
|
4936
|
-
import { Fragment as Fragment15, jsx as jsx47, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
4754
|
+
import { Fragment as Fragment15, jsx as jsx46, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
4937
4755
|
function TwoFactorForm({
|
|
4938
4756
|
className,
|
|
4939
4757
|
classNames,
|
|
@@ -4943,16 +4761,16 @@ function TwoFactorForm({
|
|
|
4943
4761
|
setIsSubmitting
|
|
4944
4762
|
}) {
|
|
4945
4763
|
const { authClient, path } = useConfig();
|
|
4946
|
-
const searchParams =
|
|
4947
|
-
const t =
|
|
4764
|
+
const searchParams = useSearchParams5();
|
|
4765
|
+
const t = useTranslations39();
|
|
4948
4766
|
const { user } = useSession();
|
|
4949
4767
|
const { onSuccess, isPending: transitionPending } = useOnSuccessTransition(redirectToProp);
|
|
4950
4768
|
const totpURI = searchParams?.get("totpURI");
|
|
4951
4769
|
const isTwoFactorEnabled = user?.twoFactorEnabled;
|
|
4952
4770
|
const initialSendRef = useRef7(false);
|
|
4953
|
-
const [method, setMethod] =
|
|
4954
|
-
const [isSendingOtp, setIsSendingOtp] =
|
|
4955
|
-
const [cooldownSeconds, setCooldownSeconds] =
|
|
4771
|
+
const [method, setMethod] = useState15("totp");
|
|
4772
|
+
const [isSendingOtp, setIsSendingOtp] = useState15(false);
|
|
4773
|
+
const [cooldownSeconds, setCooldownSeconds] = useState15(0);
|
|
4956
4774
|
const formSchema = z14.object({
|
|
4957
4775
|
code: z14.string().min(1, {
|
|
4958
4776
|
error: `${t("systems.ONE_TIME_PASSWORD")} ${t("systems.IS_REQUIRED")}`
|
|
@@ -4969,16 +4787,16 @@ function TwoFactorForm({
|
|
|
4969
4787
|
}
|
|
4970
4788
|
});
|
|
4971
4789
|
const submitting = isSubmitting || form.formState.isSubmitting || transitionPending;
|
|
4972
|
-
|
|
4790
|
+
useEffect12(() => {
|
|
4973
4791
|
setIsSubmitting?.(form.formState.isSubmitting || transitionPending);
|
|
4974
4792
|
}, [form.formState.isSubmitting, setIsSubmitting, transitionPending]);
|
|
4975
|
-
|
|
4793
|
+
useEffect12(() => {
|
|
4976
4794
|
if (method === "otp" && cooldownSeconds <= 0 && !initialSendRef.current) {
|
|
4977
4795
|
initialSendRef.current = true;
|
|
4978
4796
|
sendOtp();
|
|
4979
4797
|
}
|
|
4980
4798
|
}, [method]);
|
|
4981
|
-
|
|
4799
|
+
useEffect12(() => {
|
|
4982
4800
|
if (cooldownSeconds <= 0) return;
|
|
4983
4801
|
const timer = setTimeout(() => {
|
|
4984
4802
|
setCooldownSeconds((prev) => prev - 1);
|
|
@@ -4994,7 +4812,7 @@ function TwoFactorForm({
|
|
|
4994
4812
|
});
|
|
4995
4813
|
setCooldownSeconds(60);
|
|
4996
4814
|
} catch (error) {
|
|
4997
|
-
|
|
4815
|
+
AlertToast23({
|
|
4998
4816
|
message: getTranslations({ error, t }),
|
|
4999
4817
|
icon: "destructive"
|
|
5000
4818
|
});
|
|
@@ -5015,47 +4833,47 @@ function TwoFactorForm({
|
|
|
5015
4833
|
});
|
|
5016
4834
|
await onSuccess();
|
|
5017
4835
|
if (user && !isTwoFactorEnabled) {
|
|
5018
|
-
|
|
4836
|
+
AlertToast23({
|
|
5019
4837
|
message: t("systems.TWO_FACTOR_ENABLED")
|
|
5020
4838
|
});
|
|
5021
4839
|
}
|
|
5022
4840
|
} catch (error) {
|
|
5023
|
-
|
|
4841
|
+
AlertToast23({
|
|
5024
4842
|
message: getTranslations({ error, t }),
|
|
5025
4843
|
icon: "destructive"
|
|
5026
4844
|
});
|
|
5027
4845
|
form.reset();
|
|
5028
4846
|
}
|
|
5029
4847
|
}
|
|
5030
|
-
return /* @__PURE__ */
|
|
4848
|
+
return /* @__PURE__ */ jsx46(Form15, { ...form, children: /* @__PURE__ */ jsxs39(
|
|
5031
4849
|
"form",
|
|
5032
4850
|
{
|
|
5033
4851
|
onSubmit: form.handleSubmit(onSubmit),
|
|
5034
|
-
className:
|
|
4852
|
+
className: cn37("grid w-full gap-6", className, classNames?.base),
|
|
5035
4853
|
children: [
|
|
5036
|
-
totpURI && method === "totp" && /* @__PURE__ */
|
|
5037
|
-
/* @__PURE__ */
|
|
5038
|
-
/* @__PURE__ */
|
|
4854
|
+
totpURI && method === "totp" && /* @__PURE__ */ jsxs39("div", { className: "space-y-3", children: [
|
|
4855
|
+
/* @__PURE__ */ jsx46(Label, { className: cn37("block", classNames?.label), children: t("systems.TWO_FACTOR_TOTP_LABEL") }),
|
|
4856
|
+
/* @__PURE__ */ jsx46(QRCodeComponent, { className: classNames?.qrCode, value: totpURI })
|
|
5039
4857
|
] }),
|
|
5040
|
-
method !== null && /* @__PURE__ */
|
|
5041
|
-
/* @__PURE__ */
|
|
4858
|
+
method !== null && /* @__PURE__ */ jsxs39(Fragment15, { children: [
|
|
4859
|
+
/* @__PURE__ */ jsx46(
|
|
5042
4860
|
FormField14,
|
|
5043
4861
|
{
|
|
5044
4862
|
control: form.control,
|
|
5045
4863
|
name: "code",
|
|
5046
|
-
render: ({ field }) => /* @__PURE__ */
|
|
5047
|
-
/* @__PURE__ */
|
|
5048
|
-
/* @__PURE__ */
|
|
5049
|
-
/* @__PURE__ */
|
|
4864
|
+
render: ({ field }) => /* @__PURE__ */ jsxs39(FormItem14, { children: [
|
|
4865
|
+
/* @__PURE__ */ jsxs39("div", { className: "flex items-center justify-between", children: [
|
|
4866
|
+
/* @__PURE__ */ jsx46(FormLabel13, { className: classNames?.label, children: t("systems.ONE_TIME_PASSWORD") }),
|
|
4867
|
+
/* @__PURE__ */ jsx46(
|
|
5050
4868
|
Link2,
|
|
5051
4869
|
{
|
|
5052
|
-
className:
|
|
4870
|
+
className: cn37("text-sm hover:underline", classNames?.forgotPasswordLink),
|
|
5053
4871
|
href: `${path.auth.RECOVER_ACCOUNT}${window.location.search}`,
|
|
5054
4872
|
children: t("systems.FORGOT_AUTHENTICATOR")
|
|
5055
4873
|
}
|
|
5056
4874
|
)
|
|
5057
4875
|
] }),
|
|
5058
|
-
/* @__PURE__ */
|
|
4876
|
+
/* @__PURE__ */ jsx46(FormControl14, { children: /* @__PURE__ */ jsx46(
|
|
5059
4877
|
InputOTP2,
|
|
5060
4878
|
{
|
|
5061
4879
|
...field,
|
|
@@ -5069,20 +4887,20 @@ function TwoFactorForm({
|
|
|
5069
4887
|
containerClassName: classNames?.otpInputContainer,
|
|
5070
4888
|
className: classNames?.otpInput,
|
|
5071
4889
|
disabled: submitting,
|
|
5072
|
-
children: /* @__PURE__ */
|
|
4890
|
+
children: /* @__PURE__ */ jsx46(OTPInputGroup, { otpSeparators })
|
|
5073
4891
|
}
|
|
5074
4892
|
) }),
|
|
5075
|
-
/* @__PURE__ */
|
|
4893
|
+
/* @__PURE__ */ jsx46(FormMessage14, { className: classNames?.error })
|
|
5076
4894
|
] })
|
|
5077
4895
|
}
|
|
5078
4896
|
),
|
|
5079
|
-
/* @__PURE__ */
|
|
4897
|
+
/* @__PURE__ */ jsx46(
|
|
5080
4898
|
FormField14,
|
|
5081
4899
|
{
|
|
5082
4900
|
control: form.control,
|
|
5083
4901
|
name: "trustDevice",
|
|
5084
|
-
render: ({ field }) => /* @__PURE__ */
|
|
5085
|
-
/* @__PURE__ */
|
|
4902
|
+
render: ({ field }) => /* @__PURE__ */ jsx46(FormItem14, { children: /* @__PURE__ */ jsxs39("div", { className: "flex items-center space-x-2", children: [
|
|
4903
|
+
/* @__PURE__ */ jsx46(FormControl14, { children: /* @__PURE__ */ jsx46(
|
|
5086
4904
|
Checkbox3,
|
|
5087
4905
|
{
|
|
5088
4906
|
className: classNames?.checkbox,
|
|
@@ -5091,60 +4909,60 @@ function TwoFactorForm({
|
|
|
5091
4909
|
disabled: submitting
|
|
5092
4910
|
}
|
|
5093
4911
|
) }),
|
|
5094
|
-
/* @__PURE__ */
|
|
4912
|
+
/* @__PURE__ */ jsx46(FormLabel13, { className: classNames?.label, children: t("systems.TRUST_DEVICE") })
|
|
5095
4913
|
] }) })
|
|
5096
4914
|
}
|
|
5097
4915
|
)
|
|
5098
4916
|
] }),
|
|
5099
|
-
/* @__PURE__ */
|
|
5100
|
-
method !== null && /* @__PURE__ */
|
|
5101
|
-
|
|
4917
|
+
/* @__PURE__ */ jsxs39("div", { className: "grid gap-4", children: [
|
|
4918
|
+
method !== null && /* @__PURE__ */ jsx46(
|
|
4919
|
+
Button29,
|
|
5102
4920
|
{
|
|
5103
4921
|
type: "submit",
|
|
5104
|
-
className:
|
|
4922
|
+
className: cn37(classNames?.button, classNames?.primaryButton),
|
|
5105
4923
|
disabled: submitting,
|
|
5106
|
-
children: submitting ? /* @__PURE__ */
|
|
4924
|
+
children: submitting ? /* @__PURE__ */ jsx46(Spinner19, {}) : t("systems.TWO_FACTOR_ACTION")
|
|
5107
4925
|
}
|
|
5108
4926
|
),
|
|
5109
|
-
method === "otp" && /* @__PURE__ */
|
|
5110
|
-
|
|
4927
|
+
method === "otp" && /* @__PURE__ */ jsxs39(
|
|
4928
|
+
Button29,
|
|
5111
4929
|
{
|
|
5112
4930
|
type: "button",
|
|
5113
4931
|
variant: "outline",
|
|
5114
|
-
className:
|
|
4932
|
+
className: cn37(classNames?.button, classNames?.outlineButton),
|
|
5115
4933
|
onClick: sendOtp,
|
|
5116
4934
|
disabled: cooldownSeconds > 0 || isSendingOtp || submitting,
|
|
5117
4935
|
children: [
|
|
5118
|
-
isSendingOtp ? /* @__PURE__ */
|
|
4936
|
+
isSendingOtp ? /* @__PURE__ */ jsx46(Spinner19, {}) : /* @__PURE__ */ jsx46(SendIcon, { className: classNames?.icon }),
|
|
5119
4937
|
t("systems.RESEND_CODE"),
|
|
5120
4938
|
cooldownSeconds > 0 && ` (${cooldownSeconds})`
|
|
5121
4939
|
]
|
|
5122
4940
|
}
|
|
5123
4941
|
),
|
|
5124
|
-
method !== "otp" && /* @__PURE__ */
|
|
5125
|
-
|
|
4942
|
+
method !== "otp" && /* @__PURE__ */ jsxs39(
|
|
4943
|
+
Button29,
|
|
5126
4944
|
{
|
|
5127
4945
|
type: "button",
|
|
5128
4946
|
variant: "secondary",
|
|
5129
|
-
className:
|
|
4947
|
+
className: cn37(classNames?.button, classNames?.secondaryButton),
|
|
5130
4948
|
onClick: () => setMethod("otp"),
|
|
5131
4949
|
disabled: submitting,
|
|
5132
4950
|
children: [
|
|
5133
|
-
/* @__PURE__ */
|
|
4951
|
+
/* @__PURE__ */ jsx46(SendIcon, { className: classNames?.icon }),
|
|
5134
4952
|
t("systems.SEND_VERIFICATION_CODE")
|
|
5135
4953
|
]
|
|
5136
4954
|
}
|
|
5137
4955
|
),
|
|
5138
|
-
method !== "totp" && /* @__PURE__ */
|
|
5139
|
-
|
|
4956
|
+
method !== "totp" && /* @__PURE__ */ jsxs39(
|
|
4957
|
+
Button29,
|
|
5140
4958
|
{
|
|
5141
4959
|
type: "button",
|
|
5142
4960
|
variant: "secondary",
|
|
5143
|
-
className:
|
|
4961
|
+
className: cn37(classNames?.button, classNames?.secondaryButton),
|
|
5144
4962
|
onClick: () => setMethod("totp"),
|
|
5145
4963
|
disabled: submitting,
|
|
5146
4964
|
children: [
|
|
5147
|
-
/* @__PURE__ */
|
|
4965
|
+
/* @__PURE__ */ jsx46(QrCodeIcon, { className: classNames?.icon }),
|
|
5148
4966
|
t("systems.CONTINUE_WITH_AUTHENTICATOR")
|
|
5149
4967
|
]
|
|
5150
4968
|
}
|
|
@@ -5161,12 +4979,12 @@ function QRCodeComponent({
|
|
|
5161
4979
|
as = "svg",
|
|
5162
4980
|
className
|
|
5163
4981
|
}) {
|
|
5164
|
-
const [src, setSrc] =
|
|
4982
|
+
const [src, setSrc] = useState15("");
|
|
5165
4983
|
const opts = useMemo4(
|
|
5166
4984
|
() => ({ errorCorrectionLevel: level, margin: 1, width: size }),
|
|
5167
4985
|
[level, size]
|
|
5168
4986
|
);
|
|
5169
|
-
|
|
4987
|
+
useEffect12(() => {
|
|
5170
4988
|
let cancelled = false;
|
|
5171
4989
|
if (as === "img") {
|
|
5172
4990
|
QRCode.toDataURL(value, opts).then((url) => !cancelled && setSrc(url));
|
|
@@ -5181,36 +4999,36 @@ function QRCodeComponent({
|
|
|
5181
4999
|
}, [value, opts, as]);
|
|
5182
5000
|
if (!src) return null;
|
|
5183
5001
|
if (as === "img") {
|
|
5184
|
-
return /* @__PURE__ */
|
|
5002
|
+
return /* @__PURE__ */ jsx46("img", { src, width: size, height: size, alt: "QR code", className });
|
|
5185
5003
|
}
|
|
5186
|
-
return /* @__PURE__ */
|
|
5004
|
+
return /* @__PURE__ */ jsx46(
|
|
5187
5005
|
"span",
|
|
5188
5006
|
{
|
|
5189
|
-
className:
|
|
5007
|
+
className: cn37("block", className),
|
|
5190
5008
|
dangerouslySetInnerHTML: { __html: src }
|
|
5191
5009
|
}
|
|
5192
5010
|
);
|
|
5193
5011
|
}
|
|
5194
5012
|
|
|
5195
5013
|
// src/ui/auth/view.tsx
|
|
5196
|
-
import { useEffect as
|
|
5014
|
+
import { useEffect as useEffect13, useState as useState16 } from "react";
|
|
5197
5015
|
import Link3 from "next/link";
|
|
5198
|
-
import { useRouter as
|
|
5016
|
+
import { useRouter as useRouter13 } from "next/navigation";
|
|
5199
5017
|
import { ArrowLeftIcon } from "lucide-react";
|
|
5200
|
-
import { useTranslations as
|
|
5018
|
+
import { useTranslations as useTranslations40 } from "next-intl";
|
|
5019
|
+
import { cn as cn38 } from "pelatform-ui";
|
|
5201
5020
|
import {
|
|
5202
|
-
Button as
|
|
5203
|
-
Card as
|
|
5204
|
-
CardContent as
|
|
5021
|
+
Button as Button30,
|
|
5022
|
+
Card as Card10,
|
|
5023
|
+
CardContent as CardContent2,
|
|
5205
5024
|
CardDescription,
|
|
5206
5025
|
CardFooter as CardFooter2,
|
|
5207
|
-
CardHeader
|
|
5026
|
+
CardHeader,
|
|
5208
5027
|
CardHeading,
|
|
5209
5028
|
CardTitle,
|
|
5210
5029
|
Separator
|
|
5211
5030
|
} from "pelatform-ui/default";
|
|
5212
|
-
import {
|
|
5213
|
-
import { Fragment as Fragment16, jsx as jsx48, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
5031
|
+
import { Fragment as Fragment16, jsx as jsx47, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
5214
5032
|
function getViewByPath(pathConfig, path) {
|
|
5215
5033
|
if (!path) return null;
|
|
5216
5034
|
const cleanPath = path.replace(/^\//, "").split("?")[0];
|
|
@@ -5234,7 +5052,7 @@ function AuthView({
|
|
|
5234
5052
|
view: viewProp
|
|
5235
5053
|
}) {
|
|
5236
5054
|
const { auth, features, path: pathConfig } = useConfig();
|
|
5237
|
-
const t =
|
|
5055
|
+
const t = useTranslations40();
|
|
5238
5056
|
const auths = auth.authentication;
|
|
5239
5057
|
let socialLayout = socialLayoutProp;
|
|
5240
5058
|
if (socialLayout === "auto") {
|
|
@@ -5242,8 +5060,8 @@ function AuthView({
|
|
|
5242
5060
|
}
|
|
5243
5061
|
const currentPath = pathProp ?? pathname?.split("/").pop();
|
|
5244
5062
|
const view = viewProp || getViewByPath(pathConfig.auth, currentPath) || "SIGN_IN";
|
|
5245
|
-
const [isSubmitting, setIsSubmitting] =
|
|
5246
|
-
|
|
5063
|
+
const [isSubmitting, setIsSubmitting] = useState16(false);
|
|
5064
|
+
useEffect13(() => {
|
|
5247
5065
|
const handlePageHide = () => setIsSubmitting(false);
|
|
5248
5066
|
window.addEventListener("pagehide", handlePageHide);
|
|
5249
5067
|
return () => {
|
|
@@ -5251,12 +5069,9 @@ function AuthView({
|
|
|
5251
5069
|
window.removeEventListener("pagehide", handlePageHide);
|
|
5252
5070
|
};
|
|
5253
5071
|
}, []);
|
|
5254
|
-
const
|
|
5255
|
-
if (view === "CALLBACK") return /* @__PURE__ */
|
|
5256
|
-
if (view === "SIGN_OUT") return /* @__PURE__ */
|
|
5257
|
-
if (view === "ACCEPT_INVITATION" && enableAcceptInvitation) {
|
|
5258
|
-
return /* @__PURE__ */ jsx48(AcceptInvitation, {});
|
|
5259
|
-
}
|
|
5072
|
+
const _enableAcceptInvitation = enableAcceptInvitationProp ?? features.workspace;
|
|
5073
|
+
if (view === "CALLBACK") return /* @__PURE__ */ jsx47(AuthCallback, { redirectTo });
|
|
5074
|
+
if (view === "SIGN_OUT") return /* @__PURE__ */ jsx47(SignOut, {});
|
|
5260
5075
|
const description = !auths.password && !auths.magicLink && !auths.emailOtp ? t("systems.DISABLED_CREDENTIALS_DESCRIPTION") : t(`systems.${view}_DESCRIPTION`);
|
|
5261
5076
|
const showSocialProviders = view !== "RESET_PASSWORD" && view !== "FORGOT_PASSWORD" && auth.socialProviders && auth.socialProviders.length > 0;
|
|
5262
5077
|
const showPasskey = auths.passkey && [
|
|
@@ -5268,38 +5083,38 @@ function AuthView({
|
|
|
5268
5083
|
"FORGOT_PASSWORD"
|
|
5269
5084
|
].includes(view);
|
|
5270
5085
|
const showCredentials = auths.password || auths.magicLink || auths.emailOtp;
|
|
5271
|
-
return /* @__PURE__ */
|
|
5272
|
-
|
|
5086
|
+
return /* @__PURE__ */ jsxs40(
|
|
5087
|
+
Card10,
|
|
5273
5088
|
{
|
|
5274
|
-
className:
|
|
5089
|
+
className: cn38(
|
|
5275
5090
|
"w-full max-w-full border-0 bg-transparent p-0 shadow-none",
|
|
5276
5091
|
className,
|
|
5277
5092
|
classNames?.base
|
|
5278
5093
|
),
|
|
5279
5094
|
children: [
|
|
5280
|
-
/* @__PURE__ */
|
|
5281
|
-
|
|
5095
|
+
/* @__PURE__ */ jsx47(
|
|
5096
|
+
CardHeader,
|
|
5282
5097
|
{
|
|
5283
|
-
className:
|
|
5098
|
+
className: cn38(
|
|
5284
5099
|
"justify-center space-y-1.5 border-0 py-4 pb-3 text-center",
|
|
5285
5100
|
classNames?.header
|
|
5286
5101
|
),
|
|
5287
|
-
children: cardHeader ? cardHeader : /* @__PURE__ */
|
|
5288
|
-
/* @__PURE__ */
|
|
5289
|
-
description && /* @__PURE__ */
|
|
5102
|
+
children: cardHeader ? cardHeader : /* @__PURE__ */ jsxs40(CardHeading, { children: [
|
|
5103
|
+
/* @__PURE__ */ jsx47(CardTitle, { className: cn38("font-semibold text-2xl tracking-tight", classNames?.title), children: t(`systems.${view}`) }),
|
|
5104
|
+
description && /* @__PURE__ */ jsx47(
|
|
5290
5105
|
CardDescription,
|
|
5291
5106
|
{
|
|
5292
|
-
className:
|
|
5107
|
+
className: cn38("text-muted-foreground text-sm", classNames?.description),
|
|
5293
5108
|
children: description
|
|
5294
5109
|
}
|
|
5295
5110
|
)
|
|
5296
5111
|
] })
|
|
5297
5112
|
}
|
|
5298
5113
|
),
|
|
5299
|
-
/* @__PURE__ */
|
|
5300
|
-
auths.oneTap && ["SIGN_IN", "SIGN_UP", "MAGIC_LINK", "EMAIL_OTP"].includes(view) && /* @__PURE__ */
|
|
5301
|
-
showCredentials && /* @__PURE__ */
|
|
5302
|
-
/* @__PURE__ */
|
|
5114
|
+
/* @__PURE__ */ jsxs40(CardContent2, { className: cn38("grid gap-6", classNames?.content), children: [
|
|
5115
|
+
auths.oneTap && ["SIGN_IN", "SIGN_UP", "MAGIC_LINK", "EMAIL_OTP"].includes(view) && /* @__PURE__ */ jsx47(OneTap, { redirectTo }),
|
|
5116
|
+
showCredentials && /* @__PURE__ */ jsxs40("div", { className: "grid gap-4", children: [
|
|
5117
|
+
/* @__PURE__ */ jsx47(
|
|
5303
5118
|
AuthForm,
|
|
5304
5119
|
{
|
|
5305
5120
|
classNames: classNames?.form,
|
|
@@ -5312,22 +5127,22 @@ function AuthView({
|
|
|
5312
5127
|
),
|
|
5313
5128
|
auths.magicLink && (auths.password && ["FORGOT_PASSWORD", "SIGN_UP", "SIGN_IN", "MAGIC_LINK", "EMAIL_OTP"].includes(
|
|
5314
5129
|
view
|
|
5315
|
-
) || auths.emailOtp && view === "EMAIL_OTP") && /* @__PURE__ */
|
|
5130
|
+
) || auths.emailOtp && view === "EMAIL_OTP") && /* @__PURE__ */ jsx47(MagicLinkButton, { classNames, view }),
|
|
5316
5131
|
auths.emailOtp && (auths.password && ["FORGOT_PASSWORD", "SIGN_UP", "SIGN_IN", "MAGIC_LINK", "EMAIL_OTP"].includes(
|
|
5317
5132
|
view
|
|
5318
|
-
) || auths.magicLink && ["SIGN_IN", "MAGIC_LINK"].includes(view)) && /* @__PURE__ */
|
|
5133
|
+
) || auths.magicLink && ["SIGN_IN", "MAGIC_LINK"].includes(view)) && /* @__PURE__ */ jsx47(EmailOTPButton, { classNames, view })
|
|
5319
5134
|
] }),
|
|
5320
|
-
(showSocialProviders || showPasskey) && /* @__PURE__ */
|
|
5321
|
-
showCredentials && /* @__PURE__ */
|
|
5322
|
-
/* @__PURE__ */
|
|
5323
|
-
/* @__PURE__ */
|
|
5324
|
-
/* @__PURE__ */
|
|
5135
|
+
(showSocialProviders || showPasskey) && /* @__PURE__ */ jsxs40(Fragment16, { children: [
|
|
5136
|
+
showCredentials && /* @__PURE__ */ jsxs40("div", { className: cn38("flex items-center gap-2", classNames?.continueWith), children: [
|
|
5137
|
+
/* @__PURE__ */ jsx47(Separator, { className: cn38("w-auto! grow", classNames?.separator) }),
|
|
5138
|
+
/* @__PURE__ */ jsx47("span", { className: "shrink-0 text-muted-foreground text-sm", children: t("systems.OR_CONTINUE_WITH") }),
|
|
5139
|
+
/* @__PURE__ */ jsx47(Separator, { className: cn38("w-auto! grow", classNames?.separator) })
|
|
5325
5140
|
] }),
|
|
5326
|
-
/* @__PURE__ */
|
|
5327
|
-
showSocialProviders && /* @__PURE__ */
|
|
5141
|
+
/* @__PURE__ */ jsxs40("div", { className: "grid gap-4", children: [
|
|
5142
|
+
showSocialProviders && /* @__PURE__ */ jsx47(
|
|
5328
5143
|
"div",
|
|
5329
5144
|
{
|
|
5330
|
-
className:
|
|
5145
|
+
className: cn38(
|
|
5331
5146
|
"flex w-full items-center justify-between gap-4",
|
|
5332
5147
|
socialLayout === "horizontal" && "flex-wrap",
|
|
5333
5148
|
socialLayout === "vertical" && "flex-col",
|
|
@@ -5338,7 +5153,7 @@ function AuthView({
|
|
|
5338
5153
|
(socialProvider2) => socialProvider2.provider === provider
|
|
5339
5154
|
);
|
|
5340
5155
|
if (!socialProvider) return null;
|
|
5341
|
-
return /* @__PURE__ */
|
|
5156
|
+
return /* @__PURE__ */ jsx47(
|
|
5342
5157
|
ProviderButton,
|
|
5343
5158
|
{
|
|
5344
5159
|
classNames,
|
|
@@ -5353,50 +5168,50 @@ function AuthView({
|
|
|
5353
5168
|
})
|
|
5354
5169
|
}
|
|
5355
5170
|
),
|
|
5356
|
-
showPasskey && /* @__PURE__ */
|
|
5171
|
+
showPasskey && /* @__PURE__ */ jsx47(PasskeyButton, { classNames, redirectTo })
|
|
5357
5172
|
] })
|
|
5358
5173
|
] })
|
|
5359
5174
|
] }),
|
|
5360
|
-
auths.password && auth.enableSignup && /* @__PURE__ */
|
|
5175
|
+
auths.password && auth.enableSignup && /* @__PURE__ */ jsx47(
|
|
5361
5176
|
CardFooter2,
|
|
5362
5177
|
{
|
|
5363
|
-
className:
|
|
5178
|
+
className: cn38(
|
|
5364
5179
|
"justify-center gap-1.5 border-0 text-muted-foreground text-sm",
|
|
5365
5180
|
classNames?.footer
|
|
5366
5181
|
),
|
|
5367
|
-
children: view === "SIGN_IN" || view === "MAGIC_LINK" || view === "EMAIL_OTP" ? /* @__PURE__ */
|
|
5182
|
+
children: view === "SIGN_IN" || view === "MAGIC_LINK" || view === "EMAIL_OTP" ? /* @__PURE__ */ jsxs40(Fragment16, { children: [
|
|
5368
5183
|
t("systems.DONT_HAVE_AN_ACCOUNT"),
|
|
5369
|
-
/* @__PURE__ */
|
|
5370
|
-
|
|
5184
|
+
/* @__PURE__ */ jsx47(Link3, { href: `${pathConfig.auth.SIGN_UP}${window.location.search}`, children: /* @__PURE__ */ jsx47(
|
|
5185
|
+
Button30,
|
|
5371
5186
|
{
|
|
5372
5187
|
mode: "link",
|
|
5373
5188
|
underline: "dashed",
|
|
5374
5189
|
size: "sm",
|
|
5375
|
-
className:
|
|
5190
|
+
className: cn38("px-0 text-foreground", classNames?.footerLink),
|
|
5376
5191
|
children: t("systems.SIGN_UP")
|
|
5377
5192
|
}
|
|
5378
5193
|
) })
|
|
5379
|
-
] }) : view === "SIGN_UP" ? /* @__PURE__ */
|
|
5194
|
+
] }) : view === "SIGN_UP" ? /* @__PURE__ */ jsxs40(Fragment16, { children: [
|
|
5380
5195
|
t("systems.ALREADY_HAVE_AN_ACCOUNT"),
|
|
5381
|
-
/* @__PURE__ */
|
|
5382
|
-
|
|
5196
|
+
/* @__PURE__ */ jsx47(Link3, { href: `${pathConfig.auth.SIGN_IN}${window.location.search}`, children: /* @__PURE__ */ jsx47(
|
|
5197
|
+
Button30,
|
|
5383
5198
|
{
|
|
5384
5199
|
mode: "link",
|
|
5385
5200
|
underline: "dashed",
|
|
5386
5201
|
size: "sm",
|
|
5387
|
-
className:
|
|
5202
|
+
className: cn38("px-0 text-foreground", classNames?.footerLink),
|
|
5388
5203
|
children: t("systems.SIGN_IN")
|
|
5389
5204
|
}
|
|
5390
5205
|
) })
|
|
5391
|
-
] }) : /* @__PURE__ */
|
|
5392
|
-
/* @__PURE__ */
|
|
5393
|
-
/* @__PURE__ */
|
|
5394
|
-
|
|
5206
|
+
] }) : /* @__PURE__ */ jsxs40(Fragment16, { children: [
|
|
5207
|
+
/* @__PURE__ */ jsx47(ArrowLeftIcon, { className: "size-3" }),
|
|
5208
|
+
/* @__PURE__ */ jsx47(
|
|
5209
|
+
Button30,
|
|
5395
5210
|
{
|
|
5396
5211
|
mode: "link",
|
|
5397
5212
|
underline: "dashed",
|
|
5398
5213
|
size: "sm",
|
|
5399
|
-
className:
|
|
5214
|
+
className: cn38("px-0 text-foreground", classNames?.footerLink),
|
|
5400
5215
|
onClick: () => {
|
|
5401
5216
|
if (typeof window !== "undefined") {
|
|
5402
5217
|
window.history.back();
|
|
@@ -5423,10 +5238,10 @@ function AuthForm({
|
|
|
5423
5238
|
view: viewProp
|
|
5424
5239
|
}) {
|
|
5425
5240
|
const { auth, path: pathConfig } = useConfig();
|
|
5426
|
-
const router =
|
|
5241
|
+
const router = useRouter13();
|
|
5427
5242
|
const auths = auth.authentication;
|
|
5428
5243
|
const view = viewProp || getViewByPath(pathConfig.auth, pathname) || "SIGN_IN";
|
|
5429
|
-
|
|
5244
|
+
useEffect13(() => {
|
|
5430
5245
|
let isInvalidView = false;
|
|
5431
5246
|
if (view === "MAGIC_LINK" && (!auths.magicLink || !auths.password && !auths.emailOtp)) {
|
|
5432
5247
|
isInvalidView = true;
|
|
@@ -5458,10 +5273,10 @@ function AuthForm({
|
|
|
5458
5273
|
pathConfig.auth.SIGN_IN,
|
|
5459
5274
|
router
|
|
5460
5275
|
]);
|
|
5461
|
-
if (view === "SIGN_OUT") return /* @__PURE__ */
|
|
5462
|
-
if (view === "CALLBACK") return /* @__PURE__ */
|
|
5276
|
+
if (view === "SIGN_OUT") return /* @__PURE__ */ jsx47(SignOut, {});
|
|
5277
|
+
if (view === "CALLBACK") return /* @__PURE__ */ jsx47(AuthCallback, { redirectTo });
|
|
5463
5278
|
if (view === "SIGN_IN") {
|
|
5464
|
-
return auths.password ? /* @__PURE__ */
|
|
5279
|
+
return auths.password ? /* @__PURE__ */ jsx47(
|
|
5465
5280
|
SignInForm,
|
|
5466
5281
|
{
|
|
5467
5282
|
className,
|
|
@@ -5470,7 +5285,7 @@ function AuthForm({
|
|
|
5470
5285
|
redirectTo,
|
|
5471
5286
|
setIsSubmitting
|
|
5472
5287
|
}
|
|
5473
|
-
) : auths.magicLink ? /* @__PURE__ */
|
|
5288
|
+
) : auths.magicLink ? /* @__PURE__ */ jsx47(
|
|
5474
5289
|
MagicLinkForm,
|
|
5475
5290
|
{
|
|
5476
5291
|
className,
|
|
@@ -5478,7 +5293,7 @@ function AuthForm({
|
|
|
5478
5293
|
isSubmitting,
|
|
5479
5294
|
setIsSubmitting
|
|
5480
5295
|
}
|
|
5481
|
-
) : auths.emailOtp ? /* @__PURE__ */
|
|
5296
|
+
) : auths.emailOtp ? /* @__PURE__ */ jsx47(
|
|
5482
5297
|
EmailOTPForm,
|
|
5483
5298
|
{
|
|
5484
5299
|
className,
|
|
@@ -5490,7 +5305,7 @@ function AuthForm({
|
|
|
5490
5305
|
) : null;
|
|
5491
5306
|
}
|
|
5492
5307
|
if (view === "TWO_FACTOR") {
|
|
5493
|
-
return /* @__PURE__ */
|
|
5308
|
+
return /* @__PURE__ */ jsx47(
|
|
5494
5309
|
TwoFactorForm,
|
|
5495
5310
|
{
|
|
5496
5311
|
className,
|
|
@@ -5503,7 +5318,7 @@ function AuthForm({
|
|
|
5503
5318
|
);
|
|
5504
5319
|
}
|
|
5505
5320
|
if (view === "RECOVER_ACCOUNT") {
|
|
5506
|
-
return /* @__PURE__ */
|
|
5321
|
+
return /* @__PURE__ */ jsx47(
|
|
5507
5322
|
RecoverAccountForm,
|
|
5508
5323
|
{
|
|
5509
5324
|
className,
|
|
@@ -5515,7 +5330,7 @@ function AuthForm({
|
|
|
5515
5330
|
);
|
|
5516
5331
|
}
|
|
5517
5332
|
if (view === "MAGIC_LINK") {
|
|
5518
|
-
return /* @__PURE__ */
|
|
5333
|
+
return /* @__PURE__ */ jsx47(
|
|
5519
5334
|
MagicLinkForm,
|
|
5520
5335
|
{
|
|
5521
5336
|
className,
|
|
@@ -5526,7 +5341,7 @@ function AuthForm({
|
|
|
5526
5341
|
);
|
|
5527
5342
|
}
|
|
5528
5343
|
if (view === "EMAIL_OTP") {
|
|
5529
|
-
return /* @__PURE__ */
|
|
5344
|
+
return /* @__PURE__ */ jsx47(
|
|
5530
5345
|
EmailOTPForm,
|
|
5531
5346
|
{
|
|
5532
5347
|
className,
|
|
@@ -5538,7 +5353,7 @@ function AuthForm({
|
|
|
5538
5353
|
);
|
|
5539
5354
|
}
|
|
5540
5355
|
if (view === "FORGOT_PASSWORD") {
|
|
5541
|
-
return /* @__PURE__ */
|
|
5356
|
+
return /* @__PURE__ */ jsx47(
|
|
5542
5357
|
ForgotPasswordForm,
|
|
5543
5358
|
{
|
|
5544
5359
|
className,
|
|
@@ -5549,7 +5364,7 @@ function AuthForm({
|
|
|
5549
5364
|
);
|
|
5550
5365
|
}
|
|
5551
5366
|
if (view === "RESET_PASSWORD") {
|
|
5552
|
-
return /* @__PURE__ */
|
|
5367
|
+
return /* @__PURE__ */ jsx47(
|
|
5553
5368
|
ResetPasswordForm,
|
|
5554
5369
|
{
|
|
5555
5370
|
className,
|
|
@@ -5560,7 +5375,7 @@ function AuthForm({
|
|
|
5560
5375
|
);
|
|
5561
5376
|
}
|
|
5562
5377
|
if (view === "SIGN_UP") {
|
|
5563
|
-
return auth.enableSignup ? /* @__PURE__ */
|
|
5378
|
+
return auth.enableSignup ? /* @__PURE__ */ jsx47(
|
|
5564
5379
|
SignUpForm,
|
|
5565
5380
|
{
|
|
5566
5381
|
className,
|
|
@@ -5577,73 +5392,73 @@ function AuthForm({
|
|
|
5577
5392
|
// src/ui/layouts/auth.tsx
|
|
5578
5393
|
import Link6 from "next/link";
|
|
5579
5394
|
import { usePathname } from "next/navigation";
|
|
5580
|
-
import { useTranslations as
|
|
5395
|
+
import { useTranslations as useTranslations44 } from "next-intl";
|
|
5581
5396
|
import { LayoutBlank } from "pelatform-ui/components";
|
|
5582
5397
|
|
|
5583
5398
|
// src/ui/shared/logo.tsx
|
|
5584
5399
|
import Link4 from "next/link";
|
|
5400
|
+
import { cn as cn39 } from "pelatform-ui";
|
|
5585
5401
|
import { Logo } from "pelatform-ui/components";
|
|
5586
|
-
import {
|
|
5587
|
-
import { jsx as jsx49, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
5402
|
+
import { jsx as jsx48, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
5588
5403
|
function LogoWithName({ className }) {
|
|
5589
5404
|
const { app } = useConfig();
|
|
5590
|
-
return /* @__PURE__ */
|
|
5591
|
-
/* @__PURE__ */
|
|
5592
|
-
/* @__PURE__ */
|
|
5405
|
+
return /* @__PURE__ */ jsxs41("div", { className: cn39("flex items-center gap-2", className), children: [
|
|
5406
|
+
/* @__PURE__ */ jsx48(Logo, { className: "size-7" }),
|
|
5407
|
+
/* @__PURE__ */ jsx48("span", { className: "font-semibold text-lg text-mono", children: app.name })
|
|
5593
5408
|
] });
|
|
5594
5409
|
}
|
|
5595
5410
|
function LogoWithHref({ className, href = "/" }) {
|
|
5596
5411
|
const { app } = useConfig();
|
|
5597
|
-
return /* @__PURE__ */
|
|
5598
|
-
/* @__PURE__ */
|
|
5599
|
-
/* @__PURE__ */
|
|
5412
|
+
return /* @__PURE__ */ jsxs41(Link4, { href, className: cn39("flex items-center gap-2", className), children: [
|
|
5413
|
+
/* @__PURE__ */ jsx48(Logo, { className: "size-7" }),
|
|
5414
|
+
/* @__PURE__ */ jsx48("span", { className: "font-semibold text-lg text-mono", children: app.name })
|
|
5600
5415
|
] });
|
|
5601
5416
|
}
|
|
5602
5417
|
|
|
5603
5418
|
// src/ui/shared/signed-in-hint.tsx
|
|
5604
5419
|
import Link5 from "next/link";
|
|
5605
|
-
import { useTranslations as
|
|
5606
|
-
import { Button as
|
|
5607
|
-
import { jsx as
|
|
5420
|
+
import { useTranslations as useTranslations41 } from "next-intl";
|
|
5421
|
+
import { Button as Button31 } from "pelatform-ui/default";
|
|
5422
|
+
import { jsx as jsx49, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
5608
5423
|
function SignedInHint({ linkHref = "/signin" }) {
|
|
5609
|
-
const t =
|
|
5424
|
+
const t = useTranslations41("customs.common.signed");
|
|
5610
5425
|
const { isPending, user } = useSession();
|
|
5611
|
-
return /* @__PURE__ */
|
|
5612
|
-
/* @__PURE__ */
|
|
5426
|
+
return /* @__PURE__ */ jsxs42("div", { className: "fixed start-0 bottom-0 z-40 m-5 flex flex-col gap-2", children: [
|
|
5427
|
+
/* @__PURE__ */ jsxs42("div", { className: "flex items-center gap-1 text-muted-foreground text-xs", children: [
|
|
5613
5428
|
t("text"),
|
|
5614
5429
|
" ",
|
|
5615
|
-
isPending || !user ? /* @__PURE__ */
|
|
5430
|
+
isPending || !user ? /* @__PURE__ */ jsx49("span", { className: "h-3 w-32 animate-pulse rounded-md border bg-muted-foreground" }) : /* @__PURE__ */ jsx49("b", { className: "text-foreground", children: user.email })
|
|
5616
5431
|
] }),
|
|
5617
|
-
/* @__PURE__ */
|
|
5432
|
+
/* @__PURE__ */ jsx49(Button31, { variant: "mono", className: "h-8 w-fit rounded-lg px-3 text-xs shadow-sm", children: /* @__PURE__ */ jsx49(Link5, { href: linkHref, children: t("button") }) })
|
|
5618
5433
|
] });
|
|
5619
5434
|
}
|
|
5620
5435
|
|
|
5621
5436
|
// src/ui/layouts/loader.tsx
|
|
5622
|
-
import { useTranslations as
|
|
5437
|
+
import { useTranslations as useTranslations42 } from "next-intl";
|
|
5623
5438
|
import { ScreenLoader } from "pelatform-ui/components";
|
|
5624
|
-
import { jsx as
|
|
5439
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
5625
5440
|
function LayoutLoader({ children }) {
|
|
5626
|
-
const t =
|
|
5441
|
+
const t = useTranslations42();
|
|
5627
5442
|
const { isPending } = useSession();
|
|
5628
5443
|
if (isPending) {
|
|
5629
|
-
return /* @__PURE__ */
|
|
5444
|
+
return /* @__PURE__ */ jsx50(ScreenLoader, { loadingText: t("systems.common.status.loading") });
|
|
5630
5445
|
}
|
|
5631
5446
|
return children;
|
|
5632
5447
|
}
|
|
5633
5448
|
|
|
5634
5449
|
// src/ui/layouts/toolbar.tsx
|
|
5635
5450
|
import { Suspense } from "react";
|
|
5451
|
+
import { cn as cn40 } from "pelatform-ui";
|
|
5636
5452
|
import { ModeSwitcher } from "pelatform-ui/components";
|
|
5637
|
-
import { cn as cn41 } from "@pelatform/utils";
|
|
5638
5453
|
|
|
5639
5454
|
// src/ui/shared/language-switcher.tsx
|
|
5640
5455
|
import Image from "next/image";
|
|
5641
|
-
import { useRouter as
|
|
5642
|
-
import { useLocale as useLocale3, useTranslations as
|
|
5456
|
+
import { useRouter as useRouter14 } from "next/navigation";
|
|
5457
|
+
import { useLocale as useLocale3, useTranslations as useTranslations43 } from "next-intl";
|
|
5643
5458
|
import {
|
|
5644
5459
|
LanguageSwitcher as LanguageSwitcherBase
|
|
5645
5460
|
} from "pelatform-ui/components";
|
|
5646
|
-
import { jsx as
|
|
5461
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
5647
5462
|
function LanguageSwitcher({
|
|
5648
5463
|
className,
|
|
5649
5464
|
type,
|
|
@@ -5653,8 +5468,8 @@ function LanguageSwitcher({
|
|
|
5653
5468
|
showFlags
|
|
5654
5469
|
}) {
|
|
5655
5470
|
const { i18n } = useConfig();
|
|
5656
|
-
const router =
|
|
5657
|
-
const t =
|
|
5471
|
+
const router = useRouter14();
|
|
5472
|
+
const t = useTranslations43();
|
|
5658
5473
|
const currentLocale = useLocale3();
|
|
5659
5474
|
const availableLocales = (() => {
|
|
5660
5475
|
if (!i18n.enabled) {
|
|
@@ -5678,7 +5493,7 @@ function LanguageSwitcher({
|
|
|
5678
5493
|
document.cookie = `${i18n.localeCookieName}=${newLocale}; max-age=${60 * 60 * 24 * 365}; path=/`;
|
|
5679
5494
|
router.refresh();
|
|
5680
5495
|
}
|
|
5681
|
-
return /* @__PURE__ */
|
|
5496
|
+
return /* @__PURE__ */ jsx51(
|
|
5682
5497
|
LanguageSwitcherBase,
|
|
5683
5498
|
{
|
|
5684
5499
|
className,
|
|
@@ -5699,33 +5514,36 @@ function LanguageSwitcher({
|
|
|
5699
5514
|
}
|
|
5700
5515
|
|
|
5701
5516
|
// src/ui/layouts/toolbar.tsx
|
|
5702
|
-
import { jsx as
|
|
5517
|
+
import { jsx as jsx52, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
5703
5518
|
var DEFAULT_SHOW = ["darkmode"];
|
|
5704
5519
|
function Toolbar(props) {
|
|
5705
|
-
return /* @__PURE__ */
|
|
5520
|
+
return /* @__PURE__ */ jsx52(Suspense, { fallback: null, children: /* @__PURE__ */ jsx52("div", { className: cn40("fixed end-0 bottom-0 z-40 m-5", props.className), children: /* @__PURE__ */ jsx52(ToolbarRSC, { ...props }) }) });
|
|
5706
5521
|
}
|
|
5707
5522
|
function ToolbarRSC({ show = DEFAULT_SHOW }) {
|
|
5708
|
-
return /* @__PURE__ */
|
|
5709
|
-
show.includes("darkmode") && /* @__PURE__ */
|
|
5710
|
-
show.includes("help") && /* @__PURE__ */
|
|
5711
|
-
show.includes("language") && /* @__PURE__ */
|
|
5712
|
-
show.includes("onboarding") && /* @__PURE__ */
|
|
5523
|
+
return /* @__PURE__ */ jsx52("div", { className: "flex flex-col items-center gap-2.5", children: /* @__PURE__ */ jsxs43("div", { className: "shrink-0", children: [
|
|
5524
|
+
show.includes("darkmode") && /* @__PURE__ */ jsx52(ModeSwitcher, { variant: "outline", size: "lg", className: "size-10 rounded-full border" }),
|
|
5525
|
+
show.includes("help") && /* @__PURE__ */ jsx52("div", { className: "hidden" }),
|
|
5526
|
+
show.includes("language") && /* @__PURE__ */ jsx52(LanguageSwitcher, { variant: "outline", size: "lg", className: "size-10 rounded-full border" }),
|
|
5527
|
+
show.includes("onboarding") && /* @__PURE__ */ jsx52("div", { className: "hidden" })
|
|
5713
5528
|
] }) });
|
|
5714
5529
|
}
|
|
5715
5530
|
|
|
5716
5531
|
// src/ui/layouts/auth.tsx
|
|
5717
|
-
import { jsx as
|
|
5532
|
+
import { jsx as jsx53, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
5718
5533
|
function AuthLayout({
|
|
5719
5534
|
children,
|
|
5720
|
-
logo = /* @__PURE__ */
|
|
5535
|
+
logo = /* @__PURE__ */ jsx53(LogoWithName, {}),
|
|
5536
|
+
disableFooter = false,
|
|
5537
|
+
signInHint = false,
|
|
5538
|
+
signInHref
|
|
5721
5539
|
}) {
|
|
5722
5540
|
const { app, path } = useConfig();
|
|
5723
5541
|
const pathname = usePathname();
|
|
5724
|
-
const t =
|
|
5725
|
-
const footer = /* @__PURE__ */
|
|
5542
|
+
const t = useTranslations44();
|
|
5543
|
+
const footer = /* @__PURE__ */ jsxs44("p", { className: "px-20 py-4 text-center font-medium text-muted-foreground text-xs md:px-0", children: [
|
|
5726
5544
|
t("customs.common.agree"),
|
|
5727
5545
|
" ",
|
|
5728
|
-
/* @__PURE__ */
|
|
5546
|
+
/* @__PURE__ */ jsx53(
|
|
5729
5547
|
Link6,
|
|
5730
5548
|
{
|
|
5731
5549
|
href: path.main.TERMS,
|
|
@@ -5735,7 +5553,7 @@ function AuthLayout({
|
|
|
5735
5553
|
}
|
|
5736
5554
|
),
|
|
5737
5555
|
" ",
|
|
5738
|
-
/* @__PURE__ */
|
|
5556
|
+
/* @__PURE__ */ jsx53(
|
|
5739
5557
|
Link6,
|
|
5740
5558
|
{
|
|
5741
5559
|
href: path.main.PRIVACY,
|
|
@@ -5745,29 +5563,29 @@ function AuthLayout({
|
|
|
5745
5563
|
}
|
|
5746
5564
|
)
|
|
5747
5565
|
] });
|
|
5748
|
-
return /* @__PURE__ */
|
|
5749
|
-
/* @__PURE__ */
|
|
5750
|
-
/* @__PURE__ */
|
|
5566
|
+
return /* @__PURE__ */ jsxs44(LayoutLoader, { children: [
|
|
5567
|
+
/* @__PURE__ */ jsx53(Toolbar, { show: ["language"], className: "top-0!" }),
|
|
5568
|
+
/* @__PURE__ */ jsx53(
|
|
5751
5569
|
LayoutBlank,
|
|
5752
5570
|
{
|
|
5753
5571
|
className: "[&_.max-w-4xl]:max-w-sm [&_.max-w-4xl]:px-0",
|
|
5754
5572
|
logo,
|
|
5755
5573
|
logoHref: app.url,
|
|
5756
|
-
footer:
|
|
5574
|
+
footer: disableFooter || pathname === path.auth.SIGN_OUT || pathname === path.auth.CALLBACK ? null : footer,
|
|
5757
5575
|
children
|
|
5758
5576
|
}
|
|
5759
5577
|
),
|
|
5760
|
-
/* @__PURE__ */
|
|
5761
|
-
|
|
5578
|
+
/* @__PURE__ */ jsx53(Toolbar, { show: ["darkmode"] }),
|
|
5579
|
+
signInHint && /* @__PURE__ */ jsx53(SignedInHint, { linkHref: signInHref || path.auth.SIGN_OUT })
|
|
5762
5580
|
] });
|
|
5763
5581
|
}
|
|
5764
5582
|
|
|
5765
5583
|
// src/ui/layouts/header.tsx
|
|
5766
|
-
import { useEffect as
|
|
5584
|
+
import { useEffect as useEffect15, useState as useState18 } from "react";
|
|
5767
5585
|
import { usePathname as usePathname2 } from "next/navigation";
|
|
5768
5586
|
import { Menu, PanelRight } from "lucide-react";
|
|
5769
5587
|
import {
|
|
5770
|
-
Button as
|
|
5588
|
+
Button as Button32,
|
|
5771
5589
|
Sheet,
|
|
5772
5590
|
SheetBody,
|
|
5773
5591
|
SheetContent,
|
|
@@ -5778,11 +5596,11 @@ import {
|
|
|
5778
5596
|
} from "pelatform-ui/default";
|
|
5779
5597
|
|
|
5780
5598
|
// src/ui/shared/user-menu.tsx
|
|
5781
|
-
import { Fragment as Fragment17, useCallback as useCallback3, useEffect as
|
|
5599
|
+
import { Fragment as Fragment17, useCallback as useCallback3, useEffect as useEffect14, useState as useState17 } from "react";
|
|
5782
5600
|
import Link7 from "next/link";
|
|
5783
|
-
import { useRouter as
|
|
5601
|
+
import { useRouter as useRouter15 } from "next/navigation";
|
|
5784
5602
|
import { LogOut, PlusCircleIcon, Settings, Shield, UserStar } from "lucide-react";
|
|
5785
|
-
import { useTranslations as
|
|
5603
|
+
import { useTranslations as useTranslations45 } from "next-intl";
|
|
5786
5604
|
import { ModeSwitcher as ModeSwitcher2, UserAvatar as UserAvatar2 } from "pelatform-ui/components";
|
|
5787
5605
|
import {
|
|
5788
5606
|
Badge as Badge2,
|
|
@@ -5791,19 +5609,19 @@ import {
|
|
|
5791
5609
|
DropdownMenuItem as DropdownMenuItem3,
|
|
5792
5610
|
DropdownMenuSeparator,
|
|
5793
5611
|
DropdownMenuTrigger as DropdownMenuTrigger3,
|
|
5794
|
-
Skeleton as
|
|
5612
|
+
Skeleton as Skeleton9
|
|
5795
5613
|
} from "pelatform-ui/default";
|
|
5796
|
-
import { Fragment as Fragment18, jsx as
|
|
5614
|
+
import { Fragment as Fragment18, jsx as jsx54, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
5797
5615
|
function UserMenu({ hiddenSwitcher = false }) {
|
|
5798
5616
|
const { features, path } = useConfig();
|
|
5799
|
-
const router =
|
|
5800
|
-
const t =
|
|
5617
|
+
const router = useRouter15();
|
|
5618
|
+
const t = useTranslations45();
|
|
5801
5619
|
const { isPending: sessionPending, user } = useSession();
|
|
5802
5620
|
const { setActiveSessionAsync } = useSetActiveSession();
|
|
5803
5621
|
const { data: deviceSessions, isPending: deviceSessionsPending } = useListDeviceSessions({
|
|
5804
5622
|
enabled: features.multiSession
|
|
5805
5623
|
});
|
|
5806
|
-
const [activeSessionPending, setActiveSessionPending] =
|
|
5624
|
+
const [activeSessionPending, setActiveSessionPending] = useState17(false);
|
|
5807
5625
|
const isPending = sessionPending || activeSessionPending;
|
|
5808
5626
|
const switchAccount = useCallback3(
|
|
5809
5627
|
async (sessionToken) => {
|
|
@@ -5819,7 +5637,7 @@ function UserMenu({ hiddenSwitcher = false }) {
|
|
|
5819
5637
|
},
|
|
5820
5638
|
[router, setActiveSessionAsync]
|
|
5821
5639
|
);
|
|
5822
|
-
|
|
5640
|
+
useEffect14(() => {
|
|
5823
5641
|
if (!features.multiSession) return;
|
|
5824
5642
|
setActiveSessionPending(false);
|
|
5825
5643
|
}, [features.multiSession, user?.id]);
|
|
@@ -5830,33 +5648,33 @@ function UserMenu({ hiddenSwitcher = false }) {
|
|
|
5830
5648
|
const userName = getName(user);
|
|
5831
5649
|
const userAvatar = user?.image || void 0;
|
|
5832
5650
|
const userRole = user?.role || "user";
|
|
5833
|
-
return /* @__PURE__ */
|
|
5834
|
-
/* @__PURE__ */
|
|
5835
|
-
/* @__PURE__ */
|
|
5836
|
-
/* @__PURE__ */
|
|
5837
|
-
/* @__PURE__ */
|
|
5838
|
-
/* @__PURE__ */
|
|
5839
|
-
/* @__PURE__ */
|
|
5840
|
-
/* @__PURE__ */
|
|
5841
|
-
/* @__PURE__ */
|
|
5651
|
+
return /* @__PURE__ */ jsxs45(DropdownMenu3, { children: [
|
|
5652
|
+
/* @__PURE__ */ jsx54(DropdownMenuTrigger3, { className: "focus:outline-none focus:ring-0", children: isPending ? /* @__PURE__ */ jsx54(Skeleton9, { className: "size-8 shrink-0 rounded-full" }) : /* @__PURE__ */ jsx54(UserAvatar2, { className: "size-8", indicator: true, src: userAvatar, alt: userName }) }),
|
|
5653
|
+
/* @__PURE__ */ jsxs45(DropdownMenuContent3, { className: "w-56", side: "bottom", align: "end", sideOffset: 11, children: [
|
|
5654
|
+
/* @__PURE__ */ jsxs45("div", { className: "flex items-center gap-3 px-3 py-2", children: [
|
|
5655
|
+
/* @__PURE__ */ jsx54(UserAvatar2, { src: userAvatar, alt: userName }),
|
|
5656
|
+
/* @__PURE__ */ jsxs45("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: [
|
|
5657
|
+
/* @__PURE__ */ jsx54("span", { className: "truncate font-semibold text-foreground text-sm", children: userName }),
|
|
5658
|
+
/* @__PURE__ */ jsx54("span", { className: "block w-full truncate text-muted-foreground text-xs", children: userEmail }),
|
|
5659
|
+
/* @__PURE__ */ jsx54(Badge2, { variant: "success", appearance: "outline", size: "sm", className: "mt-1", children: userRole.toUpperCase() })
|
|
5842
5660
|
] })
|
|
5843
5661
|
] }),
|
|
5844
|
-
/* @__PURE__ */
|
|
5845
|
-
/* @__PURE__ */
|
|
5846
|
-
/* @__PURE__ */
|
|
5847
|
-
/* @__PURE__ */
|
|
5662
|
+
/* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
|
|
5663
|
+
/* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.account.SETTINGS, children: [
|
|
5664
|
+
/* @__PURE__ */ jsx54(Settings, {}),
|
|
5665
|
+
/* @__PURE__ */ jsx54("span", { children: t("systems.navigation.preferences") })
|
|
5848
5666
|
] }) }),
|
|
5849
|
-
/* @__PURE__ */
|
|
5850
|
-
/* @__PURE__ */
|
|
5851
|
-
/* @__PURE__ */
|
|
5667
|
+
/* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.account.SECURITY, children: [
|
|
5668
|
+
/* @__PURE__ */ jsx54(Shield, {}),
|
|
5669
|
+
/* @__PURE__ */ jsx54("span", { children: t("systems.navigation.security") })
|
|
5852
5670
|
] }) }),
|
|
5853
|
-
"admin" === userRole && /* @__PURE__ */
|
|
5854
|
-
/* @__PURE__ */
|
|
5855
|
-
/* @__PURE__ */
|
|
5671
|
+
"admin" === userRole && /* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.admin.OVERVIEW, children: [
|
|
5672
|
+
/* @__PURE__ */ jsx54(UserStar, {}),
|
|
5673
|
+
/* @__PURE__ */ jsx54("span", { children: "Admin Dashboard" })
|
|
5856
5674
|
] }) }),
|
|
5857
|
-
!hiddenSwitcher && /* @__PURE__ */
|
|
5858
|
-
/* @__PURE__ */
|
|
5859
|
-
/* @__PURE__ */
|
|
5675
|
+
!hiddenSwitcher && /* @__PURE__ */ jsxs45(Fragment18, { children: [
|
|
5676
|
+
/* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
|
|
5677
|
+
/* @__PURE__ */ jsx54(
|
|
5860
5678
|
ModeSwitcher2,
|
|
5861
5679
|
{
|
|
5862
5680
|
type: "sub-dropdown",
|
|
@@ -5867,31 +5685,31 @@ function UserMenu({ hiddenSwitcher = false }) {
|
|
|
5867
5685
|
}
|
|
5868
5686
|
}
|
|
5869
5687
|
),
|
|
5870
|
-
/* @__PURE__ */
|
|
5688
|
+
/* @__PURE__ */ jsx54(LanguageSwitcher, { type: "sub-dropdown" })
|
|
5871
5689
|
] }),
|
|
5872
|
-
/* @__PURE__ */
|
|
5873
|
-
/* @__PURE__ */
|
|
5874
|
-
/* @__PURE__ */
|
|
5875
|
-
/* @__PURE__ */
|
|
5690
|
+
/* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
|
|
5691
|
+
/* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.auth.SIGN_OUT, children: [
|
|
5692
|
+
/* @__PURE__ */ jsx54(LogOut, {}),
|
|
5693
|
+
/* @__PURE__ */ jsx54("span", { children: t("systems.navigation.logout") })
|
|
5876
5694
|
] }) }),
|
|
5877
|
-
user && features.multiSession && /* @__PURE__ */
|
|
5878
|
-
/* @__PURE__ */
|
|
5879
|
-
!deviceSessions && deviceSessionsPending && /* @__PURE__ */
|
|
5880
|
-
/* @__PURE__ */
|
|
5881
|
-
/* @__PURE__ */
|
|
5695
|
+
user && features.multiSession && /* @__PURE__ */ jsxs45(Fragment18, { children: [
|
|
5696
|
+
/* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
|
|
5697
|
+
!deviceSessions && deviceSessionsPending && /* @__PURE__ */ jsxs45(Fragment18, { children: [
|
|
5698
|
+
/* @__PURE__ */ jsx54(DropdownMenuItem3, { disabled: true, children: /* @__PURE__ */ jsx54(UserView, { isPending: true }) }),
|
|
5699
|
+
/* @__PURE__ */ jsx54(DropdownMenuSeparator, {})
|
|
5882
5700
|
] }),
|
|
5883
|
-
deviceSessions?.filter((sessionData) => sessionData.user.id !== user?.id).map(({ session, user: multiUser }) => /* @__PURE__ */
|
|
5884
|
-
/* @__PURE__ */
|
|
5885
|
-
/* @__PURE__ */
|
|
5886
|
-
/* @__PURE__ */
|
|
5887
|
-
/* @__PURE__ */
|
|
5888
|
-
/* @__PURE__ */
|
|
5701
|
+
deviceSessions?.filter((sessionData) => sessionData.user.id !== user?.id).map(({ session, user: multiUser }) => /* @__PURE__ */ jsxs45(Fragment17, { children: [
|
|
5702
|
+
/* @__PURE__ */ jsxs45(DropdownMenuItem3, { onClick: () => switchAccount(session.token), children: [
|
|
5703
|
+
/* @__PURE__ */ jsx54(UserAvatar2, { src: multiUser?.image || void 0, alt: getName(multiUser) }),
|
|
5704
|
+
/* @__PURE__ */ jsxs45("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: [
|
|
5705
|
+
/* @__PURE__ */ jsx54("span", { className: "truncate font-semibold text-foreground text-xs", children: getName(multiUser) }),
|
|
5706
|
+
/* @__PURE__ */ jsx54("span", { className: "block w-full truncate text-muted-foreground text-xs", children: multiUser?.email })
|
|
5889
5707
|
] })
|
|
5890
5708
|
] }),
|
|
5891
|
-
/* @__PURE__ */
|
|
5709
|
+
/* @__PURE__ */ jsx54(DropdownMenuSeparator, {})
|
|
5892
5710
|
] }, session.id)),
|
|
5893
|
-
/* @__PURE__ */
|
|
5894
|
-
/* @__PURE__ */
|
|
5711
|
+
/* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.auth.SIGN_IN, children: [
|
|
5712
|
+
/* @__PURE__ */ jsx54(PlusCircleIcon, {}),
|
|
5895
5713
|
t("systems.ADD_ACCOUNT")
|
|
5896
5714
|
] }) })
|
|
5897
5715
|
] })
|
|
@@ -5900,48 +5718,48 @@ function UserMenu({ hiddenSwitcher = false }) {
|
|
|
5900
5718
|
}
|
|
5901
5719
|
|
|
5902
5720
|
// src/ui/layouts/header.tsx
|
|
5903
|
-
import { jsx as
|
|
5721
|
+
import { jsx as jsx55, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
5904
5722
|
function Header({ children }) {
|
|
5905
|
-
return /* @__PURE__ */
|
|
5723
|
+
return /* @__PURE__ */ jsx55("header", { className: "fixed start-0 end-0 top-0 z-10 flex h-(--header-height-mobile) shrink-0 items-stretch border-border border-b bg-background/95 pe-(--removed-body-scroll-bar-size,0px) backdrop-blur-sm supports-backdrop-filter:bg-background/60 lg:h-(--header-height)", children: /* @__PURE__ */ jsx55("div", { className: "@container flex grow items-stretch justify-between gap-2.5 pe-5", children }) });
|
|
5906
5724
|
}
|
|
5907
5725
|
function HeaderLeft() {
|
|
5908
5726
|
const { logoHeader, sidebarToggle } = useLayout();
|
|
5909
|
-
return /* @__PURE__ */
|
|
5727
|
+
return /* @__PURE__ */ jsx55("div", { className: "flex items-center gap-2 px-5 lg:w-(--sidebar-width)", children: /* @__PURE__ */ jsxs46("div", { className: "flex w-full items-center justify-between", children: [
|
|
5910
5728
|
logoHeader,
|
|
5911
|
-
/* @__PURE__ */
|
|
5912
|
-
|
|
5729
|
+
/* @__PURE__ */ jsx55(
|
|
5730
|
+
Button32,
|
|
5913
5731
|
{
|
|
5914
5732
|
mode: "icon",
|
|
5915
5733
|
variant: "ghost",
|
|
5916
5734
|
onClick: sidebarToggle,
|
|
5917
5735
|
className: "hidden text-muted-foreground hover:text-foreground lg:inline-flex",
|
|
5918
|
-
children: /* @__PURE__ */
|
|
5736
|
+
children: /* @__PURE__ */ jsx55(PanelRight, { className: "-rotate-180 in-data-[sidebar-open=false]:rotate-0 opacity-100" })
|
|
5919
5737
|
}
|
|
5920
5738
|
)
|
|
5921
5739
|
] }) });
|
|
5922
5740
|
}
|
|
5923
5741
|
function HeaderRight({ sidebar, button }) {
|
|
5924
5742
|
const { isMobile } = useLayout();
|
|
5925
|
-
return /* @__PURE__ */
|
|
5743
|
+
return /* @__PURE__ */ jsxs46("nav", { className: "flex items-center gap-1.5 lg:gap-2.5", children: [
|
|
5926
5744
|
button,
|
|
5927
5745
|
isMobile && sidebar,
|
|
5928
|
-
/* @__PURE__ */
|
|
5746
|
+
/* @__PURE__ */ jsx55(UserMenu, {})
|
|
5929
5747
|
] });
|
|
5930
5748
|
}
|
|
5931
5749
|
function HeaderSidebarMobile({ children }) {
|
|
5932
5750
|
const pathname = usePathname2();
|
|
5933
|
-
const [isSheetOpen, setIsSheetOpen] =
|
|
5934
|
-
|
|
5751
|
+
const [isSheetOpen, setIsSheetOpen] = useState18(false);
|
|
5752
|
+
useEffect15(() => {
|
|
5935
5753
|
setIsSheetOpen(false);
|
|
5936
5754
|
}, [pathname]);
|
|
5937
|
-
return /* @__PURE__ */
|
|
5938
|
-
/* @__PURE__ */
|
|
5939
|
-
/* @__PURE__ */
|
|
5940
|
-
/* @__PURE__ */
|
|
5941
|
-
/* @__PURE__ */
|
|
5942
|
-
/* @__PURE__ */
|
|
5755
|
+
return /* @__PURE__ */ jsxs46(Sheet, { open: isSheetOpen, onOpenChange: setIsSheetOpen, children: [
|
|
5756
|
+
/* @__PURE__ */ jsx55(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsx55(Button32, { variant: "ghost", mode: "icon", size: "icon", children: /* @__PURE__ */ jsx55(Menu, { className: "size-4" }) }) }),
|
|
5757
|
+
/* @__PURE__ */ jsxs46(SheetContent, { className: "w-(--sidebar-width) gap-0 p-0", side: "left", close: false, children: [
|
|
5758
|
+
/* @__PURE__ */ jsxs46(SheetHeader, { className: "hidden space-y-0 p-0", children: [
|
|
5759
|
+
/* @__PURE__ */ jsx55(SheetTitle, { className: "sr-only", children: "Navigation menu" }),
|
|
5760
|
+
/* @__PURE__ */ jsx55(SheetDescription, { className: "sr-only", children: "NavigatSheet Description" })
|
|
5943
5761
|
] }),
|
|
5944
|
-
/* @__PURE__ */
|
|
5762
|
+
/* @__PURE__ */ jsx55(SheetBody, { className: "flex grow flex-col p-0", children })
|
|
5945
5763
|
] })
|
|
5946
5764
|
] });
|
|
5947
5765
|
}
|
|
@@ -5961,9 +5779,198 @@ import {
|
|
|
5961
5779
|
AccordionMenuSub,
|
|
5962
5780
|
AccordionMenuSubContent,
|
|
5963
5781
|
AccordionMenuSubTrigger,
|
|
5964
|
-
Badge as
|
|
5782
|
+
Badge as Badge4,
|
|
5965
5783
|
ScrollArea
|
|
5966
5784
|
} from "pelatform-ui/default";
|
|
5785
|
+
|
|
5786
|
+
// src/ui/workspace/switcher.tsx
|
|
5787
|
+
import { useRouter as useRouter16 } from "next/navigation";
|
|
5788
|
+
import { Building2, CheckIcon as CheckIcon4, ChevronsUpDown, PlusIcon, User } from "lucide-react";
|
|
5789
|
+
import { useTranslations as useTranslations46 } from "next-intl";
|
|
5790
|
+
import { AlertToast as AlertToast24 } from "pelatform-ui/components";
|
|
5791
|
+
import {
|
|
5792
|
+
Badge as Badge3,
|
|
5793
|
+
Button as Button33,
|
|
5794
|
+
DropdownMenu as DropdownMenu4,
|
|
5795
|
+
DropdownMenuContent as DropdownMenuContent4,
|
|
5796
|
+
DropdownMenuGroup,
|
|
5797
|
+
DropdownMenuItem as DropdownMenuItem4,
|
|
5798
|
+
DropdownMenuLabel,
|
|
5799
|
+
DropdownMenuSeparator as DropdownMenuSeparator2,
|
|
5800
|
+
DropdownMenuTrigger as DropdownMenuTrigger4,
|
|
5801
|
+
Skeleton as Skeleton10
|
|
5802
|
+
} from "pelatform-ui/default";
|
|
5803
|
+
import { useMediaQuery } from "pelatform-ui/hooks";
|
|
5804
|
+
import { jsx as jsx56, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
5805
|
+
function WorkspaceSwitcher() {
|
|
5806
|
+
const { path } = useConfig();
|
|
5807
|
+
const router = useRouter16();
|
|
5808
|
+
const t = useTranslations46();
|
|
5809
|
+
const { activeWorkspace, updateActiveWorkspace, workspaceList, isFetchingWorkspace } = useWorkspace();
|
|
5810
|
+
const ownedWorkspaces = workspaceList?.filter((workspace) => workspace.currentUserRole === "owner") || [];
|
|
5811
|
+
const sharedWorkspaces = workspaceList?.filter((workspace) => workspace.currentUserRole !== "owner") || [];
|
|
5812
|
+
async function switchWorkspace(org) {
|
|
5813
|
+
if (org.slug === activeWorkspace?.slug) {
|
|
5814
|
+
return;
|
|
5815
|
+
}
|
|
5816
|
+
try {
|
|
5817
|
+
await updateActiveWorkspace(org);
|
|
5818
|
+
} catch (error) {
|
|
5819
|
+
console.error("Failed to switch workspace:", error);
|
|
5820
|
+
AlertToast24({
|
|
5821
|
+
message: error instanceof Error ? error.message : "Failed to switch workspace",
|
|
5822
|
+
icon: "destructive"
|
|
5823
|
+
});
|
|
5824
|
+
}
|
|
5825
|
+
}
|
|
5826
|
+
const showSkeleton = !activeWorkspace && isFetchingWorkspace;
|
|
5827
|
+
const currentSlug = activeWorkspace?.slug;
|
|
5828
|
+
const currentName = activeWorkspace?.name ?? "Workspace";
|
|
5829
|
+
const plan = activeWorkspace?.subscription?.plan ?? "free";
|
|
5830
|
+
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
5831
|
+
return /* @__PURE__ */ jsx56("div", { className: "flex h-14 shrink-0 items-center gap-2 border-border border-b px-2.5 lg:h-15", children: /* @__PURE__ */ jsxs47(DropdownMenu4, { children: [
|
|
5832
|
+
activeWorkspace && !showSkeleton ? /* @__PURE__ */ jsx56(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs47(
|
|
5833
|
+
Button33,
|
|
5834
|
+
{
|
|
5835
|
+
variant: "ghost",
|
|
5836
|
+
className: "flex w-full items-center justify-between gap-2 px-1.5 hover:bg-accent focus:shadow-none! focus:outline-none! focus:ring-0! focus:ring-offset-0!",
|
|
5837
|
+
children: [
|
|
5838
|
+
/* @__PURE__ */ jsxs47("div", { className: "flex items-center gap-2.5", children: [
|
|
5839
|
+
/* @__PURE__ */ jsx56(
|
|
5840
|
+
WorkspaceLogo,
|
|
5841
|
+
{
|
|
5842
|
+
workspace: activeWorkspace,
|
|
5843
|
+
classNames: { image: "w-full h-full" }
|
|
5844
|
+
}
|
|
5845
|
+
),
|
|
5846
|
+
/* @__PURE__ */ jsx56("span", { className: "font-medium text-foreground text-sm", children: currentName })
|
|
5847
|
+
] }),
|
|
5848
|
+
/* @__PURE__ */ jsx56(ChevronsUpDown, {})
|
|
5849
|
+
]
|
|
5850
|
+
}
|
|
5851
|
+
) }) : /* @__PURE__ */ jsxs47("div", { className: "flex items-center rounded-md border bg-sidebar-accent", children: [
|
|
5852
|
+
/* @__PURE__ */ jsx56(Skeleton10, { className: "shrink-0 rounded-md border" }),
|
|
5853
|
+
/* @__PURE__ */ jsxs47("div", { className: "flex w-full flex-col gap-1", children: [
|
|
5854
|
+
/* @__PURE__ */ jsx56(Skeleton10, { className: "h-3 w-3/4 border" }),
|
|
5855
|
+
/* @__PURE__ */ jsx56(Skeleton10, { className: "h-3 w-1/2 border" })
|
|
5856
|
+
] })
|
|
5857
|
+
] }),
|
|
5858
|
+
/* @__PURE__ */ jsxs47(
|
|
5859
|
+
DropdownMenuContent4,
|
|
5860
|
+
{
|
|
5861
|
+
className: "w-64",
|
|
5862
|
+
side: isMobile ? "bottom" : "right",
|
|
5863
|
+
align: isMobile ? "end" : "start",
|
|
5864
|
+
sideOffset: isMobile ? 8 : 7,
|
|
5865
|
+
alignOffset: isMobile ? 65 : 0,
|
|
5866
|
+
children: [
|
|
5867
|
+
/* @__PURE__ */ jsxs47(DropdownMenuLabel, { className: "flex items-center gap-1.5", children: [
|
|
5868
|
+
/* @__PURE__ */ jsx56(
|
|
5869
|
+
WorkspaceLogo,
|
|
5870
|
+
{
|
|
5871
|
+
workspace: activeWorkspace,
|
|
5872
|
+
classNames: { image: "w-full h-full" }
|
|
5873
|
+
}
|
|
5874
|
+
),
|
|
5875
|
+
/* @__PURE__ */ jsx56("span", { className: "font-medium text-foreground text-sm", children: currentName }),
|
|
5876
|
+
/* @__PURE__ */ jsx56(Badge3, { size: "xs", className: "capitalize", variant: plan === "free" ? "info" : "success", children: plan })
|
|
5877
|
+
] }),
|
|
5878
|
+
/* @__PURE__ */ jsxs47(
|
|
5879
|
+
DropdownMenuItem4,
|
|
5880
|
+
{
|
|
5881
|
+
className: "cursor-pointer",
|
|
5882
|
+
disabled: !currentSlug,
|
|
5883
|
+
onSelect: () => router.push(`/${currentSlug}${path.workspaces.SETTINGS}`),
|
|
5884
|
+
children: [
|
|
5885
|
+
/* @__PURE__ */ jsx56(Building2, { className: "size-4" }),
|
|
5886
|
+
/* @__PURE__ */ jsx56("span", { children: t("systems.SETTINGS") })
|
|
5887
|
+
]
|
|
5888
|
+
}
|
|
5889
|
+
),
|
|
5890
|
+
/* @__PURE__ */ jsxs47(
|
|
5891
|
+
DropdownMenuItem4,
|
|
5892
|
+
{
|
|
5893
|
+
className: "cursor-pointer",
|
|
5894
|
+
disabled: !currentSlug,
|
|
5895
|
+
onSelect: () => router.push(`/${currentSlug}${path.workspaces.MEMBERS}`),
|
|
5896
|
+
children: [
|
|
5897
|
+
/* @__PURE__ */ jsx56(User, { className: "size-4" }),
|
|
5898
|
+
/* @__PURE__ */ jsx56("span", { children: t("systems.INVITE_MEMBER") })
|
|
5899
|
+
]
|
|
5900
|
+
}
|
|
5901
|
+
),
|
|
5902
|
+
ownedWorkspaces.length > 0 && /* @__PURE__ */ jsxs47(DropdownMenuGroup, { children: [
|
|
5903
|
+
/* @__PURE__ */ jsx56(DropdownMenuSeparator2, {}),
|
|
5904
|
+
/* @__PURE__ */ jsx56(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: t("systems.YOUR_WORKSPACES") }),
|
|
5905
|
+
ownedWorkspaces.map((w) => /* @__PURE__ */ jsxs47(
|
|
5906
|
+
DropdownMenuItem4,
|
|
5907
|
+
{
|
|
5908
|
+
className: "flex items-center justify-between",
|
|
5909
|
+
onClick: () => switchWorkspace(w),
|
|
5910
|
+
disabled: isFetchingWorkspace || w.slug !== currentSlug,
|
|
5911
|
+
children: [
|
|
5912
|
+
/* @__PURE__ */ jsxs47("div", { className: "flex items-center gap-2", children: [
|
|
5913
|
+
/* @__PURE__ */ jsx56(
|
|
5914
|
+
WorkspaceLogo,
|
|
5915
|
+
{
|
|
5916
|
+
workspace: w,
|
|
5917
|
+
classNames: { base: "size-7 rounded-[0.2rem]", image: "w-full h-full" }
|
|
5918
|
+
}
|
|
5919
|
+
),
|
|
5920
|
+
/* @__PURE__ */ jsx56("span", { className: "truncate font-medium text-foreground text-sm leading-5 sm:max-w-[140px]", children: w.name ?? w.slug })
|
|
5921
|
+
] }),
|
|
5922
|
+
w.slug === currentSlug && /* @__PURE__ */ jsx56(CheckIcon4, { className: "size-4 text-primary" })
|
|
5923
|
+
]
|
|
5924
|
+
},
|
|
5925
|
+
w.id
|
|
5926
|
+
))
|
|
5927
|
+
] }),
|
|
5928
|
+
sharedWorkspaces.length > 0 && /* @__PURE__ */ jsxs47(DropdownMenuGroup, { children: [
|
|
5929
|
+
ownedWorkspaces.length > 0 && /* @__PURE__ */ jsx56(DropdownMenuSeparator2, {}),
|
|
5930
|
+
/* @__PURE__ */ jsx56(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: t("systems.SHARED_WORKSPACES") }),
|
|
5931
|
+
sharedWorkspaces.map((w) => /* @__PURE__ */ jsxs47(
|
|
5932
|
+
DropdownMenuItem4,
|
|
5933
|
+
{
|
|
5934
|
+
className: "flex items-center justify-between",
|
|
5935
|
+
onClick: () => switchWorkspace(w),
|
|
5936
|
+
disabled: isFetchingWorkspace || w.slug !== currentSlug,
|
|
5937
|
+
children: [
|
|
5938
|
+
/* @__PURE__ */ jsxs47("div", { className: "flex items-center gap-2", children: [
|
|
5939
|
+
/* @__PURE__ */ jsx56(
|
|
5940
|
+
WorkspaceLogo,
|
|
5941
|
+
{
|
|
5942
|
+
workspace: w,
|
|
5943
|
+
classNames: { base: "size-7 rounded-[0.2rem]", image: "w-full h-full" }
|
|
5944
|
+
}
|
|
5945
|
+
),
|
|
5946
|
+
/* @__PURE__ */ jsx56("span", { className: "truncate font-medium text-foreground text-sm leading-5 sm:max-w-[140px]", children: w.name ?? w.slug })
|
|
5947
|
+
] }),
|
|
5948
|
+
w.slug === currentSlug && /* @__PURE__ */ jsx56(CheckIcon4, { className: "size-4 text-primary" })
|
|
5949
|
+
]
|
|
5950
|
+
},
|
|
5951
|
+
w.id
|
|
5952
|
+
))
|
|
5953
|
+
] }),
|
|
5954
|
+
/* @__PURE__ */ jsx56(DropdownMenuSeparator2, {}),
|
|
5955
|
+
/* @__PURE__ */ jsxs47(
|
|
5956
|
+
DropdownMenuItem4,
|
|
5957
|
+
{
|
|
5958
|
+
onSelect: () => router.push(
|
|
5959
|
+
`${path.custom.NEW_WORKSPACE}?workspaces=${workspaceList && workspaceList.length > 0}`
|
|
5960
|
+
),
|
|
5961
|
+
children: [
|
|
5962
|
+
/* @__PURE__ */ jsx56(PlusIcon, { className: "size-4" }),
|
|
5963
|
+
/* @__PURE__ */ jsx56("span", { children: t("systems.ADD_WORKSPACE") })
|
|
5964
|
+
]
|
|
5965
|
+
}
|
|
5966
|
+
)
|
|
5967
|
+
]
|
|
5968
|
+
}
|
|
5969
|
+
)
|
|
5970
|
+
] }) });
|
|
5971
|
+
}
|
|
5972
|
+
|
|
5973
|
+
// src/ui/layouts/sidebar.tsx
|
|
5967
5974
|
import { Fragment as Fragment19, jsx as jsx57, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
5968
5975
|
function Sidebar({ children }) {
|
|
5969
5976
|
const { isMobile } = useLayout();
|
|
@@ -5982,6 +5989,9 @@ function SidebarHeaderBack({
|
|
|
5982
5989
|
const t = useTranslations47();
|
|
5983
5990
|
return /* @__PURE__ */ jsx57("div", { className: "flex h-14 shrink-0 items-center gap-2 border-border border-b px-2.5 lg:h-15", children: /* @__PURE__ */ jsx57(BackLink, { Link: Link8, href: linkHref, children: admin ? t("systems.common.actions.back") : t("systems.navigation.settings") }) });
|
|
5984
5991
|
}
|
|
5992
|
+
function SidebarHeaderWorkspaces() {
|
|
5993
|
+
return /* @__PURE__ */ jsx57(WorkspaceSwitcher, {});
|
|
5994
|
+
}
|
|
5985
5995
|
function SidebarContent({ children }) {
|
|
5986
5996
|
return /* @__PURE__ */ jsx57(ScrollArea, { className: "mt-2 mb-2.5 h-[calc(100vh-5.5rem)] grow lg:mt-4 lg:mb-7.5 lg:h-[calc(100vh-4rem)]", children });
|
|
5987
5997
|
}
|
|
@@ -6049,7 +6059,7 @@ function SidebarContentMenu({
|
|
|
6049
6059
|
child.icon && /* @__PURE__ */ jsx57(child.icon, {}),
|
|
6050
6060
|
/* @__PURE__ */ jsx57("span", { children: child.title }),
|
|
6051
6061
|
child.badge && /* @__PURE__ */ jsx57(
|
|
6052
|
-
|
|
6062
|
+
Badge4,
|
|
6053
6063
|
{
|
|
6054
6064
|
size: "sm",
|
|
6055
6065
|
variant: child.badgeVariant ?? "destructive",
|
|
@@ -6097,7 +6107,7 @@ function SidebarContentMenu({
|
|
|
6097
6107
|
child.icon && /* @__PURE__ */ jsx57(child.icon, {}),
|
|
6098
6108
|
/* @__PURE__ */ jsx57("span", { children: child.title }),
|
|
6099
6109
|
child.badge && /* @__PURE__ */ jsx57(
|
|
6100
|
-
|
|
6110
|
+
Badge4,
|
|
6101
6111
|
{
|
|
6102
6112
|
size: "sm",
|
|
6103
6113
|
variant: child.badgeVariant ?? "destructive",
|
|
@@ -6130,14 +6140,14 @@ function SidebarContentMenu({
|
|
|
6130
6140
|
// src/ui/layouts/site-footer.tsx
|
|
6131
6141
|
import Link9 from "next/link";
|
|
6132
6142
|
import { useTranslations as useTranslations48 } from "next-intl";
|
|
6143
|
+
import { cn as cn41 } from "pelatform-ui";
|
|
6133
6144
|
import { SiteFooter as UISiteFooter } from "pelatform-ui/components";
|
|
6134
6145
|
import { Button as Button34 } from "pelatform-ui/default";
|
|
6135
|
-
import { cn as cn42 } from "@pelatform/utils";
|
|
6136
6146
|
import { jsx as jsx58, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
6137
6147
|
function SiteFooter({ disableProjectBy = false }) {
|
|
6138
6148
|
const { app } = useConfig();
|
|
6139
6149
|
const t = useTranslations48();
|
|
6140
|
-
return /* @__PURE__ */ jsxs49(UISiteFooter, { className:
|
|
6150
|
+
return /* @__PURE__ */ jsxs49(UISiteFooter, { className: cn41("*:gap-2! *:py-0!", disableProjectBy ? "*:justify-center!" : ""), children: [
|
|
6141
6151
|
/* @__PURE__ */ jsxs49("div", { className: "text-balance text-center text-muted-foreground text-sm leading-loose md:text-left", children: [
|
|
6142
6152
|
"\xA9 ",
|
|
6143
6153
|
(/* @__PURE__ */ new Date()).getFullYear(),
|
|
@@ -6163,7 +6173,7 @@ function SiteFooter({ disableProjectBy = false }) {
|
|
|
6163
6173
|
}
|
|
6164
6174
|
|
|
6165
6175
|
// src/ui/layouts/site-header.tsx
|
|
6166
|
-
import { useState as
|
|
6176
|
+
import { useState as useState19 } from "react";
|
|
6167
6177
|
import Link10 from "next/link";
|
|
6168
6178
|
import { usePathname as usePathname4, useRouter as useRouter17 } from "next/navigation";
|
|
6169
6179
|
import { useTranslations as useTranslations49 } from "next-intl";
|
|
@@ -6185,7 +6195,7 @@ function SiteHeader({
|
|
|
6185
6195
|
const router = useRouter17();
|
|
6186
6196
|
const t = useTranslations49();
|
|
6187
6197
|
const { isPending, session, user } = useSession();
|
|
6188
|
-
const [, setMobileNavOpen] =
|
|
6198
|
+
const [, setMobileNavOpen] = useState19(false);
|
|
6189
6199
|
const isAuthenticated = !isPending && session && user;
|
|
6190
6200
|
return /* @__PURE__ */ jsxs50(UISiteHeader, { className: "backdrop-blur-none supports-backdrop-filter:bg-background", children: [
|
|
6191
6201
|
/* @__PURE__ */ jsxs50("div", { className: "flex items-center gap-4.5", children: [
|
|
@@ -6232,7 +6242,7 @@ function SiteHeaderSecondary({
|
|
|
6232
6242
|
}) {
|
|
6233
6243
|
const pathname = usePathname4();
|
|
6234
6244
|
const t = useTranslations49();
|
|
6235
|
-
const [, setMobileNavOpen] =
|
|
6245
|
+
const [, setMobileNavOpen] = useState19(false);
|
|
6236
6246
|
return /* @__PURE__ */ jsxs50(UISiteHeader, { className: "backdrop-blur-none supports-backdrop-filter:bg-background", children: [
|
|
6237
6247
|
/* @__PURE__ */ jsxs50("div", { className: "flex items-center gap-4.5", children: [
|
|
6238
6248
|
logo,
|
|
@@ -6264,9 +6274,9 @@ function SiteHeaderSecondary({
|
|
|
6264
6274
|
}
|
|
6265
6275
|
|
|
6266
6276
|
// src/ui/providers/layout.tsx
|
|
6267
|
-
import { useEffect as
|
|
6277
|
+
import { useEffect as useEffect16, useState as useState20 } from "react";
|
|
6278
|
+
import { cn as cn42 } from "pelatform-ui";
|
|
6268
6279
|
import { useIsMobile } from "pelatform-ui/hooks";
|
|
6269
|
-
import { cn as cn43 } from "@pelatform/utils";
|
|
6270
6280
|
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
6271
6281
|
var SIDEBAR_WIDTH = "240px";
|
|
6272
6282
|
var HEADER_HEIGHT = "54px";
|
|
@@ -6280,7 +6290,7 @@ function LayoutProvider({
|
|
|
6280
6290
|
logoHeader = /* @__PURE__ */ jsx60(LogoWithHref, {})
|
|
6281
6291
|
}) {
|
|
6282
6292
|
const isMobile = useIsMobile();
|
|
6283
|
-
const [isSidebarOpen, setIsSidebarOpen] =
|
|
6293
|
+
const [isSidebarOpen, setIsSidebarOpen] = useState20(true);
|
|
6284
6294
|
const defaultStyle = {
|
|
6285
6295
|
"--sidebar-width": SIDEBAR_WIDTH,
|
|
6286
6296
|
"--header-height": HEADER_HEIGHT,
|
|
@@ -6292,7 +6302,7 @@ function LayoutProvider({
|
|
|
6292
6302
|
...customStyle
|
|
6293
6303
|
};
|
|
6294
6304
|
const sidebarToggle = () => setIsSidebarOpen((open) => !open);
|
|
6295
|
-
|
|
6305
|
+
useEffect16(() => {
|
|
6296
6306
|
if (bodyClassName) {
|
|
6297
6307
|
const body = document.body;
|
|
6298
6308
|
const existingClasses = body.className;
|
|
@@ -6317,7 +6327,7 @@ function LayoutProvider({
|
|
|
6317
6327
|
"div",
|
|
6318
6328
|
{
|
|
6319
6329
|
"data-slot": "layout-wrapper",
|
|
6320
|
-
className:
|
|
6330
|
+
className: cn42("flex grow", className),
|
|
6321
6331
|
"data-sidebar-open": isSidebarOpen,
|
|
6322
6332
|
style,
|
|
6323
6333
|
children
|
|
@@ -6351,13 +6361,599 @@ function LayoutWrapper({
|
|
|
6351
6361
|
] });
|
|
6352
6362
|
}
|
|
6353
6363
|
|
|
6364
|
+
// src/ui/pages/accept-invitation.tsx
|
|
6365
|
+
import { useEffect as useEffect17, useState as useState21 } from "react";
|
|
6366
|
+
import { useRouter as useRouter18, useSearchParams as useSearchParams6 } from "next/navigation";
|
|
6367
|
+
import { CheckIcon as CheckIcon5, XIcon } from "lucide-react";
|
|
6368
|
+
import { useTranslations as useTranslations50 } from "next-intl";
|
|
6369
|
+
import { cn as cn43 } from "pelatform-ui";
|
|
6370
|
+
import { AlertToast as AlertToast25 } from "pelatform-ui/components";
|
|
6371
|
+
import { Button as Button36, Card as Card11, CardContent as CardContent3, CardHeader as CardHeader2, Skeleton as Skeleton11, Spinner as Spinner20 } from "pelatform-ui/default";
|
|
6372
|
+
import { jsx as jsx62, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
6373
|
+
function AcceptInvitation({
|
|
6374
|
+
className,
|
|
6375
|
+
classNames,
|
|
6376
|
+
redirectTo = "/"
|
|
6377
|
+
}) {
|
|
6378
|
+
const router = useRouter18();
|
|
6379
|
+
const searchParams = useSearchParams6();
|
|
6380
|
+
const t = useTranslations50();
|
|
6381
|
+
const { data: sessionData } = useSession();
|
|
6382
|
+
const [invitationId, setInvitationId] = useState21(null);
|
|
6383
|
+
useEffect17(() => {
|
|
6384
|
+
const invitationIdParam = searchParams.get("id");
|
|
6385
|
+
if (!invitationIdParam) {
|
|
6386
|
+
AlertToast25({
|
|
6387
|
+
message: t("systems.INVITATION_NOT_FOUND"),
|
|
6388
|
+
icon: "destructive"
|
|
6389
|
+
});
|
|
6390
|
+
router.replace(redirectTo);
|
|
6391
|
+
return;
|
|
6392
|
+
}
|
|
6393
|
+
setInvitationId(invitationIdParam);
|
|
6394
|
+
}, [router, redirectTo, searchParams.get, t]);
|
|
6395
|
+
if (!sessionData || !invitationId) {
|
|
6396
|
+
return /* @__PURE__ */ jsx62(AcceptInvitationSkeleton, { className, classNames });
|
|
6397
|
+
}
|
|
6398
|
+
return /* @__PURE__ */ jsx62(
|
|
6399
|
+
AcceptInvitationContent,
|
|
6400
|
+
{
|
|
6401
|
+
className,
|
|
6402
|
+
classNames,
|
|
6403
|
+
invitationId,
|
|
6404
|
+
redirectTo
|
|
6405
|
+
}
|
|
6406
|
+
);
|
|
6407
|
+
}
|
|
6408
|
+
function AcceptInvitationContent({
|
|
6409
|
+
className,
|
|
6410
|
+
classNames,
|
|
6411
|
+
invitationId,
|
|
6412
|
+
redirectTo
|
|
6413
|
+
}) {
|
|
6414
|
+
const { authClient } = useConfig();
|
|
6415
|
+
const router = useRouter18();
|
|
6416
|
+
const t = useTranslations50();
|
|
6417
|
+
const { data: invitation, isPending } = useInvitation({
|
|
6418
|
+
query: {
|
|
6419
|
+
id: invitationId
|
|
6420
|
+
}
|
|
6421
|
+
});
|
|
6422
|
+
const [isRejecting, setIsRejecting] = useState21(false);
|
|
6423
|
+
const [isAccepting, setIsAccepting] = useState21(false);
|
|
6424
|
+
const isProcessing = isRejecting || isAccepting;
|
|
6425
|
+
useEffect17(() => {
|
|
6426
|
+
if (isPending || !invitationId) return;
|
|
6427
|
+
if (!invitation) {
|
|
6428
|
+
AlertToast25({
|
|
6429
|
+
message: t("systems.INVITATION_NOT_FOUND"),
|
|
6430
|
+
icon: "destructive"
|
|
6431
|
+
});
|
|
6432
|
+
router.replace(redirectTo);
|
|
6433
|
+
return;
|
|
6434
|
+
}
|
|
6435
|
+
if (invitation.status !== "pending" || new Date(invitation.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
6436
|
+
AlertToast25({
|
|
6437
|
+
message: new Date(invitation.expiresAt) < /* @__PURE__ */ new Date() ? t("systems.INVITATION_EXPIRED") : t("systems.INVITATION_NOT_FOUND"),
|
|
6438
|
+
icon: "destructive"
|
|
6439
|
+
});
|
|
6440
|
+
router.replace(redirectTo);
|
|
6441
|
+
}
|
|
6442
|
+
}, [invitation, isPending, invitationId, router, redirectTo, t]);
|
|
6443
|
+
const acceptInvitation = async () => {
|
|
6444
|
+
setIsAccepting(true);
|
|
6445
|
+
try {
|
|
6446
|
+
await authClient.organization.acceptInvitation({
|
|
6447
|
+
invitationId,
|
|
6448
|
+
fetchOptions: { throw: true }
|
|
6449
|
+
});
|
|
6450
|
+
AlertToast25({
|
|
6451
|
+
message: t("systems.INVITATION_ACCEPTED")
|
|
6452
|
+
});
|
|
6453
|
+
router.replace(redirectTo);
|
|
6454
|
+
} catch (error) {
|
|
6455
|
+
AlertToast25({
|
|
6456
|
+
message: getTranslations({ error, t }),
|
|
6457
|
+
icon: "destructive"
|
|
6458
|
+
});
|
|
6459
|
+
setIsAccepting(false);
|
|
6460
|
+
}
|
|
6461
|
+
};
|
|
6462
|
+
const rejectInvitation = async () => {
|
|
6463
|
+
setIsRejecting(true);
|
|
6464
|
+
try {
|
|
6465
|
+
await authClient.organization.rejectInvitation({
|
|
6466
|
+
invitationId,
|
|
6467
|
+
fetchOptions: { throw: true }
|
|
6468
|
+
});
|
|
6469
|
+
AlertToast25({
|
|
6470
|
+
message: t("systems.INVITATION_REJECTED")
|
|
6471
|
+
});
|
|
6472
|
+
router.replace(redirectTo);
|
|
6473
|
+
} catch (error) {
|
|
6474
|
+
AlertToast25({
|
|
6475
|
+
message: getTranslations({ error, t }),
|
|
6476
|
+
icon: "destructive"
|
|
6477
|
+
});
|
|
6478
|
+
setIsRejecting(false);
|
|
6479
|
+
}
|
|
6480
|
+
};
|
|
6481
|
+
if (!invitation) {
|
|
6482
|
+
return /* @__PURE__ */ jsx62(AcceptInvitationSkeleton, { className, classNames });
|
|
6483
|
+
}
|
|
6484
|
+
return /* @__PURE__ */ jsxs52(Card11, { className: cn43("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
|
|
6485
|
+
/* @__PURE__ */ jsx62(CardHeader2, { className: "py-4", children: /* @__PURE__ */ jsx62(
|
|
6486
|
+
CardHeaderComponent,
|
|
6487
|
+
{
|
|
6488
|
+
title: t("systems.ACCEPT_INVITATION"),
|
|
6489
|
+
description: t("systems.ACCEPT_INVITATION_DESCRIPTION")
|
|
6490
|
+
}
|
|
6491
|
+
) }),
|
|
6492
|
+
/* @__PURE__ */ jsxs52(CardContent3, { className: cn43("flex flex-col gap-6 truncate", classNames?.content), children: [
|
|
6493
|
+
/* @__PURE__ */ jsxs52(Card11, { className: cn43("flex-row items-center p-4"), children: [
|
|
6494
|
+
/* @__PURE__ */ jsx62(
|
|
6495
|
+
WorkspaceView,
|
|
6496
|
+
{
|
|
6497
|
+
workspace: {
|
|
6498
|
+
id: invitation.organizationId,
|
|
6499
|
+
name: invitation.organizationName,
|
|
6500
|
+
slug: invitation.organizationSlug,
|
|
6501
|
+
// logo: invitation.organizationLogo,
|
|
6502
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
),
|
|
6506
|
+
/* @__PURE__ */ jsx62("p", { className: "ms-auto font-semibold text-muted-foreground text-sm", children: t(`systems.${invitation?.role.toUpperCase()}`) || invitation?.role })
|
|
6507
|
+
] }),
|
|
6508
|
+
/* @__PURE__ */ jsxs52("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
6509
|
+
/* @__PURE__ */ jsxs52(
|
|
6510
|
+
Button36,
|
|
6511
|
+
{
|
|
6512
|
+
variant: "destructive",
|
|
6513
|
+
className: cn43(classNames?.button, classNames?.destructiveButton),
|
|
6514
|
+
onClick: rejectInvitation,
|
|
6515
|
+
disabled: isProcessing,
|
|
6516
|
+
children: [
|
|
6517
|
+
isRejecting ? /* @__PURE__ */ jsx62(Spinner20, {}) : /* @__PURE__ */ jsx62(XIcon, {}),
|
|
6518
|
+
t("systems.REJECT")
|
|
6519
|
+
]
|
|
6520
|
+
}
|
|
6521
|
+
),
|
|
6522
|
+
/* @__PURE__ */ jsxs52(
|
|
6523
|
+
Button36,
|
|
6524
|
+
{
|
|
6525
|
+
className: cn43(classNames?.button, classNames?.primaryButton),
|
|
6526
|
+
onClick: acceptInvitation,
|
|
6527
|
+
disabled: isProcessing,
|
|
6528
|
+
children: [
|
|
6529
|
+
isAccepting ? /* @__PURE__ */ jsx62(Spinner20, {}) : /* @__PURE__ */ jsx62(CheckIcon5, {}),
|
|
6530
|
+
t("systems.ACCEPT")
|
|
6531
|
+
]
|
|
6532
|
+
}
|
|
6533
|
+
)
|
|
6534
|
+
] })
|
|
6535
|
+
] })
|
|
6536
|
+
] });
|
|
6537
|
+
}
|
|
6538
|
+
function AcceptInvitationSkeleton({ className, classNames }) {
|
|
6539
|
+
const t = useTranslations50();
|
|
6540
|
+
return /* @__PURE__ */ jsxs52(Card11, { className: cn43("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
|
|
6541
|
+
/* @__PURE__ */ jsx62(CardHeader2, { className: "py-4", children: /* @__PURE__ */ jsx62(
|
|
6542
|
+
CardHeaderComponent,
|
|
6543
|
+
{
|
|
6544
|
+
className: "w-full",
|
|
6545
|
+
title: t("systems.ACCEPT_INVITATION"),
|
|
6546
|
+
description: t("systems.ACCEPT_INVITATION_DESCRIPTION"),
|
|
6547
|
+
isPending: true
|
|
6548
|
+
}
|
|
6549
|
+
) }),
|
|
6550
|
+
/* @__PURE__ */ jsxs52(CardContent3, { className: cn43("flex flex-col gap-6 truncate", classNames?.content), children: [
|
|
6551
|
+
/* @__PURE__ */ jsxs52(Card11, { className: cn43("flex-row items-center p-4"), children: [
|
|
6552
|
+
/* @__PURE__ */ jsx62(WorkspaceView, { isPending: true }),
|
|
6553
|
+
/* @__PURE__ */ jsx62(Skeleton11, { className: "ms-auto mt-0.5 h-4 w-full max-w-14 shrink-2" })
|
|
6554
|
+
] }),
|
|
6555
|
+
/* @__PURE__ */ jsxs52("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
6556
|
+
/* @__PURE__ */ jsx62(Skeleton11, { className: "h-9 w-full" }),
|
|
6557
|
+
/* @__PURE__ */ jsx62(Skeleton11, { className: "h-9 w-full" })
|
|
6558
|
+
] })
|
|
6559
|
+
] })
|
|
6560
|
+
] });
|
|
6561
|
+
}
|
|
6562
|
+
|
|
6563
|
+
// src/ui/pages/new-workspace.tsx
|
|
6564
|
+
import Link11 from "next/link";
|
|
6565
|
+
import { useRouter as useRouter19, useSearchParams as useSearchParams7 } from "next/navigation";
|
|
6566
|
+
import { zodResolver as zodResolver15 } from "@hookform/resolvers/zod";
|
|
6567
|
+
import { useTranslations as useTranslations51 } from "next-intl";
|
|
6568
|
+
import { useForm as useForm16 } from "react-hook-form";
|
|
6569
|
+
import slugify from "slugify";
|
|
6570
|
+
import { z as z15 } from "zod";
|
|
6571
|
+
import { cn as cn44 } from "pelatform-ui";
|
|
6572
|
+
import { AlertToast as AlertToast26 } from "pelatform-ui/components";
|
|
6573
|
+
import {
|
|
6574
|
+
Button as Button37,
|
|
6575
|
+
buttonVariants,
|
|
6576
|
+
Card as Card12,
|
|
6577
|
+
CardContent as CardContent4,
|
|
6578
|
+
CardHeader as CardHeader3,
|
|
6579
|
+
Form as Form16,
|
|
6580
|
+
FormControl as FormControl15,
|
|
6581
|
+
FormField as FormField15,
|
|
6582
|
+
FormItem as FormItem15,
|
|
6583
|
+
FormLabel as FormLabel14,
|
|
6584
|
+
FormMessage as FormMessage15,
|
|
6585
|
+
Input as Input12,
|
|
6586
|
+
Spinner as Spinner21
|
|
6587
|
+
} from "pelatform-ui/default";
|
|
6588
|
+
import { jsx as jsx63, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
6589
|
+
function NewWorkspace({ className, classNames }) {
|
|
6590
|
+
const searchParams = useSearchParams7();
|
|
6591
|
+
const t = useTranslations51();
|
|
6592
|
+
const hasWorkspaces = searchParams.get("workspaces") === "true";
|
|
6593
|
+
return /* @__PURE__ */ jsxs53(Card12, { className: cn44("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
|
|
6594
|
+
/* @__PURE__ */ jsx63(CardHeader3, { className: "py-4", children: /* @__PURE__ */ jsx63(
|
|
6595
|
+
CardHeaderComponent,
|
|
6596
|
+
{
|
|
6597
|
+
className: "w-full text-center",
|
|
6598
|
+
title: t("systems.NEW_ORGANIZATION_TITLE"),
|
|
6599
|
+
description: t(
|
|
6600
|
+
hasWorkspaces ? "systems.NEW_ORGANIZATION_DESCRIPTION_HAS" : "systems.NEW_ORGANIZATION_DESCRIPTION"
|
|
6601
|
+
)
|
|
6602
|
+
}
|
|
6603
|
+
) }),
|
|
6604
|
+
/* @__PURE__ */ jsx63(CardContent4, { className: cn44("flex flex-col gap-6 truncate", classNames?.content), children: /* @__PURE__ */ jsx63(NewWorkspaceForm, { hasWorkspaces }) })
|
|
6605
|
+
] });
|
|
6606
|
+
}
|
|
6607
|
+
function NewWorkspaceForm({ hasWorkspaces = false }) {
|
|
6608
|
+
const { authClient, path } = useConfig();
|
|
6609
|
+
const router = useRouter19();
|
|
6610
|
+
const t = useTranslations51();
|
|
6611
|
+
const RESERVED_SLUGS = [
|
|
6612
|
+
// Main routes
|
|
6613
|
+
path.main.ERROR.replace("/", ""),
|
|
6614
|
+
path.main.HOME.replace("/", ""),
|
|
6615
|
+
path.main.FEATURES.replace("/", ""),
|
|
6616
|
+
path.main.PRICING.replace("/", ""),
|
|
6617
|
+
path.main.TERMS.replace("/", ""),
|
|
6618
|
+
path.main.PRIVACY.replace("/", ""),
|
|
6619
|
+
// Auth routes
|
|
6620
|
+
path.auth.EMAIL_OTP.replace("/", ""),
|
|
6621
|
+
path.auth.FORGOT_PASSWORD.replace("/", ""),
|
|
6622
|
+
path.auth.MAGIC_LINK.replace("/", ""),
|
|
6623
|
+
path.auth.RECOVER_ACCOUNT.replace("/", ""),
|
|
6624
|
+
path.auth.RESET_PASSWORD.replace("/", ""),
|
|
6625
|
+
path.auth.SIGN_IN.replace("/", ""),
|
|
6626
|
+
path.auth.SIGN_OUT.replace("/", ""),
|
|
6627
|
+
path.auth.SIGN_UP.replace("/", ""),
|
|
6628
|
+
path.auth.TWO_FACTOR.replace("/", ""),
|
|
6629
|
+
// System routes
|
|
6630
|
+
"new",
|
|
6631
|
+
"accept",
|
|
6632
|
+
"invitation",
|
|
6633
|
+
"join",
|
|
6634
|
+
"verify",
|
|
6635
|
+
"api",
|
|
6636
|
+
"account",
|
|
6637
|
+
"accounts",
|
|
6638
|
+
"billing",
|
|
6639
|
+
"billings",
|
|
6640
|
+
"user",
|
|
6641
|
+
"users",
|
|
6642
|
+
"onboarding",
|
|
6643
|
+
"organization",
|
|
6644
|
+
"organizations",
|
|
6645
|
+
"workspace",
|
|
6646
|
+
"workspaces",
|
|
6647
|
+
"setting",
|
|
6648
|
+
"settings",
|
|
6649
|
+
"apikey",
|
|
6650
|
+
"apikeys",
|
|
6651
|
+
"member",
|
|
6652
|
+
"members",
|
|
6653
|
+
"people",
|
|
6654
|
+
"peoples",
|
|
6655
|
+
// Next.js internals
|
|
6656
|
+
"_next",
|
|
6657
|
+
"static",
|
|
6658
|
+
"favicon",
|
|
6659
|
+
"robots",
|
|
6660
|
+
"sitemap",
|
|
6661
|
+
// Future-proofing common patterns
|
|
6662
|
+
"admin",
|
|
6663
|
+
"dashboard",
|
|
6664
|
+
"app",
|
|
6665
|
+
"www",
|
|
6666
|
+
"home",
|
|
6667
|
+
"blog",
|
|
6668
|
+
"docs",
|
|
6669
|
+
"help",
|
|
6670
|
+
"support",
|
|
6671
|
+
"about",
|
|
6672
|
+
"contact",
|
|
6673
|
+
"features",
|
|
6674
|
+
"pricing",
|
|
6675
|
+
"terms",
|
|
6676
|
+
"privacy"
|
|
6677
|
+
];
|
|
6678
|
+
const formSchema = z15.object({
|
|
6679
|
+
name: z15.string().min(1, {
|
|
6680
|
+
error: `${t("systems.ORGANIZATION_NAME")} ${t("systems.IS_REQUIRED")}`
|
|
6681
|
+
}),
|
|
6682
|
+
slug: z15.string().min(1, {
|
|
6683
|
+
error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_REQUIRED")}`
|
|
6684
|
+
}).regex(/^[a-z0-9]+([a-z0-9-]*[a-z0-9])?$/, {
|
|
6685
|
+
error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_INVALID")}`
|
|
6686
|
+
}).refine((slug) => !RESERVED_SLUGS.includes(slug), {
|
|
6687
|
+
error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_INVALID")}`
|
|
6688
|
+
})
|
|
6689
|
+
});
|
|
6690
|
+
const form = useForm16({
|
|
6691
|
+
resolver: zodResolver15(formSchema),
|
|
6692
|
+
defaultValues: {
|
|
6693
|
+
name: "",
|
|
6694
|
+
slug: ""
|
|
6695
|
+
}
|
|
6696
|
+
});
|
|
6697
|
+
const watchedName = form.watch("name");
|
|
6698
|
+
const watchedSlug = form.watch("slug");
|
|
6699
|
+
const isSubmitting = form.formState.isSubmitting;
|
|
6700
|
+
const disableSubmit = isSubmitting || !form.formState.isValid || !watchedName || !watchedSlug;
|
|
6701
|
+
async function onSubmit({ name, slug }) {
|
|
6702
|
+
const { error } = await authClient.organization.checkSlug({
|
|
6703
|
+
slug
|
|
6704
|
+
});
|
|
6705
|
+
if (error) {
|
|
6706
|
+
AlertToast26({
|
|
6707
|
+
message: getTranslations({ error, t }),
|
|
6708
|
+
icon: "destructive"
|
|
6709
|
+
});
|
|
6710
|
+
console.log("check slug error", error);
|
|
6711
|
+
return;
|
|
6712
|
+
}
|
|
6713
|
+
try {
|
|
6714
|
+
const organization = await authClient.organization.create({
|
|
6715
|
+
name,
|
|
6716
|
+
slug,
|
|
6717
|
+
logo: `https://api.dicebear.com/9.x/glass/svg?seed=${slug}`,
|
|
6718
|
+
fetchOptions: { throw: true }
|
|
6719
|
+
});
|
|
6720
|
+
if (organization) {
|
|
6721
|
+
console.log("setting active organization", organization.id);
|
|
6722
|
+
await authClient.organization.setActive({
|
|
6723
|
+
organizationId: organization.id
|
|
6724
|
+
});
|
|
6725
|
+
console.log("active organization set", organization.id);
|
|
6726
|
+
router.push(`/${organization.slug}`);
|
|
6727
|
+
AlertToast26({
|
|
6728
|
+
message: t("systems.CREATE_ORGANIZATION_SUCCESS")
|
|
6729
|
+
});
|
|
6730
|
+
}
|
|
6731
|
+
} catch (error2) {
|
|
6732
|
+
AlertToast26({
|
|
6733
|
+
message: getTranslations({ error: error2, t }),
|
|
6734
|
+
icon: "destructive"
|
|
6735
|
+
});
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6738
|
+
const handleSlugify = (slug) => {
|
|
6739
|
+
return slugify(slug, { lower: true, strict: true, remove: /[*+~.()'"!:@]/g });
|
|
6740
|
+
};
|
|
6741
|
+
return /* @__PURE__ */ jsx63(Form16, { ...form, children: /* @__PURE__ */ jsxs53("form", { onSubmit: form.handleSubmit(onSubmit), className: "w-full space-y-6", children: [
|
|
6742
|
+
/* @__PURE__ */ jsx63(
|
|
6743
|
+
FormField15,
|
|
6744
|
+
{
|
|
6745
|
+
control: form.control,
|
|
6746
|
+
name: "name",
|
|
6747
|
+
render: ({ field }) => /* @__PURE__ */ jsxs53(FormItem15, { children: [
|
|
6748
|
+
/* @__PURE__ */ jsx63(FormLabel14, { children: t("systems.ORGANIZATION_NAME") }),
|
|
6749
|
+
/* @__PURE__ */ jsx63(FormControl15, { children: /* @__PURE__ */ jsx63(
|
|
6750
|
+
Input12,
|
|
6751
|
+
{
|
|
6752
|
+
placeholder: t("systems.ORGANIZATION_NAME_PLACEHOLDER"),
|
|
6753
|
+
...field,
|
|
6754
|
+
onChange: (e) => {
|
|
6755
|
+
const v = e.target.value;
|
|
6756
|
+
field.onChange(v);
|
|
6757
|
+
form.setValue("slug", handleSlugify(v), {
|
|
6758
|
+
shouldValidate: true,
|
|
6759
|
+
shouldDirty: true
|
|
6760
|
+
});
|
|
6761
|
+
},
|
|
6762
|
+
onBlur: () => {
|
|
6763
|
+
field.onBlur();
|
|
6764
|
+
void handleSlugify(form.getValues("slug"));
|
|
6765
|
+
}
|
|
6766
|
+
}
|
|
6767
|
+
) }),
|
|
6768
|
+
/* @__PURE__ */ jsx63(FormMessage15, {})
|
|
6769
|
+
] })
|
|
6770
|
+
}
|
|
6771
|
+
),
|
|
6772
|
+
/* @__PURE__ */ jsx63(
|
|
6773
|
+
FormField15,
|
|
6774
|
+
{
|
|
6775
|
+
control: form.control,
|
|
6776
|
+
name: "slug",
|
|
6777
|
+
render: ({ field }) => /* @__PURE__ */ jsxs53(FormItem15, { children: [
|
|
6778
|
+
/* @__PURE__ */ jsx63(FormLabel14, { children: t("systems.ORGANIZATION_SLUG") }),
|
|
6779
|
+
/* @__PURE__ */ jsx63(FormControl15, { children: /* @__PURE__ */ jsx63(Input12, { placeholder: t("systems.ORGANIZATION_SLUG_PLACEHOLDER"), ...field }) }),
|
|
6780
|
+
/* @__PURE__ */ jsx63(FormMessage15, {})
|
|
6781
|
+
] })
|
|
6782
|
+
}
|
|
6783
|
+
),
|
|
6784
|
+
/* @__PURE__ */ jsxs53("div", { className: "flex flex-col gap-4", children: [
|
|
6785
|
+
/* @__PURE__ */ jsxs53(
|
|
6786
|
+
Button37,
|
|
6787
|
+
{
|
|
6788
|
+
type: "submit",
|
|
6789
|
+
className: cn44("w-full", disableSubmit && "pointer-events-auto! cursor-not-allowed"),
|
|
6790
|
+
disabled: disableSubmit,
|
|
6791
|
+
children: [
|
|
6792
|
+
isSubmitting && /* @__PURE__ */ jsx63(Spinner21, {}),
|
|
6793
|
+
t("systems.CREATE_ORGANIZATION")
|
|
6794
|
+
]
|
|
6795
|
+
}
|
|
6796
|
+
),
|
|
6797
|
+
hasWorkspaces && /* @__PURE__ */ jsx63(
|
|
6798
|
+
Link11,
|
|
6799
|
+
{
|
|
6800
|
+
href: "/",
|
|
6801
|
+
className: cn44(buttonVariants({ variant: "ghost", size: "lg" }), "w-full"),
|
|
6802
|
+
children: t("systems.common.actions.backDashboard")
|
|
6803
|
+
}
|
|
6804
|
+
)
|
|
6805
|
+
] })
|
|
6806
|
+
] }) });
|
|
6807
|
+
}
|
|
6808
|
+
|
|
6809
|
+
// src/ui/pages/verify-email.tsx
|
|
6810
|
+
import { useEffect as useEffect18, useState as useState22 } from "react";
|
|
6811
|
+
import { useRouter as useRouter20 } from "next/navigation";
|
|
6812
|
+
import { useTranslations as useTranslations52 } from "next-intl";
|
|
6813
|
+
import { cn as cn45 } from "pelatform-ui";
|
|
6814
|
+
import { AlertToast as AlertToast27 } from "pelatform-ui/components";
|
|
6815
|
+
import { Button as Button38, Card as Card13, CardContent as CardContent5, CardHeader as CardHeader4, InputOTP as InputOTP3, Spinner as Spinner22 } from "pelatform-ui/default";
|
|
6816
|
+
import { Fragment as Fragment21, jsx as jsx64, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
6817
|
+
function VerifyEmail({ className, classNames, callbackUrl, email }) {
|
|
6818
|
+
const { authClient } = useConfig();
|
|
6819
|
+
const router = useRouter20();
|
|
6820
|
+
const t = useTranslations52();
|
|
6821
|
+
const [otp, setOtp] = useState22("");
|
|
6822
|
+
const [isLoading, setIsLoading] = useState22(false);
|
|
6823
|
+
const [isResendLoading, setIsResendLoading] = useState22(false);
|
|
6824
|
+
const [isResendSuccess, setIsResendSuccess] = useState22(false);
|
|
6825
|
+
const [waitingSeconds, setWaitingSeconds] = useState22(30);
|
|
6826
|
+
useEffect18(() => {
|
|
6827
|
+
if (waitingSeconds > 0) {
|
|
6828
|
+
const timeout = setTimeout(() => {
|
|
6829
|
+
setWaitingSeconds(waitingSeconds - 1);
|
|
6830
|
+
}, 1e3);
|
|
6831
|
+
return () => clearTimeout(timeout);
|
|
6832
|
+
}
|
|
6833
|
+
if (waitingSeconds === 0 && isResendSuccess) {
|
|
6834
|
+
setIsResendSuccess(false);
|
|
6835
|
+
}
|
|
6836
|
+
}, [waitingSeconds, isResendSuccess]);
|
|
6837
|
+
const handleResendCode = async () => {
|
|
6838
|
+
setIsResendLoading(true);
|
|
6839
|
+
try {
|
|
6840
|
+
await authClient.emailOtp.sendVerificationOtp({
|
|
6841
|
+
email,
|
|
6842
|
+
type: "email-verification"
|
|
6843
|
+
});
|
|
6844
|
+
AlertToast27({
|
|
6845
|
+
message: t("systems.VERIFY_EMAIL_RESEND_SUCCESS")
|
|
6846
|
+
});
|
|
6847
|
+
} catch {
|
|
6848
|
+
AlertToast27({
|
|
6849
|
+
message: t("systems.VERIFY_EMAIL_RESEND_FAILED"),
|
|
6850
|
+
icon: "destructive"
|
|
6851
|
+
});
|
|
6852
|
+
} finally {
|
|
6853
|
+
setWaitingSeconds(30);
|
|
6854
|
+
setIsResendLoading(false);
|
|
6855
|
+
setIsResendSuccess(true);
|
|
6856
|
+
}
|
|
6857
|
+
};
|
|
6858
|
+
const handleVerifyOtp = async () => {
|
|
6859
|
+
setIsLoading(true);
|
|
6860
|
+
try {
|
|
6861
|
+
const result = await authClient.emailOtp.verifyEmail({
|
|
6862
|
+
email,
|
|
6863
|
+
otp
|
|
6864
|
+
});
|
|
6865
|
+
if (result.data) {
|
|
6866
|
+
AlertToast27({
|
|
6867
|
+
message: t("systems.VERIFY_EMAIL_SUCCESS")
|
|
6868
|
+
});
|
|
6869
|
+
router.push(callbackUrl);
|
|
6870
|
+
} else {
|
|
6871
|
+
AlertToast27({
|
|
6872
|
+
message: t("systems.VERIFY_EMAIL_FAILED"),
|
|
6873
|
+
icon: "destructive"
|
|
6874
|
+
});
|
|
6875
|
+
}
|
|
6876
|
+
} catch {
|
|
6877
|
+
AlertToast27({
|
|
6878
|
+
message: t("systems.VERIFY_EMAIL_FAILED_TRY"),
|
|
6879
|
+
icon: "destructive"
|
|
6880
|
+
});
|
|
6881
|
+
} finally {
|
|
6882
|
+
setIsLoading(false);
|
|
6883
|
+
}
|
|
6884
|
+
};
|
|
6885
|
+
const emailElement = () => /* @__PURE__ */ jsx64("span", { className: "block font-medium text-foreground", children: email });
|
|
6886
|
+
return /* @__PURE__ */ jsxs54(Card13, { className: cn45("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
|
|
6887
|
+
/* @__PURE__ */ jsx64(CardHeader4, { className: "py-4", children: /* @__PURE__ */ jsx64(
|
|
6888
|
+
CardHeaderComponent,
|
|
6889
|
+
{
|
|
6890
|
+
className: "w-full text-center",
|
|
6891
|
+
title: t("systems.VERIFY_EMAIL_TITLE"),
|
|
6892
|
+
description: /* @__PURE__ */ jsxs54(Fragment21, { children: [
|
|
6893
|
+
t("systems.VERIFY_EMAIL_DESCRIPTION"),
|
|
6894
|
+
" ",
|
|
6895
|
+
emailElement()
|
|
6896
|
+
] })
|
|
6897
|
+
}
|
|
6898
|
+
) }),
|
|
6899
|
+
/* @__PURE__ */ jsxs54(CardContent5, { className: cn45("flex flex-col gap-6 truncate", classNames?.content), children: [
|
|
6900
|
+
/* @__PURE__ */ jsx64(
|
|
6901
|
+
InputOTP3,
|
|
6902
|
+
{
|
|
6903
|
+
maxLength: 6,
|
|
6904
|
+
onChange: (value) => setOtp(value),
|
|
6905
|
+
value: otp,
|
|
6906
|
+
containerClassName: "justify-center",
|
|
6907
|
+
children: /* @__PURE__ */ jsx64(OTPInputGroup, { otpSeparators: 1 })
|
|
6908
|
+
}
|
|
6909
|
+
),
|
|
6910
|
+
/* @__PURE__ */ jsxs54("div", { className: "flex w-full flex-col items-center gap-4", children: [
|
|
6911
|
+
/* @__PURE__ */ jsxs54(
|
|
6912
|
+
Button38,
|
|
6913
|
+
{
|
|
6914
|
+
className: cn45(
|
|
6915
|
+
"flex w-full items-center justify-center",
|
|
6916
|
+
otp.length !== 6 && "cursor-not-allowed"
|
|
6917
|
+
),
|
|
6918
|
+
onClick: handleVerifyOtp,
|
|
6919
|
+
disabled: otp.length !== 6,
|
|
6920
|
+
children: [
|
|
6921
|
+
isLoading && /* @__PURE__ */ jsx64(Spinner22, {}),
|
|
6922
|
+
t("systems.VERIFY_EMAIL_BUTTON")
|
|
6923
|
+
]
|
|
6924
|
+
}
|
|
6925
|
+
),
|
|
6926
|
+
/* @__PURE__ */ jsxs54("div", { className: "flex flex-col items-center gap-3", children: [
|
|
6927
|
+
/* @__PURE__ */ jsx64("p", { className: "text-muted-foreground text-sm", children: t("systems.VERIFY_EMAIL_NOT_RECEIVE") }),
|
|
6928
|
+
/* @__PURE__ */ jsxs54(
|
|
6929
|
+
Button38,
|
|
6930
|
+
{
|
|
6931
|
+
variant: "outline",
|
|
6932
|
+
className: cn45(
|
|
6933
|
+
"text-muted-foreground",
|
|
6934
|
+
isResendLoading || waitingSeconds > 0 && "cursor-not-allowed"
|
|
6935
|
+
),
|
|
6936
|
+
onClick: handleResendCode,
|
|
6937
|
+
disabled: waitingSeconds > 0,
|
|
6938
|
+
children: [
|
|
6939
|
+
isResendLoading && /* @__PURE__ */ jsx64(Spinner22, {}),
|
|
6940
|
+
isResendLoading ? `${t("systems.VERIFY_EMAIL_SENDING")}` : waitingSeconds > 0 ? `${t("systems.VERIFY_EMAIL_RESEND")} (${waitingSeconds}s)` : t("systems.VERIFY_EMAIL_RESEND")
|
|
6941
|
+
]
|
|
6942
|
+
}
|
|
6943
|
+
)
|
|
6944
|
+
] })
|
|
6945
|
+
] })
|
|
6946
|
+
] })
|
|
6947
|
+
] });
|
|
6948
|
+
}
|
|
6949
|
+
|
|
6354
6950
|
// src/ui/providers/shared.tsx
|
|
6355
6951
|
import { Suspense as Suspense2 } from "react";
|
|
6356
6952
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
6357
6953
|
import { NextIntlClientProvider } from "next-intl";
|
|
6358
6954
|
import { QueryProvider, ThemeProvider } from "pelatform-ui/components";
|
|
6359
6955
|
import { Toaster as Sonner } from "pelatform-ui/default";
|
|
6360
|
-
import { jsx as
|
|
6956
|
+
import { jsx as jsx65, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
6361
6957
|
function SharedProviders({
|
|
6362
6958
|
children,
|
|
6363
6959
|
locale,
|
|
@@ -6366,20 +6962,161 @@ function SharedProviders({
|
|
|
6366
6962
|
sonnerPosition = "top-center"
|
|
6367
6963
|
}) {
|
|
6368
6964
|
const config = useConfig();
|
|
6369
|
-
return /* @__PURE__ */
|
|
6370
|
-
/* @__PURE__ */
|
|
6965
|
+
return /* @__PURE__ */ jsxs55(QueryProvider, { children: [
|
|
6966
|
+
/* @__PURE__ */ jsx65(ThemeProvider, { defaultTheme: config.ui.defaultTheme, children: /* @__PURE__ */ jsx65(NextIntlClientProvider, { locale, messages, timeZone, children: /* @__PURE__ */ jsxs55(Suspense2, { children: [
|
|
6371
6967
|
children,
|
|
6372
|
-
/* @__PURE__ */
|
|
6968
|
+
/* @__PURE__ */ jsx65(Sonner, { position: sonnerPosition })
|
|
6373
6969
|
] }) }) }),
|
|
6374
|
-
/* @__PURE__ */
|
|
6970
|
+
/* @__PURE__ */ jsx65(ReactQueryDevtools, { initialIsOpen: false })
|
|
6375
6971
|
] });
|
|
6376
6972
|
}
|
|
6377
6973
|
|
|
6974
|
+
// src/ui/providers/workspace.tsx
|
|
6975
|
+
import { useCallback as useCallback5, useContext as useContext14, useEffect as useEffect19, useState as useState23 } from "react";
|
|
6976
|
+
import { notFound, usePathname as usePathname5, useRouter as useRouter21 } from "next/navigation";
|
|
6977
|
+
import { useMutation as useMutation3, useQuery as useQuery3, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
6978
|
+
import { AlertToast as AlertToast28 } from "pelatform-ui/components";
|
|
6979
|
+
import { jsx as jsx66 } from "react/jsx-runtime";
|
|
6980
|
+
function WorkspaceProvider({
|
|
6981
|
+
children,
|
|
6982
|
+
initialWorkspace,
|
|
6983
|
+
workspaceSlug,
|
|
6984
|
+
fetchWorkspaceList = "api/workspaces",
|
|
6985
|
+
fetchWorkspaceBySlug = "api/workspace/s"
|
|
6986
|
+
}) {
|
|
6987
|
+
const { authClient } = useConfig();
|
|
6988
|
+
const { queryKey } = useContext14(QueryContext);
|
|
6989
|
+
const pathname = usePathname5();
|
|
6990
|
+
const queryClient = useQueryClient3();
|
|
6991
|
+
const router = useRouter21();
|
|
6992
|
+
const [activeWorkspace, setActiveWorkspace] = useState23(initialWorkspace);
|
|
6993
|
+
const [isSwitchingWorkspace, setIsSwitchingWorkspace] = useState23(false);
|
|
6994
|
+
const shouldFetchWorkspace = !!workspaceSlug && (!activeWorkspace || activeWorkspace.slug !== workspaceSlug);
|
|
6995
|
+
const { data: usersWorkspaces } = useQuery3({
|
|
6996
|
+
queryKey: queryKey.workspaceList,
|
|
6997
|
+
queryFn: async () => {
|
|
6998
|
+
const response = await request(fetchWorkspaceList);
|
|
6999
|
+
return response.data;
|
|
7000
|
+
}
|
|
7001
|
+
});
|
|
7002
|
+
const fetchWorkspaceData = async (slug) => {
|
|
7003
|
+
try {
|
|
7004
|
+
const response = await request(`${fetchWorkspaceBySlug}/${slug}`);
|
|
7005
|
+
if (response.status === 200) {
|
|
7006
|
+
setActiveWorkspace(response.data);
|
|
7007
|
+
return response.data;
|
|
7008
|
+
}
|
|
7009
|
+
if (response.status === 404) {
|
|
7010
|
+
console.error("Workspace not found");
|
|
7011
|
+
return notFound();
|
|
7012
|
+
}
|
|
7013
|
+
console.error(`Unexpected status code: ${response.status}`);
|
|
7014
|
+
return null;
|
|
7015
|
+
} catch (error) {
|
|
7016
|
+
console.error("Failed to fetch workspace data:", error);
|
|
7017
|
+
return null;
|
|
7018
|
+
}
|
|
7019
|
+
};
|
|
7020
|
+
const { data: fetchedActiveWorkspace, isLoading: isFetchingActiveWorkspace } = useQuery3({
|
|
7021
|
+
queryKey: queryKey.workspaceBySlug(workspaceSlug),
|
|
7022
|
+
queryFn: () => fetchWorkspaceData(workspaceSlug),
|
|
7023
|
+
enabled: shouldFetchWorkspace,
|
|
7024
|
+
initialData: initialWorkspace && initialWorkspace.slug === workspaceSlug ? initialWorkspace : void 0,
|
|
7025
|
+
staleTime: 5 * 60 * 1e3,
|
|
7026
|
+
gcTime: 10 * 60 * 1e3
|
|
7027
|
+
});
|
|
7028
|
+
const { mutateAsync: updateActiveWorkspaceMutation } = useMutation3({
|
|
7029
|
+
mutationFn: async (workspace) => {
|
|
7030
|
+
setIsSwitchingWorkspace(true);
|
|
7031
|
+
setActiveWorkspace(
|
|
7032
|
+
(prev) => ({
|
|
7033
|
+
...prev,
|
|
7034
|
+
...workspace
|
|
7035
|
+
})
|
|
7036
|
+
);
|
|
7037
|
+
if (workspace.slug) {
|
|
7038
|
+
setLastVisitedWorkspace(workspace.slug);
|
|
7039
|
+
}
|
|
7040
|
+
if (!workspace.id) {
|
|
7041
|
+
throw new Error("Workspace ID is required for switching");
|
|
7042
|
+
}
|
|
7043
|
+
const { data, error } = await authClient.organization.setActive({
|
|
7044
|
+
organizationId: workspace.id
|
|
7045
|
+
});
|
|
7046
|
+
if (error) {
|
|
7047
|
+
AlertToast28({
|
|
7048
|
+
message: error.message,
|
|
7049
|
+
icon: "destructive"
|
|
7050
|
+
});
|
|
7051
|
+
throw new Error(error.message);
|
|
7052
|
+
}
|
|
7053
|
+
return data;
|
|
7054
|
+
},
|
|
7055
|
+
onSuccess: (data) => {
|
|
7056
|
+
if (data) {
|
|
7057
|
+
queryClient.removeQueries({
|
|
7058
|
+
predicate: (query) => {
|
|
7059
|
+
const key = query.queryKey;
|
|
7060
|
+
return Array.isArray(key) && key.length >= 2 && typeof key[1] === "string" && WORKSPACE_SCOPED_PREFIXES.includes(key[0]);
|
|
7061
|
+
}
|
|
7062
|
+
});
|
|
7063
|
+
queryClient.setQueryData(queryKey.workspaceBySlug(data.slug), data);
|
|
7064
|
+
queryClient.setQueryData(queryKey.workspaceById(data.id), data);
|
|
7065
|
+
const pathSegments = pathname.split("/").filter(Boolean);
|
|
7066
|
+
const pathAfterWorkspace = pathSegments.slice(1).join("/");
|
|
7067
|
+
const newPath = pathAfterWorkspace ? `/${data.slug}/${pathAfterWorkspace}` : `/${data.slug}`;
|
|
7068
|
+
router.push(newPath);
|
|
7069
|
+
}
|
|
7070
|
+
setIsSwitchingWorkspace(false);
|
|
7071
|
+
},
|
|
7072
|
+
onError: (error) => {
|
|
7073
|
+
console.error("Failed to switch workspace:", error);
|
|
7074
|
+
if (initialWorkspace) {
|
|
7075
|
+
setActiveWorkspace(initialWorkspace);
|
|
7076
|
+
setLastVisitedWorkspace(initialWorkspace.slug);
|
|
7077
|
+
}
|
|
7078
|
+
setIsSwitchingWorkspace(false);
|
|
7079
|
+
}
|
|
7080
|
+
});
|
|
7081
|
+
const updateActiveWorkspace = useCallback5(
|
|
7082
|
+
async (workspace) => {
|
|
7083
|
+
await updateActiveWorkspaceMutation(workspace);
|
|
7084
|
+
},
|
|
7085
|
+
[updateActiveWorkspaceMutation]
|
|
7086
|
+
);
|
|
7087
|
+
useEffect19(() => {
|
|
7088
|
+
if (fetchedActiveWorkspace && workspaceSlug !== fetchedActiveWorkspace.slug && !isSwitchingWorkspace) {
|
|
7089
|
+
updateActiveWorkspace(fetchedActiveWorkspace);
|
|
7090
|
+
}
|
|
7091
|
+
}, [fetchedActiveWorkspace, workspaceSlug, isSwitchingWorkspace, updateActiveWorkspace]);
|
|
7092
|
+
const isFetchingWorkspace = isFetchingActiveWorkspace || isSwitchingWorkspace;
|
|
7093
|
+
const isOwner = activeWorkspace?.currentUserRole === "owner";
|
|
7094
|
+
const isAdmin = activeWorkspace?.currentUserRole === "admin";
|
|
7095
|
+
const isMember = activeWorkspace?.currentUserRole === "member";
|
|
7096
|
+
const currentUserRole = activeWorkspace?.currentUserRole || null;
|
|
7097
|
+
return /* @__PURE__ */ jsx66(
|
|
7098
|
+
WorkspaceContext.Provider,
|
|
7099
|
+
{
|
|
7100
|
+
value: {
|
|
7101
|
+
activeWorkspace,
|
|
7102
|
+
workspaceList: usersWorkspaces ?? null,
|
|
7103
|
+
isFetchingWorkspace,
|
|
7104
|
+
isOwner,
|
|
7105
|
+
isAdmin,
|
|
7106
|
+
isMember,
|
|
7107
|
+
currentUserRole,
|
|
7108
|
+
updateActiveWorkspace
|
|
7109
|
+
},
|
|
7110
|
+
children
|
|
7111
|
+
}
|
|
7112
|
+
);
|
|
7113
|
+
}
|
|
7114
|
+
|
|
6378
7115
|
// src/ui/shared/empty-state.tsx
|
|
6379
|
-
import
|
|
6380
|
-
import { useTranslations as
|
|
6381
|
-
import { cn as
|
|
6382
|
-
import { jsx as
|
|
7116
|
+
import Link12 from "next/link";
|
|
7117
|
+
import { useTranslations as useTranslations53 } from "next-intl";
|
|
7118
|
+
import { cn as cn46 } from "pelatform-ui";
|
|
7119
|
+
import { jsx as jsx67, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
6383
7120
|
function EmptyState({
|
|
6384
7121
|
className,
|
|
6385
7122
|
icon: Icon,
|
|
@@ -6389,15 +7126,15 @@ function EmptyState({
|
|
|
6389
7126
|
learnMoreText,
|
|
6390
7127
|
children
|
|
6391
7128
|
}) {
|
|
6392
|
-
const t =
|
|
6393
|
-
return /* @__PURE__ */
|
|
6394
|
-
Icon && /* @__PURE__ */
|
|
6395
|
-
/* @__PURE__ */
|
|
6396
|
-
description && /* @__PURE__ */
|
|
7129
|
+
const t = useTranslations53();
|
|
7130
|
+
return /* @__PURE__ */ jsxs56("div", { className: cn46("flex flex-col items-center justify-center gap-y-4", className), children: [
|
|
7131
|
+
Icon && /* @__PURE__ */ jsx67("div", { className: "flex size-14 items-center justify-center rounded-2xl border bg-muted", children: /* @__PURE__ */ jsx67(Icon, { className: "size-6 text-foreground" }) }),
|
|
7132
|
+
/* @__PURE__ */ jsx67("p", { className: "text-center font-medium text-base text-foreground", children: title }),
|
|
7133
|
+
description && /* @__PURE__ */ jsxs56("p", { className: "max-w-sm text-balance text-center text-muted-foreground text-sm", children: [
|
|
6397
7134
|
description,
|
|
6398
7135
|
" ",
|
|
6399
|
-
learnMore && /* @__PURE__ */
|
|
6400
|
-
|
|
7136
|
+
learnMore && /* @__PURE__ */ jsxs56(
|
|
7137
|
+
Link12,
|
|
6401
7138
|
{
|
|
6402
7139
|
href: learnMore,
|
|
6403
7140
|
className: "text-foreground underline underline-offset-2 transition-colors hover:text-primary",
|
|
@@ -6457,6 +7194,8 @@ export {
|
|
|
6457
7194
|
MagicLinkButton,
|
|
6458
7195
|
MagicLinkForm,
|
|
6459
7196
|
MultiAccountCard,
|
|
7197
|
+
NewWorkspace,
|
|
7198
|
+
NewWorkspaceForm,
|
|
6460
7199
|
OTPInputGroup,
|
|
6461
7200
|
OneTap,
|
|
6462
7201
|
PasskeyButton,
|
|
@@ -6476,6 +7215,7 @@ export {
|
|
|
6476
7215
|
SidebarContent,
|
|
6477
7216
|
SidebarContentMenu,
|
|
6478
7217
|
SidebarHeaderBack,
|
|
7218
|
+
SidebarHeaderWorkspaces,
|
|
6479
7219
|
SignInForm,
|
|
6480
7220
|
SignOut,
|
|
6481
7221
|
SignUpForm,
|
|
@@ -6492,7 +7232,11 @@ export {
|
|
|
6492
7232
|
UserAvatar,
|
|
6493
7233
|
UserMenu,
|
|
6494
7234
|
UserView,
|
|
7235
|
+
VerifyEmail,
|
|
7236
|
+
WorkspaceContext,
|
|
6495
7237
|
WorkspaceLogo,
|
|
7238
|
+
WorkspaceProvider,
|
|
7239
|
+
WorkspaceSwitcher,
|
|
6496
7240
|
WorkspaceView,
|
|
6497
7241
|
getUserName,
|
|
6498
7242
|
useAccountInfo,
|
|
@@ -6518,5 +7262,6 @@ export {
|
|
|
6518
7262
|
useSession,
|
|
6519
7263
|
useSetActiveSession,
|
|
6520
7264
|
useUnlinkAccount,
|
|
6521
|
-
useUpdateUser
|
|
7265
|
+
useUpdateUser,
|
|
7266
|
+
useWorkspace
|
|
6522
7267
|
};
|