better-auth-ui 3.2.5
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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/auth-hooks-IOEvlYYv.d.cts +6966 -0
- package/dist/auth-hooks-IOEvlYYv.d.ts +6966 -0
- package/dist/auth-mutators-DdqOmQ32.d.cts +29 -0
- package/dist/auth-mutators-DdqOmQ32.d.ts +29 -0
- package/dist/auth-ui-provider-BsH3xJDw.d.ts +697 -0
- package/dist/auth-ui-provider-DhZfncd3.d.cts +697 -0
- package/dist/chunk-BDFQSFBU.js +750 -0
- package/dist/chunk-CRAHKL2C.cjs +801 -0
- package/dist/chunk-MJPOA6PK.js +801 -0
- package/dist/chunk-SV64DXGW.cjs +750 -0
- package/dist/index.cjs +12618 -0
- package/dist/index.d.cts +771 -0
- package/dist/index.d.ts +771 -0
- package/dist/index.js +12618 -0
- package/dist/instantdb.cjs +189 -0
- package/dist/instantdb.d.cts +36 -0
- package/dist/instantdb.d.ts +36 -0
- package/dist/instantdb.js +189 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/server.cjs +194 -0
- package/dist/server.d.cts +35 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.js +194 -0
- package/dist/style.css +1 -0
- package/dist/tanstack.cjs +153 -0
- package/dist/tanstack.d.cts +18 -0
- package/dist/tanstack.d.ts +18 -0
- package/dist/tanstack.js +153 -0
- package/dist/triplit.cjs +201 -0
- package/dist/triplit.d.cts +31 -0
- package/dist/triplit.d.ts +31 -0
- package/dist/triplit.js +201 -0
- package/dist/utils-C5R37WDe.d.cts +3 -0
- package/dist/utils-C5R37WDe.d.ts +3 -0
- package/dist/view-paths-CHSJf5dv.d.cts +645 -0
- package/dist/view-paths-CHSJf5dv.d.ts +645 -0
- package/package.json +156 -0
- package/src/components/account/account-view.tsx +220 -0
- package/src/components/auth/auth-callback.tsx +36 -0
- package/src/components/auth/auth-form.tsx +277 -0
- package/src/components/auth/auth-view.tsx +389 -0
- package/src/components/auth/email-otp-button.tsx +53 -0
- package/src/components/auth/forms/email-otp-form.tsx +288 -0
- package/src/components/auth/forms/forgot-password-form.tsx +168 -0
- package/src/components/auth/forms/magic-link-form.tsx +191 -0
- package/src/components/auth/forms/recover-account-form.tsx +138 -0
- package/src/components/auth/forms/reset-password-form.tsx +215 -0
- package/src/components/auth/forms/sign-in-form.tsx +289 -0
- package/src/components/auth/forms/sign-up-form.tsx +788 -0
- package/src/components/auth/forms/two-factor-form.tsx +372 -0
- package/src/components/auth/magic-link-button.tsx +54 -0
- package/src/components/auth/one-tap.tsx +48 -0
- package/src/components/auth/otp-input-group.tsx +65 -0
- package/src/components/auth/passkey-button.tsx +85 -0
- package/src/components/auth/provider-button.tsx +141 -0
- package/src/components/auth/sign-out.tsx +25 -0
- package/src/components/auth-loading.tsx +21 -0
- package/src/components/captcha/captcha.tsx +79 -0
- package/src/components/captcha/recaptcha-badge.tsx +61 -0
- package/src/components/captcha/recaptcha-v2.tsx +58 -0
- package/src/components/captcha/recaptcha-v3.tsx +73 -0
- package/src/components/email/email-template.tsx +216 -0
- package/src/components/form-error.tsx +27 -0
- package/src/components/organization/accept-invitation-card.tsx +362 -0
- package/src/components/organization/create-organization-dialog.tsx +395 -0
- package/src/components/organization/delete-organization-card.tsx +101 -0
- package/src/components/organization/delete-organization-dialog.tsx +209 -0
- package/src/components/organization/invitation-cell.tsx +156 -0
- package/src/components/organization/invite-member-dialog.tsx +258 -0
- package/src/components/organization/leave-organization-dialog.tsx +150 -0
- package/src/components/organization/member-cell.tsx +187 -0
- package/src/components/organization/organization-cell-view.tsx +122 -0
- package/src/components/organization/organization-cell.tsx +154 -0
- package/src/components/organization/organization-invitations-card.tsx +94 -0
- package/src/components/organization/organization-logo-card.tsx +308 -0
- package/src/components/organization/organization-logo.tsx +120 -0
- package/src/components/organization/organization-members-card.tsx +155 -0
- package/src/components/organization/organization-name-card.tsx +204 -0
- package/src/components/organization/organization-settings-cards.tsx +67 -0
- package/src/components/organization/organization-slug-card.tsx +223 -0
- package/src/components/organization/organization-switcher.tsx +512 -0
- package/src/components/organization/organization-view.tsx +228 -0
- package/src/components/organization/organizations-card.tsx +72 -0
- package/src/components/organization/personal-account-view.tsx +115 -0
- package/src/components/organization/remove-member-dialog.tsx +144 -0
- package/src/components/organization/update-member-role-dialog.tsx +213 -0
- package/src/components/organization/user-invitations-card.tsx +238 -0
- package/src/components/password-input.tsx +56 -0
- package/src/components/provider-icons.tsx +385 -0
- package/src/components/redirect-to-sign-in.tsx +16 -0
- package/src/components/redirect-to-sign-up.tsx +16 -0
- package/src/components/settings/account/account-cell.tsx +158 -0
- package/src/components/settings/account/accounts-card.tsx +75 -0
- package/src/components/settings/account/delete-account-card.tsx +65 -0
- package/src/components/settings/account/delete-account-dialog.tsx +231 -0
- package/src/components/settings/account/update-avatar-card.tsx +198 -0
- package/src/components/settings/account/update-field-card.tsx +282 -0
- package/src/components/settings/account/update-name-card.tsx +39 -0
- package/src/components/settings/account/update-username-card.tsx +42 -0
- package/src/components/settings/account-settings-cards.tsx +123 -0
- package/src/components/settings/api-key/api-key-cell.tsx +108 -0
- package/src/components/settings/api-key/api-key-delete-dialog.tsx +162 -0
- package/src/components/settings/api-key/api-key-display-dialog.tsx +110 -0
- package/src/components/settings/api-key/api-keys-card.tsx +98 -0
- package/src/components/settings/api-key/create-api-key-dialog.tsx +376 -0
- package/src/components/settings/passkey/passkey-cell.tsx +113 -0
- package/src/components/settings/passkey/passkeys-card.tsx +111 -0
- package/src/components/settings/providers/provider-cell.tsx +152 -0
- package/src/components/settings/providers/providers-card.tsx +108 -0
- package/src/components/settings/security/change-email-card.tsx +200 -0
- package/src/components/settings/security/change-password-card.tsx +326 -0
- package/src/components/settings/security/session-cell.tsx +120 -0
- package/src/components/settings/security/sessions-card.tsx +58 -0
- package/src/components/settings/security-settings-cards.tsx +111 -0
- package/src/components/settings/shared/session-freshness-dialog.tsx +97 -0
- package/src/components/settings/shared/settings-action-button.tsx +51 -0
- package/src/components/settings/shared/settings-card-footer.tsx +94 -0
- package/src/components/settings/shared/settings-card-header.tsx +67 -0
- package/src/components/settings/shared/settings-card.tsx +106 -0
- package/src/components/settings/skeletons/input-field-skeleton.tsx +18 -0
- package/src/components/settings/skeletons/settings-cell-skeleton.tsx +37 -0
- package/src/components/settings/two-factor/backup-codes-dialog.tsx +113 -0
- package/src/components/settings/two-factor/two-factor-card.tsx +63 -0
- package/src/components/settings/two-factor/two-factor-password-dialog.tsx +226 -0
- package/src/components/signed-in.tsx +20 -0
- package/src/components/signed-out.tsx +20 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/avatar.tsx +53 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/checkbox.tsx +32 -0
- package/src/components/ui/dialog.tsx +143 -0
- package/src/components/ui/drawer.tsx +135 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/form.tsx +167 -0
- package/src/components/ui/input-otp.tsx +77 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/select.tsx +185 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/tabs.tsx +66 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/user-avatar.tsx +147 -0
- package/src/components/user-button.tsx +409 -0
- package/src/components/user-view.tsx +138 -0
- package/src/hooks/use-auth-data.ts +184 -0
- package/src/hooks/use-authenticate.ts +62 -0
- package/src/hooks/use-captcha.tsx +138 -0
- package/src/hooks/use-current-organization.ts +59 -0
- package/src/hooks/use-hydrated.ts +13 -0
- package/src/hooks/use-lang.ts +32 -0
- package/src/hooks/use-success-transition.ts +51 -0
- package/src/hooks/use-theme.ts +39 -0
- package/src/index.ts +65 -0
- package/src/instantdb.ts +1 -0
- package/src/lib/auth-data-cache.ts +90 -0
- package/src/lib/auth-ui-provider.tsx +658 -0
- package/src/lib/gravatar-utils.ts +58 -0
- package/src/lib/image-utils.ts +55 -0
- package/src/lib/instantdb/model-names.ts +24 -0
- package/src/lib/instantdb/use-instant-options.ts +98 -0
- package/src/lib/instantdb/use-list-accounts.ts +38 -0
- package/src/lib/instantdb/use-list-sessions.ts +53 -0
- package/src/lib/instantdb/use-session.ts +55 -0
- package/src/lib/organization-refetcher.tsx +56 -0
- package/src/lib/social-providers.ts +144 -0
- package/src/lib/tanstack/auth-ui-provider-tanstack.tsx +49 -0
- package/src/lib/tanstack/use-tanstack-options.ts +112 -0
- package/src/lib/triplit/model-names.ts +24 -0
- package/src/lib/triplit/use-conditional-query.ts +82 -0
- package/src/lib/triplit/use-list-accounts.ts +31 -0
- package/src/lib/triplit/use-list-sessions.ts +33 -0
- package/src/lib/triplit/use-session.ts +42 -0
- package/src/lib/triplit/use-triplit-hooks.ts +68 -0
- package/src/lib/triplit/use-triplit-token.ts +44 -0
- package/src/lib/utils.ts +105 -0
- package/src/lib/view-paths.ts +55 -0
- package/src/localization/admin-error-codes.ts +20 -0
- package/src/localization/anonymous-error-codes.ts +6 -0
- package/src/localization/api-key-error-codes.ts +32 -0
- package/src/localization/auth-localization.ts +740 -0
- package/src/localization/base-error-codes.ts +27 -0
- package/src/localization/captcha-error-codes.ts +17 -0
- package/src/localization/email-otp-error-codes.ts +7 -0
- package/src/localization/generic-oauth-error-codes.ts +3 -0
- package/src/localization/haveibeenpwned-error-codes.ts +4 -0
- package/src/localization/multi-session-error-codes.ts +3 -0
- package/src/localization/organization-error-codes.ts +57 -0
- package/src/localization/passkey-error-codes.ts +10 -0
- package/src/localization/phone-number-error-codes.ts +10 -0
- package/src/localization/stripe-localization.ts +12 -0
- package/src/localization/two-factor-error-codes.ts +12 -0
- package/src/localization/username-error-codes.ts +9 -0
- package/src/server.ts +4 -0
- package/src/style.css +1 -0
- package/src/tanstack.ts +1 -0
- package/src/triplit.ts +1 -0
- package/src/types/account-options.ts +35 -0
- package/src/types/additional-fields.ts +21 -0
- package/src/types/any-auth-client.ts +6 -0
- package/src/types/api-key.ts +9 -0
- package/src/types/auth-client.ts +37 -0
- package/src/types/auth-hooks.ts +61 -0
- package/src/types/auth-mutators.ts +17 -0
- package/src/types/avatar-options.ts +29 -0
- package/src/types/captcha-options.ts +32 -0
- package/src/types/captcha-provider.ts +6 -0
- package/src/types/credentials-options.ts +32 -0
- package/src/types/delete-user-options.ts +7 -0
- package/src/types/fetch-error.ts +6 -0
- package/src/types/generic-oauth-options.ts +16 -0
- package/src/types/gravatar-options.ts +21 -0
- package/src/types/image.ts +7 -0
- package/src/types/invitation.ts +10 -0
- package/src/types/link.ts +7 -0
- package/src/types/organization-options.ts +106 -0
- package/src/types/password-validation.ts +16 -0
- package/src/types/profile.ts +15 -0
- package/src/types/refetch.ts +1 -0
- package/src/types/render-toast.ts +9 -0
- package/src/types/sign-up-options.ts +7 -0
- package/src/types/social-options.ts +16 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { AlertCircle } from "lucide-react"
|
|
4
|
+
import { useFormState } from "react-hook-form"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
import type { AuthFormClassNames } from "./auth/auth-form"
|
|
8
|
+
import { Alert, AlertDescription, AlertTitle } from "./ui/alert"
|
|
9
|
+
|
|
10
|
+
export interface FormErrorProps {
|
|
11
|
+
title?: string
|
|
12
|
+
classNames?: AuthFormClassNames
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function FormError({ title, classNames }: FormErrorProps) {
|
|
16
|
+
const { errors } = useFormState()
|
|
17
|
+
|
|
18
|
+
if (!errors.root?.message) return null
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Alert variant="destructive" className={cn(classNames?.error)}>
|
|
22
|
+
<AlertCircle className="self-center" />
|
|
23
|
+
<AlertTitle>{title || "Error"}</AlertTitle>
|
|
24
|
+
<AlertDescription>{errors.root.message}</AlertDescription>
|
|
25
|
+
</Alert>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { CheckIcon, Loader2, XIcon } from "lucide-react"
|
|
4
|
+
import { useCallback, useContext, useEffect, useMemo, useState } from "react"
|
|
5
|
+
|
|
6
|
+
import { useAuthenticate } from "../../hooks/use-authenticate"
|
|
7
|
+
import { AuthUIContext } from "../../lib/auth-ui-provider"
|
|
8
|
+
import { cn, getLocalizedError, getSearchParam } from "../../lib/utils"
|
|
9
|
+
import type { AuthLocalization } from "../../localization/auth-localization"
|
|
10
|
+
import type { SettingsCardClassNames } from "../settings/shared/settings-card"
|
|
11
|
+
import { Button } from "../ui/button"
|
|
12
|
+
import {
|
|
13
|
+
Card,
|
|
14
|
+
CardContent,
|
|
15
|
+
CardDescription,
|
|
16
|
+
CardHeader,
|
|
17
|
+
CardTitle
|
|
18
|
+
} from "../ui/card"
|
|
19
|
+
import { Skeleton } from "../ui/skeleton"
|
|
20
|
+
import { OrganizationCellView } from "./organization-cell-view"
|
|
21
|
+
|
|
22
|
+
export interface AcceptInvitationCardProps {
|
|
23
|
+
className?: string
|
|
24
|
+
classNames?: SettingsCardClassNames
|
|
25
|
+
localization?: Partial<AuthLocalization>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function AcceptInvitationCard({
|
|
29
|
+
className,
|
|
30
|
+
classNames,
|
|
31
|
+
localization: localizationProp
|
|
32
|
+
}: AcceptInvitationCardProps) {
|
|
33
|
+
const {
|
|
34
|
+
localization: contextLocalization,
|
|
35
|
+
redirectTo,
|
|
36
|
+
replace,
|
|
37
|
+
toast
|
|
38
|
+
} = useContext(AuthUIContext)
|
|
39
|
+
|
|
40
|
+
const localization = useMemo(
|
|
41
|
+
() => ({ ...contextLocalization, ...localizationProp }),
|
|
42
|
+
[contextLocalization, localizationProp]
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const { data: sessionData } = useAuthenticate()
|
|
46
|
+
const [invitationId, setInvitationId] = useState<string | null>(null)
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const invitationIdParam = getSearchParam("invitationId")
|
|
50
|
+
|
|
51
|
+
if (!invitationIdParam) {
|
|
52
|
+
toast({
|
|
53
|
+
variant: "error",
|
|
54
|
+
message: localization.INVITATION_NOT_FOUND
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
replace(redirectTo)
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setInvitationId(invitationIdParam)
|
|
62
|
+
}, [localization.INVITATION_NOT_FOUND, toast, replace, redirectTo])
|
|
63
|
+
|
|
64
|
+
if (!sessionData || !invitationId) {
|
|
65
|
+
return (
|
|
66
|
+
<AcceptInvitationSkeleton
|
|
67
|
+
className={className}
|
|
68
|
+
classNames={classNames}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<AcceptInvitationContent
|
|
75
|
+
className={className}
|
|
76
|
+
classNames={classNames}
|
|
77
|
+
localization={localization}
|
|
78
|
+
invitationId={invitationId}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function AcceptInvitationContent({
|
|
84
|
+
className,
|
|
85
|
+
classNames,
|
|
86
|
+
localization: localizationProp,
|
|
87
|
+
invitationId
|
|
88
|
+
}: AcceptInvitationCardProps & { invitationId: string }) {
|
|
89
|
+
const {
|
|
90
|
+
authClient,
|
|
91
|
+
hooks: { useInvitation },
|
|
92
|
+
localization: contextLocalization,
|
|
93
|
+
organization,
|
|
94
|
+
redirectTo,
|
|
95
|
+
replace,
|
|
96
|
+
toast
|
|
97
|
+
} = useContext(AuthUIContext)
|
|
98
|
+
|
|
99
|
+
const localization = useMemo(
|
|
100
|
+
() => ({ ...contextLocalization, ...localizationProp }),
|
|
101
|
+
[contextLocalization, localizationProp]
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
const [isRejecting, setIsRejecting] = useState(false)
|
|
105
|
+
const [isAccepting, setIsAccepting] = useState(false)
|
|
106
|
+
const isProcessing = isRejecting || isAccepting
|
|
107
|
+
|
|
108
|
+
const { data: invitation, isPending } = useInvitation({
|
|
109
|
+
query: {
|
|
110
|
+
id: invitationId
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const getRedirectTo = useCallback(
|
|
115
|
+
() => getSearchParam("redirectTo") || redirectTo,
|
|
116
|
+
[redirectTo]
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (isPending || !invitationId) return
|
|
121
|
+
|
|
122
|
+
if (!invitation) {
|
|
123
|
+
toast({
|
|
124
|
+
variant: "error",
|
|
125
|
+
message: localization.INVITATION_NOT_FOUND
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
replace(redirectTo)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (
|
|
133
|
+
invitation.status !== "pending" ||
|
|
134
|
+
new Date(invitation.expiresAt) < new Date()
|
|
135
|
+
) {
|
|
136
|
+
toast({
|
|
137
|
+
variant: "error",
|
|
138
|
+
message:
|
|
139
|
+
new Date(invitation.expiresAt) < new Date()
|
|
140
|
+
? localization.INVITATION_EXPIRED
|
|
141
|
+
: localization.INVITATION_NOT_FOUND
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
replace(redirectTo)
|
|
145
|
+
}
|
|
146
|
+
}, [
|
|
147
|
+
invitation,
|
|
148
|
+
isPending,
|
|
149
|
+
invitationId,
|
|
150
|
+
localization,
|
|
151
|
+
toast,
|
|
152
|
+
replace,
|
|
153
|
+
redirectTo
|
|
154
|
+
])
|
|
155
|
+
|
|
156
|
+
const acceptInvitation = async () => {
|
|
157
|
+
setIsAccepting(true)
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
await authClient.organization.acceptInvitation({
|
|
161
|
+
invitationId: invitationId,
|
|
162
|
+
fetchOptions: { throw: true }
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
toast({
|
|
166
|
+
variant: "success",
|
|
167
|
+
message:
|
|
168
|
+
localization.INVITATION_ACCEPTED || "Invitation accepted"
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
replace(getRedirectTo())
|
|
172
|
+
} catch (error) {
|
|
173
|
+
toast({
|
|
174
|
+
variant: "error",
|
|
175
|
+
message: getLocalizedError({ error, localization })
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
setIsAccepting(false)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const rejectInvitation = async () => {
|
|
183
|
+
setIsRejecting(true)
|
|
184
|
+
|
|
185
|
+
try {
|
|
186
|
+
await authClient.organization.rejectInvitation({
|
|
187
|
+
invitationId: invitationId,
|
|
188
|
+
fetchOptions: { throw: true }
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
toast({
|
|
192
|
+
variant: "success",
|
|
193
|
+
message: localization.INVITATION_REJECTED
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
replace(redirectTo)
|
|
197
|
+
} catch (error) {
|
|
198
|
+
toast({
|
|
199
|
+
variant: "error",
|
|
200
|
+
message: getLocalizedError({ error, localization })
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
setIsRejecting(false)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const builtInRoles = [
|
|
208
|
+
{ role: "owner", label: localization.OWNER },
|
|
209
|
+
{ role: "admin", label: localization.ADMIN },
|
|
210
|
+
{ role: "member", label: localization.MEMBER }
|
|
211
|
+
]
|
|
212
|
+
|
|
213
|
+
const roles = [...builtInRoles, ...(organization?.customRoles || [])]
|
|
214
|
+
const roleLabel =
|
|
215
|
+
roles.find((r) => r.role === invitation?.role)?.label ||
|
|
216
|
+
invitation?.role
|
|
217
|
+
|
|
218
|
+
if (!invitation)
|
|
219
|
+
return (
|
|
220
|
+
<AcceptInvitationSkeleton
|
|
221
|
+
className={className}
|
|
222
|
+
classNames={classNames}
|
|
223
|
+
/>
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<Card className={cn("w-full max-w-sm", className, classNames?.base)}>
|
|
228
|
+
<CardHeader
|
|
229
|
+
className={cn(
|
|
230
|
+
"justify-items-center text-center",
|
|
231
|
+
classNames?.header
|
|
232
|
+
)}
|
|
233
|
+
>
|
|
234
|
+
<CardTitle
|
|
235
|
+
className={cn("text-lg md:text-xl", classNames?.title)}
|
|
236
|
+
>
|
|
237
|
+
{localization.ACCEPT_INVITATION}
|
|
238
|
+
</CardTitle>
|
|
239
|
+
|
|
240
|
+
<CardDescription
|
|
241
|
+
className={cn(
|
|
242
|
+
"text-xs md:text-sm",
|
|
243
|
+
classNames?.description
|
|
244
|
+
)}
|
|
245
|
+
>
|
|
246
|
+
{localization.ACCEPT_INVITATION_DESCRIPTION}
|
|
247
|
+
</CardDescription>
|
|
248
|
+
</CardHeader>
|
|
249
|
+
|
|
250
|
+
<CardContent
|
|
251
|
+
className={cn(
|
|
252
|
+
"flex flex-col gap-6 truncate",
|
|
253
|
+
classNames?.content
|
|
254
|
+
)}
|
|
255
|
+
>
|
|
256
|
+
<Card className={cn("flex-row items-center p-4")}>
|
|
257
|
+
<OrganizationCellView
|
|
258
|
+
organization={{
|
|
259
|
+
id: invitation.organizationId,
|
|
260
|
+
name: invitation.organizationName,
|
|
261
|
+
slug: invitation.organizationSlug,
|
|
262
|
+
logo: invitation.organizationLogo,
|
|
263
|
+
createdAt: new Date()
|
|
264
|
+
}}
|
|
265
|
+
localization={localization}
|
|
266
|
+
/>
|
|
267
|
+
|
|
268
|
+
<p className="ml-auto text-muted-foreground text-sm">
|
|
269
|
+
{roleLabel}
|
|
270
|
+
</p>
|
|
271
|
+
</Card>
|
|
272
|
+
|
|
273
|
+
<div className="grid grid-cols-2 gap-3">
|
|
274
|
+
<Button
|
|
275
|
+
variant="outline"
|
|
276
|
+
className={cn(
|
|
277
|
+
classNames?.button,
|
|
278
|
+
classNames?.outlineButton
|
|
279
|
+
)}
|
|
280
|
+
onClick={rejectInvitation}
|
|
281
|
+
disabled={isProcessing}
|
|
282
|
+
>
|
|
283
|
+
{isRejecting ? (
|
|
284
|
+
<Loader2 className="animate-spin" />
|
|
285
|
+
) : (
|
|
286
|
+
<XIcon />
|
|
287
|
+
)}
|
|
288
|
+
|
|
289
|
+
{localization.REJECT}
|
|
290
|
+
</Button>
|
|
291
|
+
|
|
292
|
+
<Button
|
|
293
|
+
className={cn(
|
|
294
|
+
classNames?.button,
|
|
295
|
+
classNames?.primaryButton
|
|
296
|
+
)}
|
|
297
|
+
onClick={acceptInvitation}
|
|
298
|
+
disabled={isProcessing}
|
|
299
|
+
>
|
|
300
|
+
{isAccepting ? (
|
|
301
|
+
<Loader2 className="animate-spin" />
|
|
302
|
+
) : (
|
|
303
|
+
<CheckIcon />
|
|
304
|
+
)}
|
|
305
|
+
|
|
306
|
+
{localization.ACCEPT}
|
|
307
|
+
</Button>
|
|
308
|
+
</div>
|
|
309
|
+
</CardContent>
|
|
310
|
+
</Card>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const AcceptInvitationSkeleton = ({
|
|
315
|
+
className,
|
|
316
|
+
classNames,
|
|
317
|
+
localization
|
|
318
|
+
}: AcceptInvitationCardProps) => {
|
|
319
|
+
return (
|
|
320
|
+
<Card className={cn("w-full max-w-sm", className, classNames?.base)}>
|
|
321
|
+
<CardHeader
|
|
322
|
+
className={cn("justify-items-center", classNames?.header)}
|
|
323
|
+
>
|
|
324
|
+
<Skeleton
|
|
325
|
+
className={cn(
|
|
326
|
+
"my-1 h-5 w-full max-w-32 md:h-5.5 md:w-40",
|
|
327
|
+
classNames?.skeleton
|
|
328
|
+
)}
|
|
329
|
+
/>
|
|
330
|
+
|
|
331
|
+
<Skeleton
|
|
332
|
+
className={cn(
|
|
333
|
+
"my-0.5 h-3 w-full max-w-56 md:h-3.5 md:w-64",
|
|
334
|
+
classNames?.skeleton
|
|
335
|
+
)}
|
|
336
|
+
/>
|
|
337
|
+
</CardHeader>
|
|
338
|
+
|
|
339
|
+
<CardContent
|
|
340
|
+
className={cn(
|
|
341
|
+
"flex flex-col gap-6 truncate",
|
|
342
|
+
classNames?.content
|
|
343
|
+
)}
|
|
344
|
+
>
|
|
345
|
+
<Card className={cn("flex-row items-center p-4")}>
|
|
346
|
+
<OrganizationCellView
|
|
347
|
+
isPending
|
|
348
|
+
localization={localization}
|
|
349
|
+
/>
|
|
350
|
+
|
|
351
|
+
<Skeleton className="mt-0.5 ml-auto h-4 w-full max-w-14 shrink-2" />
|
|
352
|
+
</Card>
|
|
353
|
+
|
|
354
|
+
<div className="grid grid-cols-2 gap-3">
|
|
355
|
+
<Skeleton className="h-9 w-full" />
|
|
356
|
+
|
|
357
|
+
<Skeleton className="h-9 w-full" />
|
|
358
|
+
</div>
|
|
359
|
+
</CardContent>
|
|
360
|
+
</Card>
|
|
361
|
+
)
|
|
362
|
+
}
|