@krak-stack/auth 0.2.7 → 0.2.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/components/member-required.js +21 -23
- package/dist/components/organization-switcher.d.ts +4 -2
- package/dist/components/organization-switcher.js +77 -96
- package/dist/components/user-button.d.ts +22 -6
- package/dist/components/user-button.js +171 -120
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/proxy-origin.d.ts +17 -0
- package/dist/server/proxy-origin.js +41 -0
- package/dist/server/proxy.d.ts +5 -3
- package/dist/server/proxy.js +16 -11
- package/dist/server/schema.d.ts +5 -0
- package/dist/server/schema.js +5 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAtomSet, useAtomSuspense } from "@effect/atom-react";
|
|
2
|
+
import { useAtomRefresh, useAtomSet, useAtomSuspense, } from "@effect/atom-react";
|
|
3
3
|
import { Effect, Schema } from "effect";
|
|
4
4
|
import { Atom } from "effect/unstable/reactivity";
|
|
5
5
|
import { Check, Loader2, Mail, ShieldAlert } from "lucide-react";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { Button } from "@/components/ui/button";
|
|
8
8
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
9
9
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card";
|
|
@@ -102,7 +102,7 @@ const accessAtom = Atom.family((baseUrl) => Atom.family((key) => {
|
|
|
102
102
|
userId: Schema.optional(Schema.String),
|
|
103
103
|
}));
|
|
104
104
|
const { locale, organizationId } = Schema.decodeUnknownSync(AccessKey)(key);
|
|
105
|
-
return Atom.keepAlive(authClientApi(baseUrl).runtime.atom((get) => Effect.gen(function* () {
|
|
105
|
+
return Atom.optimistic(Atom.keepAlive(authClientApi(baseUrl).runtime.atom((get) => Effect.gen(function* () {
|
|
106
106
|
const client = yield* authHttpClient(baseUrl);
|
|
107
107
|
const allowed = yield* client.auth
|
|
108
108
|
.organizationSetActive({ payload: { organizationId } })
|
|
@@ -111,9 +111,6 @@ const accessAtom = Atom.family((baseUrl) => Atom.family((key) => {
|
|
|
111
111
|
: Effect.fail(error)));
|
|
112
112
|
if (allowed) {
|
|
113
113
|
get.refresh(authSessionAtom(baseUrl));
|
|
114
|
-
yield* get.result(authSessionAtom(baseUrl), {
|
|
115
|
-
suspendOnWaiting: true,
|
|
116
|
-
});
|
|
117
114
|
return { allowed: true };
|
|
118
115
|
}
|
|
119
116
|
const profileKey = JSON.stringify({ locale, organizationId });
|
|
@@ -135,10 +132,9 @@ const accessAtom = Atom.family((baseUrl) => Atom.family((key) => {
|
|
|
135
132
|
organization,
|
|
136
133
|
invitation: invitations.find((item) => invitationMatches(item, organizationId)) ?? null,
|
|
137
134
|
};
|
|
138
|
-
})));
|
|
135
|
+
}))));
|
|
139
136
|
}));
|
|
140
|
-
const accessAtomKey = ({
|
|
141
|
-
authRefreshVersion,
|
|
137
|
+
const accessAtomKey = ({ baseUrl, locale, organizationId, userId, }) => JSON.stringify({
|
|
142
138
|
baseUrl,
|
|
143
139
|
locale,
|
|
144
140
|
organizationId,
|
|
@@ -151,25 +147,24 @@ export function MemberRequired({ organizationId, contactEmail, children, message
|
|
|
151
147
|
const locale = auth?.locale;
|
|
152
148
|
const refreshAuth = auth?.refreshAuth;
|
|
153
149
|
const session = useAtomSuspense(authSessionAtom(baseUrl), {
|
|
154
|
-
suspendOnWaiting:
|
|
150
|
+
suspendOnWaiting: false,
|
|
155
151
|
}).value;
|
|
156
152
|
const userId = session?.user.id;
|
|
157
153
|
const currentAccessKey = accessAtomKey({
|
|
158
|
-
authRefreshVersion,
|
|
159
154
|
baseUrl,
|
|
160
155
|
locale,
|
|
161
156
|
organizationId,
|
|
162
157
|
userId,
|
|
163
158
|
});
|
|
164
|
-
|
|
165
|
-
if (allowedAccessKey === currentAccessKey)
|
|
166
|
-
return _jsx(_Fragment, { children: children });
|
|
167
|
-
return (_jsx(MemberRequiredGate, { accessKey: currentAccessKey, baseUrl: baseUrl, contactEmail: contactEmail, locale: locale, messages: messages, onAccessAllowed: () => setAllowedAccessKey(currentAccessKey), organizationId: organizationId, refreshAuth: refreshAuth, children: children }));
|
|
159
|
+
return (_jsx(MemberRequiredGate, { accessKey: currentAccessKey, authRefreshVersion: authRefreshVersion, baseUrl: baseUrl, contactEmail: contactEmail, locale: locale, messages: messages, organizationId: organizationId, refreshAuth: refreshAuth, children: children }));
|
|
168
160
|
}
|
|
169
|
-
function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale, messages,
|
|
161
|
+
function MemberRequiredGate({ accessKey, authRefreshVersion, baseUrl, contactEmail, children, locale, messages, organizationId, refreshAuth, }) {
|
|
170
162
|
const m = labels(locale, messages);
|
|
171
|
-
const
|
|
172
|
-
|
|
163
|
+
const queryAtom = accessAtom(baseUrl)(accessKey);
|
|
164
|
+
const refreshAccess = useAtomRefresh(queryAtom);
|
|
165
|
+
const lastAuthRefreshVersion = useRef(authRefreshVersion);
|
|
166
|
+
const accessResult = useAtomSuspense(queryAtom, {
|
|
167
|
+
suspendOnWaiting: false,
|
|
173
168
|
});
|
|
174
169
|
const acceptInvitationMutation = useAtomSet(acceptInvitationAtom(baseUrl));
|
|
175
170
|
const [accepting, setAccepting] = useState(false);
|
|
@@ -177,10 +172,11 @@ function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale
|
|
|
177
172
|
const access = accessResult.value;
|
|
178
173
|
const invitationNow = useInvitationExpirationClock(access.allowed || !access.invitation ? [] : [access.invitation]);
|
|
179
174
|
useEffect(() => {
|
|
180
|
-
if (
|
|
175
|
+
if (lastAuthRefreshVersion.current === authRefreshVersion)
|
|
181
176
|
return;
|
|
182
|
-
|
|
183
|
-
|
|
177
|
+
lastAuthRefreshVersion.current = authRefreshVersion;
|
|
178
|
+
refreshAccess();
|
|
179
|
+
}, [authRefreshVersion, refreshAccess]);
|
|
184
180
|
if (access.allowed)
|
|
185
181
|
return _jsx(_Fragment, { children: children });
|
|
186
182
|
const { invitation, organization } = access;
|
|
@@ -204,8 +200,10 @@ function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale
|
|
|
204
200
|
: m.member_required_accept_error);
|
|
205
201
|
},
|
|
206
202
|
onSuccess: () => {
|
|
207
|
-
refreshAuth
|
|
208
|
-
|
|
203
|
+
if (refreshAuth)
|
|
204
|
+
refreshAuth();
|
|
205
|
+
else
|
|
206
|
+
refreshAccess();
|
|
209
207
|
setAccepting(false);
|
|
210
208
|
},
|
|
211
209
|
});
|
|
@@ -85,13 +85,14 @@ declare const messages: {
|
|
|
85
85
|
readonly organization_role_owner: "Owner";
|
|
86
86
|
readonly organization_role_support: "Support";
|
|
87
87
|
readonly organization_slug: "Slug";
|
|
88
|
+
readonly organization_slug_identifier_description: "A unique, URL-friendly identifier for your organization.";
|
|
88
89
|
readonly organization_slug_description: "Leave blank to generate one from the name.";
|
|
89
90
|
readonly organization_switcher_empty: "You do not belong to any organizations yet.";
|
|
90
91
|
readonly organization_switcher_label: "Organization";
|
|
91
92
|
readonly organization_switcher_manage: "Manage organization";
|
|
92
93
|
readonly organization_switcher_no_other_organizations: "No other organizations.";
|
|
93
94
|
readonly organization_switcher_personal: "Personal";
|
|
94
|
-
readonly organization_translation_description: "
|
|
95
|
+
readonly organization_translation_description: "Customize your organization’s name, logo, and icon for each language.";
|
|
95
96
|
readonly organization_translation_name: "Name";
|
|
96
97
|
readonly organization_update_error: "Could not update the organization.";
|
|
97
98
|
readonly table_empty: "No results.";
|
|
@@ -223,13 +224,14 @@ declare const messages: {
|
|
|
223
224
|
readonly organization_role_owner: "Propriétaire";
|
|
224
225
|
readonly organization_role_support: "Support";
|
|
225
226
|
readonly organization_slug: "Slug";
|
|
227
|
+
readonly organization_slug_identifier_description: "Un identifiant unique pour votre organisation, adapté aux URL.";
|
|
226
228
|
readonly organization_slug_description: "Laissez vide pour en générer un à partir du nom.";
|
|
227
229
|
readonly organization_switcher_empty: "Vous n'appartenez encore à aucune organisation.";
|
|
228
230
|
readonly organization_switcher_label: "Organisation";
|
|
229
231
|
readonly organization_switcher_manage: "Gérer l'organisation";
|
|
230
232
|
readonly organization_switcher_no_other_organizations: "Aucune autre organisation.";
|
|
231
233
|
readonly organization_switcher_personal: "Personnel";
|
|
232
|
-
readonly organization_translation_description: "
|
|
234
|
+
readonly organization_translation_description: "Personnalisez le nom, le logo et l’icône de votre organisation pour chaque langue.";
|
|
233
235
|
readonly organization_translation_name: "Nom";
|
|
234
236
|
readonly organization_update_error: "Impossible de mettre à jour l'organisation.";
|
|
235
237
|
readonly table_empty: "Aucun résultat.";
|
|
@@ -13,7 +13,7 @@ import { FieldSet } from "@/components/ui/field";
|
|
|
13
13
|
import { Badge } from "@/components/ui/badge";
|
|
14
14
|
import { Button } from "@/components/ui/button";
|
|
15
15
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
16
|
-
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
16
|
+
import { Dialog, DialogContent, DialogFooter, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
17
17
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
18
18
|
import { Separator } from "@/components/ui/separator";
|
|
19
19
|
import { OrganizationEmail, OrganizationAddress, OrganizationMetadata, OrganizationPhone, OrganizationSocial, OrganizationTranslation, OrganizationWebsite, decodeOrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
@@ -116,13 +116,14 @@ const messages = {
|
|
|
116
116
|
organization_role_owner: "Owner",
|
|
117
117
|
organization_role_support: "Support",
|
|
118
118
|
organization_slug: "Slug",
|
|
119
|
+
organization_slug_identifier_description: "A unique, URL-friendly identifier for your organization.",
|
|
119
120
|
organization_slug_description: "Leave blank to generate one from the name.",
|
|
120
121
|
organization_switcher_empty: "You do not belong to any organizations yet.",
|
|
121
122
|
organization_switcher_label: "Organization",
|
|
122
123
|
organization_switcher_manage: "Manage organization",
|
|
123
124
|
organization_switcher_no_other_organizations: "No other organizations.",
|
|
124
125
|
organization_switcher_personal: "Personal",
|
|
125
|
-
organization_translation_description: "
|
|
126
|
+
organization_translation_description: "Customize your organization’s name, logo, and icon for each language.",
|
|
126
127
|
organization_translation_name: "Name",
|
|
127
128
|
organization_update_error: "Could not update the organization.",
|
|
128
129
|
table_empty: "No results.",
|
|
@@ -254,13 +255,14 @@ const messages = {
|
|
|
254
255
|
organization_role_owner: "Propriétaire",
|
|
255
256
|
organization_role_support: "Support",
|
|
256
257
|
organization_slug: "Slug",
|
|
258
|
+
organization_slug_identifier_description: "Un identifiant unique pour votre organisation, adapté aux URL.",
|
|
257
259
|
organization_slug_description: "Laissez vide pour en générer un à partir du nom.",
|
|
258
260
|
organization_switcher_empty: "Vous n'appartenez encore à aucune organisation.",
|
|
259
261
|
organization_switcher_label: "Organisation",
|
|
260
262
|
organization_switcher_manage: "Gérer l'organisation",
|
|
261
263
|
organization_switcher_no_other_organizations: "Aucune autre organisation.",
|
|
262
264
|
organization_switcher_personal: "Personnel",
|
|
263
|
-
organization_translation_description: "
|
|
265
|
+
organization_translation_description: "Personnalisez le nom, le logo et l’icône de votre organisation pour chaque langue.",
|
|
264
266
|
organization_translation_name: "Nom",
|
|
265
267
|
organization_update_error: "Impossible de mettre à jour l'organisation.",
|
|
266
268
|
table_empty: "Aucun résultat.",
|
|
@@ -499,20 +501,6 @@ const organizationDisplay = (organization, m, baseUrl) => {
|
|
|
499
501
|
const organizationSwitcherSubtitle = (organization, subtitle, m) => organization?.userId
|
|
500
502
|
? `${m.organization_switcher_personal()} · ${subtitle}`
|
|
501
503
|
: subtitle;
|
|
502
|
-
const organizationParentOptions = (organizations, m, excludedOrganizationId) => [
|
|
503
|
-
{
|
|
504
|
-
label: m.organization_parent_none(),
|
|
505
|
-
value: noParentOrganization,
|
|
506
|
-
},
|
|
507
|
-
...organizations
|
|
508
|
-
.filter((organization) => organization.id !== excludedOrganizationId &&
|
|
509
|
-
!organization.userId &&
|
|
510
|
-
!organization.parentId)
|
|
511
|
-
.map((organization) => ({
|
|
512
|
-
label: organizationDisplay(organization, m).name,
|
|
513
|
-
value: organization.id,
|
|
514
|
-
})),
|
|
515
|
-
];
|
|
516
504
|
const organizationFormDefaults = (organization, baseUrl) => {
|
|
517
505
|
const metadata = parseOrganizationMetadata(organization?.metadata);
|
|
518
506
|
const translations = metadata.translations;
|
|
@@ -874,25 +862,25 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
874
862
|
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }));
|
|
875
863
|
})(), canUpdateOrganization ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] })) : null, _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), canManageApiKeys ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })) : null] })) : null] }) })] })), _jsx(Dialog, { open: dialog === "create" && canCreateOrganization, onOpenChange: (open) => {
|
|
876
864
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
877
|
-
}, children:
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
865
|
+
}, children: _jsx(CreateOrganizationSection, { header: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() }), _jsx("div", { className: "pt-2", children: _jsx(EditingLocaleSwitcher, { value: editingOrganizationLocale, onValueChange: setEditingOrganizationLocale }) })] }), baseUrl: baseUrl, editingLocale: editingOrganizationLocale, onCreated: async (organization) => {
|
|
866
|
+
setDialog(null);
|
|
867
|
+
let activated = false;
|
|
868
|
+
try {
|
|
869
|
+
await Effect.runPromise(setActiveOrganization(organization.id));
|
|
870
|
+
activated = true;
|
|
871
|
+
notifyAuthChange();
|
|
872
|
+
}
|
|
873
|
+
catch {
|
|
874
|
+
// Creation succeeded even if activating the organization did not.
|
|
875
|
+
}
|
|
876
|
+
await refresh();
|
|
877
|
+
if (activated) {
|
|
878
|
+
onCreate?.(organization);
|
|
879
|
+
onChange?.(organization);
|
|
880
|
+
}
|
|
881
|
+
} }) }), _jsx(Dialog, { open: dialog === "manage" && canUpdateOrganization, onOpenChange: (open) => {
|
|
894
882
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
895
|
-
}, children:
|
|
883
|
+
}, children: activeOrganization && canUpdateOrganization ? (_jsx(EditOrganizationSection, { header: _jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() }), _jsx("div", { className: "pt-2", children: _jsx(EditingLocaleSwitcher, { value: editingOrganizationLocale, onValueChange: setEditingOrganizationLocale }) })] }), baseUrl: baseUrl, editingLocale: editingOrganizationLocale, organization: activeOrganization, onUpdated: refresh })) : null }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
896
884
|
setDialog((current) => open ? "members" : current === "members" ? null : current);
|
|
897
885
|
}, children: _jsx(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: activeOrganization ? (_jsx(OrganizationMembersManager, { baseUrl: baseUrl, canManageMembers: canManageApiKeys, organization: activeOrganization, currentUserId: session.user.id, active: dialog === "members", onLeft: async () => {
|
|
898
886
|
setDialog(null);
|
|
@@ -900,7 +888,7 @@ export function OrganizationSwitcher({ baseUrl: providedBaseUrl, side = "bottom"
|
|
|
900
888
|
onChange?.(null);
|
|
901
889
|
} })) : null }) }), _jsx(Dialog, { open: dialog === "apiKeys" && canManageApiKeys, onOpenChange: (open) => {
|
|
902
890
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
903
|
-
}, children: _jsx(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-
|
|
891
|
+
}, children: _jsx(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-[calc(100%-2rem)]", children: activeOrganization ? (_jsx(OrganizationApiKeyManager, { baseUrl: baseUrl, organization: activeOrganization, active: dialog === "apiKeys" && canManageApiKeys, permissionLabels: auth?.accessLabels ?? undefined, permissions: apiKeyPermissions ??
|
|
904
892
|
auth?.access?.apiKeyPermissions.organization ??
|
|
905
893
|
{} })) : null }) }), _jsx(Dialog, { open: dialog === "invitations" && canViewOrganizationInvitations, onOpenChange: (open) => {
|
|
906
894
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
@@ -1022,7 +1010,7 @@ const userInvitationRowActions = ({ m, actingInvitationId, now, onAccept, onReje
|
|
|
1022
1010
|
onClick: onReject,
|
|
1023
1011
|
},
|
|
1024
1012
|
];
|
|
1025
|
-
function EditOrganizationSection({ baseUrl, editingLocale, organization, onUpdated, }) {
|
|
1013
|
+
function EditOrganizationSection({ header, baseUrl, editingLocale, organization, onUpdated, }) {
|
|
1026
1014
|
const m = useOrganizationMessages();
|
|
1027
1015
|
const [defaultLocale] = useState(currentOrganizationLocale);
|
|
1028
1016
|
const defaultValues = organizationFormDefaults(organization, baseUrl);
|
|
@@ -1059,33 +1047,33 @@ function EditOrganizationSection({ baseUrl, editingLocale, organization, onUpdat
|
|
|
1059
1047
|
}));
|
|
1060
1048
|
const submit = useAtomSet(form.submit);
|
|
1061
1049
|
const submitResult = useAtomValue(form.submit);
|
|
1062
|
-
return (_jsx(
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1050
|
+
return (_jsx(form.Initialize, { defaultValues: defaultValues, children: _jsx("form", { onSubmit: (event) => {
|
|
1051
|
+
event.preventDefault();
|
|
1052
|
+
event.stopPropagation();
|
|
1053
|
+
submit();
|
|
1054
|
+
}, children: _jsxs(DialogContent, { className: "grid max-h-[85vh] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden sm:max-w-2xl", children: [_jsx("div", { className: "pb-6", children: header }), _jsxs("div", { className: "-mx-6 flex min-h-0 flex-col gap-4 overflow-y-auto px-6 pb-6", children: [_jsxs(OrganizationFormSection, { title: m.organization_profile(), description: m.organization_translation_description(), children: [_jsxs(FieldSet, { disabled: editingLocale !== "en", className: editingLocale === "en" ? "contents" : "hidden", children: [_jsx(form.enName, { label: m.organization_translation_name() }), _jsx(form.enLogo, { label: m.organization_logo(), size: {
|
|
1055
|
+
width: 175,
|
|
1056
|
+
height: 50,
|
|
1057
|
+
suggestedWidth: 350,
|
|
1058
|
+
suggestedHeight: 100,
|
|
1059
|
+
} }), _jsx(form.enIcon, { label: m.organization_icon(), size: {
|
|
1060
|
+
width: 96,
|
|
1061
|
+
height: 96,
|
|
1062
|
+
suggestedWidth: 512,
|
|
1063
|
+
suggestedHeight: 512,
|
|
1064
|
+
} })] }), _jsxs(FieldSet, { disabled: editingLocale !== "fr", className: editingLocale === "fr" ? "contents" : "hidden", children: [_jsx(form.frName, { label: m.organization_translation_name() }), _jsx(form.frLogo, { label: m.organization_logo(), size: {
|
|
1065
|
+
width: 175,
|
|
1066
|
+
height: 50,
|
|
1067
|
+
suggestedWidth: 350,
|
|
1068
|
+
suggestedHeight: 100,
|
|
1069
|
+
} }), _jsx(form.frIcon, { label: m.organization_icon(), size: {
|
|
1070
|
+
width: 96,
|
|
1071
|
+
height: 96,
|
|
1072
|
+
suggestedWidth: 512,
|
|
1073
|
+
suggestedHeight: 512,
|
|
1074
|
+
} })] })] }), _jsx(Separator, { className: "my-2" }), _jsx(form.slug, { label: m.organization_slug(), description: m.organization_slug_identifier_description(), required: true }), _jsx(Separator, { className: "my-2" }), _jsxs(OrganizationFormSection, { title: m.organization_contact(), children: [_jsx(OrganizationContactGroup, { title: m.organization_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationFormSection, { title: m.organization_address(), children: _jsx(form.addresses, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
|
|
1087
1075
|
}
|
|
1088
|
-
function CreateOrganizationSection({ baseUrl, editingLocale,
|
|
1076
|
+
function CreateOrganizationSection({ header, baseUrl, editingLocale, onCreated, }) {
|
|
1089
1077
|
const m = useOrganizationMessages();
|
|
1090
1078
|
const [defaultLocale] = useState(currentOrganizationLocale);
|
|
1091
1079
|
const defaultValues = organizationFormDefaults(undefined, baseUrl);
|
|
@@ -1100,14 +1088,7 @@ function CreateOrganizationSection({ baseUrl, editingLocale, organizations, onCr
|
|
|
1100
1088
|
const client = yield* authHttpClient(baseUrl);
|
|
1101
1089
|
const metadata = yield* organizationMetadataFromForm({ ...value, slug }, m, (input) => client.authExtra.uploadUserImage(input));
|
|
1102
1090
|
const normalizedMetadata = yield* normalizeOrganizationMetadata(metadata);
|
|
1103
|
-
const createPayload =
|
|
1104
|
-
? { name, slug, metadata: normalizedMetadata }
|
|
1105
|
-
: {
|
|
1106
|
-
name,
|
|
1107
|
-
slug,
|
|
1108
|
-
metadata: normalizedMetadata,
|
|
1109
|
-
parentId: value.parentId,
|
|
1110
|
-
};
|
|
1091
|
+
const createPayload = { name, slug, metadata: normalizedMetadata };
|
|
1111
1092
|
const created = yield* client.auth
|
|
1112
1093
|
.organizationCreate({ payload: createPayload })
|
|
1113
1094
|
.pipe(Effect.mapError((cause) => new Error(isOrganizationSlugConflict(cause)
|
|
@@ -1142,31 +1123,31 @@ function CreateOrganizationSection({ baseUrl, editingLocale, organizations, onCr
|
|
|
1142
1123
|
lastGeneratedSlug.current = generatedSlug;
|
|
1143
1124
|
setSlug(generatedSlug);
|
|
1144
1125
|
}, [defaultLocale, setSlug, values]);
|
|
1145
|
-
return (_jsx(
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1126
|
+
return (_jsx(form.Initialize, { defaultValues: defaultValues, children: _jsx("form", { onSubmit: (event) => {
|
|
1127
|
+
event.preventDefault();
|
|
1128
|
+
event.stopPropagation();
|
|
1129
|
+
submit();
|
|
1130
|
+
}, children: _jsxs(DialogContent, { className: "grid max-h-[85vh] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden sm:max-w-2xl", children: [_jsx("div", { className: "pb-6", children: header }), _jsxs("div", { className: "-mx-6 flex min-h-0 flex-col gap-4 overflow-y-auto px-6 pb-6", children: [_jsxs(OrganizationFormSection, { title: m.organization_profile(), description: m.organization_translation_description(), children: [_jsxs(FieldSet, { disabled: editingLocale !== "en", className: editingLocale === "en" ? "contents" : "hidden", children: [_jsx(form.enName, { label: m.organization_translation_name() }), _jsx(form.enLogo, { label: m.organization_logo(), size: {
|
|
1131
|
+
width: 175,
|
|
1132
|
+
height: 50,
|
|
1133
|
+
suggestedWidth: 350,
|
|
1134
|
+
suggestedHeight: 100,
|
|
1135
|
+
} }), _jsx(form.enIcon, { label: m.organization_icon(), size: {
|
|
1136
|
+
width: 96,
|
|
1137
|
+
height: 96,
|
|
1138
|
+
suggestedWidth: 512,
|
|
1139
|
+
suggestedHeight: 512,
|
|
1140
|
+
} })] }), _jsxs(FieldSet, { disabled: editingLocale !== "fr", className: editingLocale === "fr" ? "contents" : "hidden", children: [_jsx(form.frName, { label: m.organization_translation_name() }), _jsx(form.frLogo, { label: m.organization_logo(), size: {
|
|
1141
|
+
width: 175,
|
|
1142
|
+
height: 50,
|
|
1143
|
+
suggestedWidth: 350,
|
|
1144
|
+
suggestedHeight: 100,
|
|
1145
|
+
} }), _jsx(form.frIcon, { label: m.organization_icon(), size: {
|
|
1146
|
+
width: 96,
|
|
1147
|
+
height: 96,
|
|
1148
|
+
suggestedWidth: 512,
|
|
1149
|
+
suggestedHeight: 512,
|
|
1150
|
+
} })] })] }), _jsx(Separator, { className: "my-2" }), _jsx(form.slug, { label: m.organization_slug(), description: `${m.organization_slug_identifier_description()} ${m.organization_slug_description()}` }), _jsx(Separator, { className: "my-2" }), _jsxs(OrganizationFormSection, { title: m.organization_contact(), children: [_jsx(OrganizationContactGroup, { title: m.organization_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationFormSection, { title: m.organization_address(), children: _jsx(form.addresses, { locale: editingLocale, messages: organizationContactFieldMessages(m) }) })] }), _jsx(DialogFooter, { className: "-mx-6 -mb-6 border-t px-6 py-4", children: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) })] }) }) }));
|
|
1170
1151
|
}
|
|
1171
1152
|
function OrganizationFormSection({ children, description, title, }) {
|
|
1172
1153
|
return (_jsxs("section", { className: "flex flex-col gap-4", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: title }), description ? (_jsx("p", { className: "text-muted-foreground text-sm", children: description })) : null] }), children] }));
|
|
@@ -6,10 +6,13 @@ declare const messages: {
|
|
|
6
6
|
readonly en: {
|
|
7
7
|
readonly table_empty: "No results.";
|
|
8
8
|
readonly user_account_cancel: "Cancel";
|
|
9
|
+
readonly user_account_back: "Back";
|
|
10
|
+
readonly user_two_factor_manage: "Manage";
|
|
11
|
+
readonly user_account_change: "Change";
|
|
9
12
|
readonly user_account_confirm_revoke: "Revoke account";
|
|
10
13
|
readonly user_account_connected: "Connected";
|
|
11
14
|
readonly user_account_current_password: "Current password";
|
|
12
|
-
readonly user_account_google_connect: "
|
|
15
|
+
readonly user_account_google_connect: "Set up";
|
|
13
16
|
readonly user_account_google_description: "Use your Google account as a sign-in option.";
|
|
14
17
|
readonly user_account_google_link_error: "Could not connect Google.";
|
|
15
18
|
readonly user_account_google_title: "Google";
|
|
@@ -24,15 +27,19 @@ declare const messages: {
|
|
|
24
27
|
readonly user_account_password_connected_description: "Password sign-in is enabled for this account.";
|
|
25
28
|
readonly user_account_password_description: "Use an email and password as a sign-in option.";
|
|
26
29
|
readonly user_account_password_set: "Set password";
|
|
30
|
+
readonly user_account_password_setup: "Set up";
|
|
27
31
|
readonly user_account_password_set_error: "Could not set your password.";
|
|
28
32
|
readonly user_account_password_title: "Password";
|
|
29
33
|
readonly user_account_password_verify_error: "Could not verify your password.";
|
|
30
34
|
readonly user_account_revoke: "Revoke";
|
|
31
35
|
readonly user_account_revoke_description: "Revoke {provider} from this account. You will not be able to use it to sign in unless you connect it again.";
|
|
32
36
|
readonly user_account_revoke_error: "Could not revoke this account.";
|
|
33
|
-
readonly user_accounts_description: "
|
|
37
|
+
readonly user_accounts_description: "Manage your password and connected accounts.";
|
|
34
38
|
readonly user_accounts_load_error: "Could not load connected accounts.";
|
|
35
|
-
readonly user_accounts_title: "
|
|
39
|
+
readonly user_accounts_title: "Sign-in methods";
|
|
40
|
+
readonly user_account_email_otp_title: "Email OTP";
|
|
41
|
+
readonly user_account_email_otp_status: "Always available";
|
|
42
|
+
readonly user_account_email_otp_description: "Sign in with a one-time code sent to your email.";
|
|
36
43
|
readonly user_api_key_copied: "Copied";
|
|
37
44
|
readonly user_api_key_copy: "Copy";
|
|
38
45
|
readonly user_api_key_back: "Back";
|
|
@@ -123,6 +130,7 @@ declare const messages: {
|
|
|
123
130
|
readonly user_two_factor_disabled_message: "Two-factor authentication is disabled.";
|
|
124
131
|
readonly user_two_factor_enable_error: "Could not start two-factor setup.";
|
|
125
132
|
readonly user_two_factor_enable_submit: "Enable";
|
|
133
|
+
readonly user_confirm_password: "Confirm password";
|
|
126
134
|
readonly user_two_factor_enabled: "Enabled";
|
|
127
135
|
readonly user_two_factor_enabled_message: "Two-factor authentication is enabled.";
|
|
128
136
|
readonly user_two_factor_scan_description: "Add this account to your authenticator app, then enter the generated code below.";
|
|
@@ -133,10 +141,13 @@ declare const messages: {
|
|
|
133
141
|
readonly fr: {
|
|
134
142
|
readonly table_empty: "Aucun résultat.";
|
|
135
143
|
readonly user_account_cancel: "Annuler";
|
|
144
|
+
readonly user_account_back: "Retour";
|
|
145
|
+
readonly user_two_factor_manage: "Gérer";
|
|
146
|
+
readonly user_account_change: "Modifier";
|
|
136
147
|
readonly user_account_confirm_revoke: "Révoquer le compte";
|
|
137
148
|
readonly user_account_connected: "Connecté";
|
|
138
149
|
readonly user_account_current_password: "Mot de passe actuel";
|
|
139
|
-
readonly user_account_google_connect: "
|
|
150
|
+
readonly user_account_google_connect: "Configurer";
|
|
140
151
|
readonly user_account_google_description: "Utilisez votre compte Google comme option de connexion.";
|
|
141
152
|
readonly user_account_google_link_error: "Impossible de connecter Google.";
|
|
142
153
|
readonly user_account_google_title: "Google";
|
|
@@ -151,15 +162,19 @@ declare const messages: {
|
|
|
151
162
|
readonly user_account_password_connected_description: "La connexion par mot de passe est activée pour ce compte.";
|
|
152
163
|
readonly user_account_password_description: "Utilisez un courriel et un mot de passe comme option de connexion.";
|
|
153
164
|
readonly user_account_password_set: "Définir le mot de passe";
|
|
165
|
+
readonly user_account_password_setup: "Configurer";
|
|
154
166
|
readonly user_account_password_set_error: "Impossible de définir votre mot de passe.";
|
|
155
167
|
readonly user_account_password_title: "Mot de passe";
|
|
156
168
|
readonly user_account_password_verify_error: "Impossible de vérifier votre mot de passe.";
|
|
157
169
|
readonly user_account_revoke: "Révoquer";
|
|
158
170
|
readonly user_account_revoke_description: "Révoquez {provider} de ce compte. Vous ne pourrez plus l'utiliser pour vous connecter, sauf si vous le reconnectez.";
|
|
159
171
|
readonly user_account_revoke_error: "Impossible de révoquer ce compte.";
|
|
160
|
-
readonly user_accounts_description: "
|
|
172
|
+
readonly user_accounts_description: "Gérez votre mot de passe et vos comptes connectés.";
|
|
161
173
|
readonly user_accounts_load_error: "Impossible de charger les comptes connectés.";
|
|
162
|
-
readonly user_accounts_title: "
|
|
174
|
+
readonly user_accounts_title: "Méthodes de connexion";
|
|
175
|
+
readonly user_account_email_otp_title: "Code à usage unique par e-mail";
|
|
176
|
+
readonly user_account_email_otp_status: "Toujours disponible";
|
|
177
|
+
readonly user_account_email_otp_description: "Connectez-vous avec un code à usage unique envoyé à votre adresse e-mail.";
|
|
163
178
|
readonly user_api_key_copied: "Copié";
|
|
164
179
|
readonly user_api_key_copy: "Copier";
|
|
165
180
|
readonly user_api_key_back: "Retour";
|
|
@@ -250,6 +265,7 @@ declare const messages: {
|
|
|
250
265
|
readonly user_two_factor_disabled_message: "L'authentification à deux facteurs est désactivée.";
|
|
251
266
|
readonly user_two_factor_enable_error: "Impossible de démarrer la configuration à deux facteurs.";
|
|
252
267
|
readonly user_two_factor_enable_submit: "Activer";
|
|
268
|
+
readonly user_confirm_password: "Confirmer le mot de passe";
|
|
253
269
|
readonly user_two_factor_enabled: "Activée";
|
|
254
270
|
readonly user_two_factor_enabled_message: "L'authentification à deux facteurs est activée.";
|
|
255
271
|
readonly user_two_factor_scan_description: "Ajoutez ce compte à votre application d'authentification, puis saisissez le code généré ci-dessous.";
|