@krak-stack/auth 0.1.51 → 0.1.53
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/admin/api.group.d.ts +60 -0
- package/dist/admin/schema.d.ts +64 -0
- package/dist/admin/schema.js +41 -0
- package/dist/api.d.ts +297 -216
- package/dist/components/admin-organization-form.js +110 -69
- package/dist/components/admin-organizations.js +99 -6
- package/dist/components/admin-users.js +38 -4
- package/dist/components/auth-client-api.d.ts +60 -0
- package/dist/components/auth-client.d.ts +17 -1
- package/dist/components/auth-client.js +15 -1
- package/dist/components/auth-forms.d.ts +1 -0
- package/dist/components/auth-forms.js +309 -252
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/organization-switcher.d.ts +18 -7
- package/dist/components/organization-switcher.js +264 -189
- package/dist/components/user-button.js +197 -178
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/server/api.group.d.ts +22 -1
- package/dist/server/api.group.js +10 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/schema.d.ts +20 -0
- package/dist/server/schema.js +5 -0
- package/dist/service.d.ts +50 -0
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
3
|
-
import {
|
|
3
|
+
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
4
4
|
import {} from "@tanstack/react-table";
|
|
5
|
-
import { Effect, Schema } from "effect";
|
|
5
|
+
import { Effect, Option, Schema } from "effect";
|
|
6
6
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
7
7
|
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
8
8
|
import { createContext, useContext, useEffect, useEffectEvent, useRef, useState, } from "react";
|
|
9
9
|
import { DataTable, DataTableRelationshipCell, } from "@/components/ui/data-table";
|
|
10
|
+
import { ImageField, SelectField, SubmitButton, SubmitError, TextField, } from "@/components/ui/effect-form";
|
|
10
11
|
import { EditingLocaleSwitcher } from "@/components/ui/editing-locale-switcher";
|
|
11
12
|
import { AppBrand } from "@/components/ui/app-brand";
|
|
12
|
-
import {
|
|
13
|
+
import { FieldSet } from "@/components/ui/field";
|
|
13
14
|
import { Badge } from "@/components/ui/badge";
|
|
14
15
|
import { Button } from "@/components/ui/button";
|
|
15
16
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
@@ -33,7 +34,7 @@ const messages = {
|
|
|
33
34
|
organization_copy_id: "Copy organization ID",
|
|
34
35
|
organization_create_slug_conflict: "That organization slug is already in use. Choose a different slug.",
|
|
35
36
|
organization_create_title: "Create organization",
|
|
36
|
-
organization_edit_description: "Update the active organization's
|
|
37
|
+
organization_edit_description: "Update the active organization's localized profile.",
|
|
37
38
|
organization_invitation_cancel: "Cancel invitation",
|
|
38
39
|
organization_invitation_cancel_error: "Could not cancel the invitation.",
|
|
39
40
|
organization_invitation_accept: "Accept invitation",
|
|
@@ -62,6 +63,9 @@ const messages = {
|
|
|
62
63
|
organization_invite_member_title: "Invite a member",
|
|
63
64
|
organization_loading: "Loading...",
|
|
64
65
|
organization_location: "Location",
|
|
66
|
+
organization_parent: "Parent organization",
|
|
67
|
+
organization_parent_description: "Optionally group this organization under another organization.",
|
|
68
|
+
organization_parent_none: "No parent organization",
|
|
65
69
|
organization_icon: "Icon",
|
|
66
70
|
organization_logo: "Logo",
|
|
67
71
|
organization_logo_upload_error: "Could not upload the organization logo.",
|
|
@@ -79,7 +83,7 @@ const messages = {
|
|
|
79
83
|
organization_members_heading: "Organization members",
|
|
80
84
|
organization_members_load_error: "Could not load organization members.",
|
|
81
85
|
organization_members_title: "Members",
|
|
82
|
-
|
|
86
|
+
organization_name_required: "Enter a name in at least one language.",
|
|
83
87
|
organization_role_admin: "Admin",
|
|
84
88
|
organization_role_member: "Member",
|
|
85
89
|
organization_role_owner: "Owner",
|
|
@@ -90,10 +94,11 @@ const messages = {
|
|
|
90
94
|
organization_switcher_label: "Organization",
|
|
91
95
|
organization_switcher_manage: "Manage organization",
|
|
92
96
|
organization_switcher_no_other_organizations: "No other organizations.",
|
|
97
|
+
organization_switcher_personal: "Personal",
|
|
93
98
|
organization_translation_description: "Localized organization details stored in metadata.",
|
|
94
99
|
organization_translation_english: "English profile",
|
|
95
100
|
organization_translation_french: "French profile",
|
|
96
|
-
organization_translation_name: "
|
|
101
|
+
organization_translation_name: "Name",
|
|
97
102
|
organization_update_error: "Could not update the organization.",
|
|
98
103
|
table_empty: "No results.",
|
|
99
104
|
user_api_key_create_error: "Could not create the API key.",
|
|
@@ -120,7 +125,7 @@ const messages = {
|
|
|
120
125
|
organization_copy_id: "Copier l'ID de l'organisation",
|
|
121
126
|
organization_create_slug_conflict: "Ce slug d'organisation est déjà utilisé. Choisissez un autre slug.",
|
|
122
127
|
organization_create_title: "Créer une organisation",
|
|
123
|
-
organization_edit_description: "Mettez à jour
|
|
128
|
+
organization_edit_description: "Mettez à jour le profil localisé de l'organisation active.",
|
|
124
129
|
organization_invitation_cancel: "Annuler l'invitation",
|
|
125
130
|
organization_invitation_cancel_error: "Impossible d'annuler l'invitation.",
|
|
126
131
|
organization_invitation_accept: "Accepter l'invitation",
|
|
@@ -149,6 +154,9 @@ const messages = {
|
|
|
149
154
|
organization_invite_member_title: "Inviter un membre",
|
|
150
155
|
organization_loading: "Chargement...",
|
|
151
156
|
organization_location: "Emplacement",
|
|
157
|
+
organization_parent: "Organisation parente",
|
|
158
|
+
organization_parent_description: "Regroupez facultativement cette organisation sous une autre organisation.",
|
|
159
|
+
organization_parent_none: "Aucune organisation parente",
|
|
152
160
|
organization_icon: "Icône",
|
|
153
161
|
organization_logo: "Logo",
|
|
154
162
|
organization_logo_upload_error: "Impossible de téléverser le logo de l'organisation.",
|
|
@@ -166,7 +174,7 @@ const messages = {
|
|
|
166
174
|
organization_members_heading: "Membres de l'organisation",
|
|
167
175
|
organization_members_load_error: "Impossible de charger les membres de l'organisation.",
|
|
168
176
|
organization_members_title: "Membres",
|
|
169
|
-
|
|
177
|
+
organization_name_required: "Saisissez un nom dans au moins une langue.",
|
|
170
178
|
organization_role_admin: "Admin",
|
|
171
179
|
organization_role_member: "Membre",
|
|
172
180
|
organization_role_owner: "Propriétaire",
|
|
@@ -177,10 +185,11 @@ const messages = {
|
|
|
177
185
|
organization_switcher_label: "Organisation",
|
|
178
186
|
organization_switcher_manage: "Gérer l'organisation",
|
|
179
187
|
organization_switcher_no_other_organizations: "Aucune autre organisation.",
|
|
188
|
+
organization_switcher_personal: "Personnel",
|
|
180
189
|
organization_translation_description: "Détails localisés de l'organisation stockés dans les métadonnées.",
|
|
181
190
|
organization_translation_english: "Profil anglais",
|
|
182
191
|
organization_translation_french: "Profil français",
|
|
183
|
-
organization_translation_name: "Nom
|
|
192
|
+
organization_translation_name: "Nom",
|
|
184
193
|
organization_update_error: "Impossible de mettre à jour l'organisation.",
|
|
185
194
|
table_empty: "Aucun résultat.",
|
|
186
195
|
user_api_key_create_error: "Impossible de créer la clé API.",
|
|
@@ -281,11 +290,35 @@ const organizationApiKeysAtom = Atom.family((authClient) => Atom.family((organiz
|
|
|
281
290
|
catch: (error) => error,
|
|
282
291
|
})))));
|
|
283
292
|
const emptyOrganizationApiKeysAtom = Atom.make(Effect.succeed([]));
|
|
293
|
+
const organizationImageSchema = Schema.Union([
|
|
294
|
+
Schema.String,
|
|
295
|
+
Schema.instanceOf(File),
|
|
296
|
+
Schema.Null,
|
|
297
|
+
Schema.Undefined,
|
|
298
|
+
]);
|
|
299
|
+
const organizationFormBuilder = FormBuilder.empty
|
|
300
|
+
.addField("parentId", Schema.String)
|
|
301
|
+
.addField("slug", Schema.String)
|
|
302
|
+
.addField("enName", Schema.String)
|
|
303
|
+
.addField("enLogo", organizationImageSchema)
|
|
304
|
+
.addField("enIcon", organizationImageSchema)
|
|
305
|
+
.addField("enContactEmail", Schema.String)
|
|
306
|
+
.addField("enLocation", Schema.String)
|
|
307
|
+
.addField("frName", Schema.String)
|
|
308
|
+
.addField("frLogo", organizationImageSchema)
|
|
309
|
+
.addField("frIcon", organizationImageSchema)
|
|
310
|
+
.addField("frContactEmail", Schema.String)
|
|
311
|
+
.addField("frLocation", Schema.String);
|
|
312
|
+
const inviteMemberFormBuilder = FormBuilder.empty
|
|
313
|
+
.addField("email", Schema.NonEmptyString)
|
|
314
|
+
.addField("role", Schema.String);
|
|
315
|
+
const apiKeyFormBuilder = FormBuilder.empty.addField("name", Schema.NonEmptyString);
|
|
284
316
|
const slugify = (value) => value
|
|
285
317
|
.trim()
|
|
286
318
|
.toLowerCase()
|
|
287
319
|
.replace(/[^a-z0-9]+/g, "-")
|
|
288
320
|
.replace(/^-+|-+$/g, "");
|
|
321
|
+
const noParentOrganization = "__none__";
|
|
289
322
|
const isOrganizationSlugConflict = (error) => {
|
|
290
323
|
if (typeof error !== "object" || error === null)
|
|
291
324
|
return false;
|
|
@@ -339,12 +372,29 @@ const organizationDisplay = (organization, m, baseUrl) => {
|
|
|
339
372
|
image: assetUrl(translation?.icon || translation?.logo, baseUrl),
|
|
340
373
|
};
|
|
341
374
|
};
|
|
375
|
+
const organizationSwitcherSubtitle = (organization, subtitle, m) => organization?.userId
|
|
376
|
+
? `${m.organization_switcher_personal()} · ${subtitle}`
|
|
377
|
+
: subtitle;
|
|
378
|
+
const organizationParentOptions = (organizations, m, excludedOrganizationId) => [
|
|
379
|
+
{
|
|
380
|
+
label: m.organization_parent_none(),
|
|
381
|
+
value: noParentOrganization,
|
|
382
|
+
},
|
|
383
|
+
...organizations
|
|
384
|
+
.filter((organization) => organization.id !== excludedOrganizationId &&
|
|
385
|
+
!organization.userId &&
|
|
386
|
+
!organization.parentId)
|
|
387
|
+
.map((organization) => ({
|
|
388
|
+
label: organizationDisplay(organization, m).name,
|
|
389
|
+
value: organization.id,
|
|
390
|
+
})),
|
|
391
|
+
];
|
|
342
392
|
const organizationFormDefaults = (organization, baseUrl) => {
|
|
343
393
|
const translations = parseOrganizationMetadata(organization?.metadata).translations;
|
|
344
394
|
const en = translations.find((translation) => translation.locale === "en");
|
|
345
395
|
const fr = translations.find((translation) => translation.locale === "fr");
|
|
346
396
|
return {
|
|
347
|
-
|
|
397
|
+
parentId: organization?.parentId ?? noParentOrganization,
|
|
348
398
|
slug: organization?.slug ?? "",
|
|
349
399
|
enName: en?.name || organization?.name || "",
|
|
350
400
|
enLogo: assetUrl(en?.logo, baseUrl) || null,
|
|
@@ -365,6 +415,11 @@ const organizationLogoFromForm = async (value, m, uploadImage) => {
|
|
|
365
415
|
return assetPath(value);
|
|
366
416
|
return null;
|
|
367
417
|
};
|
|
418
|
+
const organizationNameFromForm = (value, locale) => {
|
|
419
|
+
const preferredName = locale === "fr" ? value.frName : value.enName;
|
|
420
|
+
const fallbackName = locale === "fr" ? value.enName : value.frName;
|
|
421
|
+
return preferredName.trim() || fallbackName.trim();
|
|
422
|
+
};
|
|
368
423
|
const organizationRoleLabel = (role, m) => {
|
|
369
424
|
switch (normalizeOrganizationRole(role)) {
|
|
370
425
|
case "owner":
|
|
@@ -396,7 +451,7 @@ const invitationStatusLabel = (status, m) => {
|
|
|
396
451
|
const formatOrganizationDate = (date) => new Intl.DateTimeFormat(getLocale(), { dateStyle: "medium" }).format(new Date(date));
|
|
397
452
|
const organizationMetadataFromForm = async (value, m, uploadImage) => {
|
|
398
453
|
const translations = [];
|
|
399
|
-
const enName = value.enName.trim()
|
|
454
|
+
const enName = value.enName.trim();
|
|
400
455
|
const frName = value.frName.trim();
|
|
401
456
|
const enLogo = await organizationLogoFromForm(value.enLogo, m, uploadImage);
|
|
402
457
|
const enIcon = await organizationLogoFromForm(value.enIcon, m, uploadImage);
|
|
@@ -424,7 +479,7 @@ const organizationMetadataFromForm = async (value, m, uploadImage) => {
|
|
|
424
479
|
}
|
|
425
480
|
return { translations };
|
|
426
481
|
};
|
|
427
|
-
export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, menuActions, renderUnauthenticated, locked = false, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
482
|
+
export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, menuActions, renderUnauthenticated, locked = false, organizationWhitelist, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
428
483
|
const auth = useKrakstackAuth();
|
|
429
484
|
const authClient = providedAuthClient ?? auth?.authClient;
|
|
430
485
|
if (!authClient) {
|
|
@@ -486,8 +541,10 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
486
541
|
}
|
|
487
542
|
const active = activeOrganization.data;
|
|
488
543
|
const activeName = active?.name;
|
|
544
|
+
const visibleOrganizations = organizations.data?.filter((organization) => !organizationWhitelist ||
|
|
545
|
+
organizationWhitelist.includes(organization.id)) ?? [];
|
|
489
546
|
const selectableOrganizations = !locked
|
|
490
|
-
?
|
|
547
|
+
? visibleOrganizations.filter((organization) => organization.id !== active?.id)
|
|
491
548
|
: [];
|
|
492
549
|
const hasOrganizationListItems = organizations.isPending || Boolean(organizations.error) || !locked;
|
|
493
550
|
const refreshAfterInvitationAction = async (previousActiveId) => {
|
|
@@ -504,11 +561,12 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
504
561
|
}
|
|
505
562
|
};
|
|
506
563
|
const activeDisplay = organizationDisplay(active ?? null, m, baseUrl);
|
|
564
|
+
const activeSubtitle = organizationSwitcherSubtitle(active ?? null, activeDisplay.subtitle, m);
|
|
507
565
|
return (_jsxs(OrganizationMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "ghost", className: cn("h-11 w-full justify-between gap-2 !px-1 !py-0 group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-start group-data-[collapsible=icon]:!p-0", className), children: [_jsx(AppBrand, { to: null, label: activeName
|
|
508
566
|
? activeDisplay.name
|
|
509
|
-
: m.organization_switcher_label(), subtitle:
|
|
567
|
+
: m.organization_switcher_label(), subtitle: activeSubtitle, icon: Building2, variant: "sidebar", className: "min-w-0 flex-1 !p-0 text-left group-data-[collapsible=icon]:flex-none group-data-[collapsible=icon]:justify-start", ...(activeDisplay.image
|
|
510
568
|
? { imageSrc: activeDisplay.image }
|
|
511
|
-
: {}) }), _jsx(ChevronsUpDown, { className: "text-muted-foreground size-4 shrink-0 group-data-[collapsible=icon]:hidden" })] }) }), _jsx(DropdownMenuContent, { className: "min-w-64 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: activeDisplay.name, subtitle:
|
|
569
|
+
: {}) }), _jsx(ChevronsUpDown, { className: "text-muted-foreground size-4 shrink-0 group-data-[collapsible=icon]:hidden" })] }) }), _jsx(DropdownMenuContent, { className: "min-w-64 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: activeDisplay.name, subtitle: activeSubtitle, icon: Building2, variant: "sidebar", className: "px-1 py-1.5 text-left text-sm", ...(activeDisplay.image
|
|
512
570
|
? { imageSrc: activeDisplay.image }
|
|
513
571
|
: {}) }) }), menuActions ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), menuActions] })) : null, hasOrganizationListItems ? _jsx(DropdownMenuSeparator, {}) : null, organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: m.organization_loading() })) : null, organizations.error ? (_jsx(DropdownMenuItem, { disabled: true, children: organizations.error.message })) : null, !locked && selectableOrganizations.length ? (selectableOrganizations.map((organization) => {
|
|
514
572
|
const display = organizationDisplay(organization, m, baseUrl);
|
|
@@ -520,7 +578,7 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
520
578
|
await refresh();
|
|
521
579
|
onChange?.(organization);
|
|
522
580
|
}
|
|
523
|
-
}, children: _jsx(AppBrand, { to: null, label: display.name, subtitle: display.subtitle, icon: Building2, className: "w-full text-left [&>div:first-child]:size-7", ...(display.image ? { imageSrc: display.image } : {}) }) }, organization.id));
|
|
581
|
+
}, children: _jsx(AppBrand, { to: null, label: display.name, subtitle: organizationSwitcherSubtitle(organization, display.subtitle, m), icon: Building2, className: "w-full text-left [&>div:first-child]:size-7", ...(display.image ? { imageSrc: display.image } : {}) }) }, organization.id));
|
|
524
582
|
})) : !locked && !organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: active
|
|
525
583
|
? m.organization_switcher_no_other_organizations()
|
|
526
584
|
: m.organization_switcher_empty() })) : null, !locked ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: openCreate, children: [_jsx(Plus, {}), m.organization_create_title()] }), _jsxs(DropdownMenuItem, { onClick: () => {
|
|
@@ -532,7 +590,7 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
532
590
|
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }));
|
|
533
591
|
})(), 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", onOpenChange: (open) => {
|
|
534
592
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
535
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { authClient: authClient, baseUrl: baseUrl, onCreated: async (organization) => {
|
|
593
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { authClient: authClient, baseUrl: baseUrl, organizations: visibleOrganizations, onCreated: async (organization) => {
|
|
536
594
|
setDialog(null);
|
|
537
595
|
const activeResult = await authClient.organization.setActive({
|
|
538
596
|
organizationId: organization.id,
|
|
@@ -671,14 +729,29 @@ const userInvitationRowActions = ({ m, actingInvitationId, now, onAccept, onReje
|
|
|
671
729
|
function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated, }) {
|
|
672
730
|
const m = useOrganizationMessages();
|
|
673
731
|
const uploadImage = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"), { mode: "promise" });
|
|
674
|
-
const [
|
|
732
|
+
const [defaultLocale] = useState(currentOrganizationLocale);
|
|
733
|
+
const [editingLocale, setEditingLocale] = useState(defaultLocale);
|
|
675
734
|
const defaultValues = organizationFormDefaults(organization, baseUrl);
|
|
676
|
-
const form =
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
735
|
+
const [form] = useState(() => FormReact.make(organizationFormBuilder, {
|
|
736
|
+
fields: {
|
|
737
|
+
parentId: SelectField,
|
|
738
|
+
slug: TextField,
|
|
739
|
+
enName: TextField,
|
|
740
|
+
enLogo: ImageField,
|
|
741
|
+
enIcon: ImageField,
|
|
742
|
+
enContactEmail: TextField,
|
|
743
|
+
enLocation: TextField,
|
|
744
|
+
frName: TextField,
|
|
745
|
+
frLogo: ImageField,
|
|
746
|
+
frIcon: ImageField,
|
|
747
|
+
frContactEmail: TextField,
|
|
748
|
+
frLocation: TextField,
|
|
749
|
+
},
|
|
750
|
+
onSubmit: (_, { decoded: value }) => Effect.tryPromise({
|
|
751
|
+
try: async () => {
|
|
752
|
+
const name = organizationNameFromForm(value, defaultLocale);
|
|
753
|
+
if (!name)
|
|
754
|
+
throw new Error(m.organization_name_required());
|
|
682
755
|
const slug = value.slug.trim().toLowerCase();
|
|
683
756
|
const metadata = await organizationMetadataFromForm(value, m, uploadImage);
|
|
684
757
|
const result = await authClient.organization.update({
|
|
@@ -686,142 +759,137 @@ function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated,
|
|
|
686
759
|
data: { name, slug, metadata },
|
|
687
760
|
});
|
|
688
761
|
if (result.error) {
|
|
689
|
-
|
|
690
|
-
onSubmit: {
|
|
691
|
-
form: result.error.message ?? m.organization_update_error(),
|
|
692
|
-
fields: {},
|
|
693
|
-
},
|
|
694
|
-
});
|
|
695
|
-
return;
|
|
762
|
+
throw new Error(result.error.message ?? m.organization_update_error());
|
|
696
763
|
}
|
|
697
764
|
await onUpdated();
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
},
|
|
710
|
-
});
|
|
711
|
-
return (_jsx("section", { className: "flex flex-col gap-4", children: _jsx(form.AppForm, { children: _jsxs("form", { className: "flex max-w-xl flex-col gap-4", onSubmit: (event) => {
|
|
765
|
+
return result.data;
|
|
766
|
+
},
|
|
767
|
+
catch: (cause) => cause instanceof Error
|
|
768
|
+
? cause
|
|
769
|
+
: new Error(m.organization_update_error()),
|
|
770
|
+
}),
|
|
771
|
+
}));
|
|
772
|
+
const submit = useAtomSet(form.submit);
|
|
773
|
+
const submitResult = useAtomValue(form.submit);
|
|
774
|
+
return (_jsx("section", { className: "flex flex-col gap-4", children: _jsx(form.Initialize, { defaultValues: defaultValues, children: _jsxs("form", { className: "flex max-w-xl flex-col gap-4", onSubmit: (event) => {
|
|
712
775
|
event.preventDefault();
|
|
713
776
|
event.stopPropagation();
|
|
714
|
-
|
|
715
|
-
}, children: [_jsx(form.
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
777
|
+
submit();
|
|
778
|
+
}, children: [_jsx(form.slug, { label: m.organization_slug(), required: true }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationTranslationHeader, { locale: editingLocale, editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _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: {
|
|
779
|
+
width: 175,
|
|
780
|
+
height: 50,
|
|
781
|
+
suggestedWidth: 350,
|
|
782
|
+
suggestedHeight: 100,
|
|
783
|
+
} }), _jsx(form.enIcon, { label: m.organization_icon(), size: {
|
|
784
|
+
width: 96,
|
|
785
|
+
height: 96,
|
|
786
|
+
suggestedWidth: 512,
|
|
787
|
+
suggestedHeight: 512,
|
|
788
|
+
} }), _jsx(form.enContactEmail, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" }), _jsx(form.enLocation, { label: m.organization_location() })] }), _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: {
|
|
789
|
+
width: 175,
|
|
790
|
+
height: 50,
|
|
791
|
+
suggestedWidth: 350,
|
|
792
|
+
suggestedHeight: 100,
|
|
793
|
+
} }), _jsx(form.frIcon, { label: m.organization_icon(), size: {
|
|
794
|
+
width: 96,
|
|
795
|
+
height: 96,
|
|
796
|
+
suggestedWidth: 512,
|
|
797
|
+
suggestedHeight: 512,
|
|
798
|
+
} }), _jsx(form.frContactEmail, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" }), _jsx(form.frLocation, { label: m.organization_location() })] }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) }) }));
|
|
736
799
|
}
|
|
737
|
-
function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
800
|
+
function CreateOrganizationSection({ authClient, baseUrl, organizations, onCreated, }) {
|
|
738
801
|
const m = useOrganizationMessages();
|
|
739
802
|
const uploadImage = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"), { mode: "promise" });
|
|
740
|
-
const [
|
|
803
|
+
const [defaultLocale] = useState(currentOrganizationLocale);
|
|
804
|
+
const [editingLocale, setEditingLocale] = useState(defaultLocale);
|
|
741
805
|
const defaultValues = organizationFormDefaults(undefined, baseUrl);
|
|
742
|
-
const form =
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
806
|
+
const [form] = useState(() => FormReact.make(organizationFormBuilder, {
|
|
807
|
+
fields: {
|
|
808
|
+
parentId: SelectField,
|
|
809
|
+
slug: TextField,
|
|
810
|
+
enName: TextField,
|
|
811
|
+
enLogo: ImageField,
|
|
812
|
+
enIcon: ImageField,
|
|
813
|
+
enContactEmail: TextField,
|
|
814
|
+
enLocation: TextField,
|
|
815
|
+
frName: TextField,
|
|
816
|
+
frLogo: ImageField,
|
|
817
|
+
frIcon: ImageField,
|
|
818
|
+
frContactEmail: TextField,
|
|
819
|
+
frLocation: TextField,
|
|
820
|
+
},
|
|
821
|
+
onSubmit: (_, { decoded: value }) => Effect.tryPromise({
|
|
822
|
+
try: async () => {
|
|
823
|
+
const name = organizationNameFromForm(value, defaultLocale);
|
|
824
|
+
if (!name)
|
|
825
|
+
throw new Error(m.organization_name_required());
|
|
748
826
|
const slug = (value.slug.trim() || slugify(name)).toLowerCase();
|
|
749
|
-
const metadata = await organizationMetadataFromForm({
|
|
750
|
-
...value,
|
|
751
|
-
name,
|
|
752
|
-
slug,
|
|
753
|
-
}, m, uploadImage);
|
|
827
|
+
const metadata = await organizationMetadataFromForm({ ...value, slug }, m, uploadImage);
|
|
754
828
|
const result = await authClient.organization.create({
|
|
755
829
|
name,
|
|
756
830
|
slug,
|
|
757
831
|
metadata,
|
|
832
|
+
...(value.parentId === noParentOrganization
|
|
833
|
+
? {}
|
|
834
|
+
: { parentId: value.parentId }),
|
|
758
835
|
});
|
|
759
836
|
if (result.error) {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
fields: {
|
|
764
|
-
slug: { message: m.organization_create_slug_conflict() },
|
|
765
|
-
},
|
|
766
|
-
},
|
|
767
|
-
});
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
formApi.setErrorMap({
|
|
771
|
-
onSubmit: {
|
|
772
|
-
form: result.error.message ?? m.organization_create_error(),
|
|
773
|
-
fields: {},
|
|
774
|
-
},
|
|
775
|
-
});
|
|
776
|
-
return;
|
|
837
|
+
throw new Error(isOrganizationSlugConflict(result.error)
|
|
838
|
+
? m.organization_create_slug_conflict()
|
|
839
|
+
: (result.error.message ?? m.organization_create_error()));
|
|
777
840
|
}
|
|
778
|
-
form.reset();
|
|
779
841
|
await onCreated(result.data);
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const name = useStore(form.store, (state) => state.values.name);
|
|
794
|
-
const slugIsDirty = useStore(form.store, (state) => state.fieldMeta.slug?.isDirty ?? false);
|
|
842
|
+
return result.data;
|
|
843
|
+
},
|
|
844
|
+
catch: (cause) => cause instanceof Error
|
|
845
|
+
? cause
|
|
846
|
+
: new Error(m.organization_create_error()),
|
|
847
|
+
}),
|
|
848
|
+
}));
|
|
849
|
+
const submit = useAtomSet(form.submit);
|
|
850
|
+
const submitResult = useAtomValue(form.submit);
|
|
851
|
+
const values = useAtomValue(form.values);
|
|
852
|
+
const setSlug = useAtomSet(form.getFieldAtoms(form.fields.slug).setValue);
|
|
853
|
+
const lastGeneratedSlug = useRef("");
|
|
854
|
+
const slugWasEdited = useRef(false);
|
|
795
855
|
useEffect(() => {
|
|
796
|
-
if (
|
|
797
|
-
|
|
856
|
+
if (Option.isNone(values) || slugWasEdited.current)
|
|
857
|
+
return;
|
|
858
|
+
if (values.value.slug !== lastGeneratedSlug.current) {
|
|
859
|
+
slugWasEdited.current = true;
|
|
860
|
+
return;
|
|
798
861
|
}
|
|
799
|
-
|
|
800
|
-
|
|
862
|
+
const generatedSlug = slugify(organizationNameFromForm(values.value, defaultLocale));
|
|
863
|
+
if (generatedSlug === values.value.slug)
|
|
864
|
+
return;
|
|
865
|
+
lastGeneratedSlug.current = generatedSlug;
|
|
866
|
+
setSlug(generatedSlug);
|
|
867
|
+
}, [defaultLocale, setSlug, values]);
|
|
868
|
+
return (_jsx("section", { className: "flex flex-col gap-4", children: _jsx(form.Initialize, { defaultValues: defaultValues, children: _jsxs("form", { className: "flex max-w-xl flex-col gap-4", onSubmit: (event) => {
|
|
801
869
|
event.preventDefault();
|
|
802
870
|
event.stopPropagation();
|
|
803
|
-
|
|
804
|
-
}, children: [_jsx(form.
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
871
|
+
submit();
|
|
872
|
+
}, children: [_jsx(form.slug, { label: m.organization_slug(), description: m.organization_slug_description() }), _jsx(form.parentId, { label: m.organization_parent(), description: m.organization_parent_description(), options: organizationParentOptions(organizations, m) }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationTranslationHeader, { locale: editingLocale, editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _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: {
|
|
873
|
+
width: 175,
|
|
874
|
+
height: 50,
|
|
875
|
+
suggestedWidth: 350,
|
|
876
|
+
suggestedHeight: 100,
|
|
877
|
+
} }), _jsx(form.enIcon, { label: m.organization_icon(), size: {
|
|
878
|
+
width: 96,
|
|
879
|
+
height: 96,
|
|
880
|
+
suggestedWidth: 512,
|
|
881
|
+
suggestedHeight: 512,
|
|
882
|
+
} }), _jsx(form.enContactEmail, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" }), _jsx(form.enLocation, { label: m.organization_location() })] }), _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: {
|
|
883
|
+
width: 175,
|
|
884
|
+
height: 50,
|
|
885
|
+
suggestedWidth: 350,
|
|
886
|
+
suggestedHeight: 100,
|
|
887
|
+
} }), _jsx(form.frIcon, { label: m.organization_icon(), size: {
|
|
888
|
+
width: 96,
|
|
889
|
+
height: 96,
|
|
890
|
+
suggestedWidth: 512,
|
|
891
|
+
suggestedHeight: 512,
|
|
892
|
+
} }), _jsx(form.frContactEmail, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" }), _jsx(form.frLocation, { label: m.organization_location() })] }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) }) }));
|
|
825
893
|
}
|
|
826
894
|
function OrganizationTranslationHeader({ locale, editingLocale, onEditingLocaleChange, }) {
|
|
827
895
|
const m = useOrganizationMessages();
|
|
@@ -873,28 +941,36 @@ function OrganizationMembersManager({ authClient, baseUrl, canManageMembers, org
|
|
|
873
941
|
return;
|
|
874
942
|
setLastMembersData(currentMembersData);
|
|
875
943
|
}, [currentMembersData]);
|
|
876
|
-
const inviteForm =
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const result = await authClient.organization.inviteMember({
|
|
881
|
-
email: value.email.trim(),
|
|
882
|
-
role: normalizeInvitationRole(value.role),
|
|
883
|
-
organizationId: organization.id,
|
|
884
|
-
});
|
|
885
|
-
if (result.error) {
|
|
886
|
-
formApi.setErrorMap({
|
|
887
|
-
onSubmit: {
|
|
888
|
-
form: result.error.message ?? m.organization_invite_error(),
|
|
889
|
-
fields: {},
|
|
890
|
-
},
|
|
891
|
-
});
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
894
|
-
inviteForm.reset();
|
|
895
|
-
refreshMembers();
|
|
944
|
+
const [inviteForm] = useState(() => FormReact.make(inviteMemberFormBuilder, {
|
|
945
|
+
fields: {
|
|
946
|
+
email: TextField,
|
|
947
|
+
role: SelectField,
|
|
896
948
|
},
|
|
897
|
-
|
|
949
|
+
onSubmit: (_, { decoded: value }) => Effect.tryPromise({
|
|
950
|
+
try: async () => {
|
|
951
|
+
const result = await authClient.organization.inviteMember({
|
|
952
|
+
email: value.email.trim(),
|
|
953
|
+
role: normalizeInvitationRole(value.role),
|
|
954
|
+
organizationId: organization.id,
|
|
955
|
+
});
|
|
956
|
+
if (result.error) {
|
|
957
|
+
throw new Error(result.error.message ?? m.organization_invite_error());
|
|
958
|
+
}
|
|
959
|
+
refreshMembers();
|
|
960
|
+
return result.data;
|
|
961
|
+
},
|
|
962
|
+
catch: (cause) => cause instanceof Error
|
|
963
|
+
? cause
|
|
964
|
+
: new Error(m.organization_invite_error()),
|
|
965
|
+
}),
|
|
966
|
+
}));
|
|
967
|
+
const submitInvitation = useAtomSet(inviteForm.submit);
|
|
968
|
+
const resetInvitation = useAtomSet(inviteForm.reset);
|
|
969
|
+
const inviteResult = useAtomValue(inviteForm.submit);
|
|
970
|
+
useEffect(() => {
|
|
971
|
+
if (AsyncResult.isSuccess(inviteResult))
|
|
972
|
+
resetInvitation();
|
|
973
|
+
}, [inviteResult, resetInvitation]);
|
|
898
974
|
const updateRole = async (member, role) => {
|
|
899
975
|
setError(null);
|
|
900
976
|
const nextRole = Array.isArray(role)
|
|
@@ -955,14 +1031,14 @@ function OrganizationMembersManager({ authClient, baseUrl, canManageMembers, org
|
|
|
955
1031
|
}
|
|
956
1032
|
refreshMembers();
|
|
957
1033
|
};
|
|
958
|
-
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-5", children: [canInviteMembers ? (_jsx("div", { className: "min-h-40 rounded-lg border p-4", children: _jsx(inviteForm.
|
|
1034
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-5", children: [canInviteMembers ? (_jsx("div", { className: "min-h-40 rounded-lg border p-4", children: _jsx(inviteForm.Initialize, { defaultValues: { email: "", role: "member" }, children: _jsxs("form", { className: "grid gap-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end", onSubmit: (event) => {
|
|
959
1035
|
event.preventDefault();
|
|
960
1036
|
event.stopPropagation();
|
|
961
|
-
|
|
962
|
-
}, children: [_jsxs("div", { className: "sm:col-span-3", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(UserPlus, { className: "size-4" }), m.organization_invite_member_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invite_member_description() })] }), _jsx(inviteForm.
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1037
|
+
submitInvitation();
|
|
1038
|
+
}, children: [_jsxs("div", { className: "sm:col-span-3", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(UserPlus, { className: "size-4" }), m.organization_invite_member_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invite_member_description() })] }), _jsx(inviteForm.email, { label: m.organization_member_email(), placeholder: "teammate@example.com", type: "email", required: true }), _jsx(inviteForm.role, { label: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
1039
|
+
label: organizationRoleLabel(role, m),
|
|
1040
|
+
value: role,
|
|
1041
|
+
})) }), _jsx("div", { className: "self-end", children: _jsx(SubmitButton, { form: inviteForm }) }), _jsx(SubmitError, { result: inviteResult })] }) }) })) : null, membersError ? (_jsx("p", { className: "text-destructive text-sm", children: membersError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columns: memberColumns({
|
|
966
1042
|
m,
|
|
967
1043
|
baseUrl,
|
|
968
1044
|
canChangeRoles: canManageMembers,
|
|
@@ -1108,33 +1184,32 @@ function OrganizationApiKeyManager({ authClient, organization, active, }) {
|
|
|
1108
1184
|
onSuccess: () => null,
|
|
1109
1185
|
});
|
|
1110
1186
|
const loading = keysResult._tag === "Initial";
|
|
1111
|
-
const createForm =
|
|
1112
|
-
|
|
1113
|
-
onSubmit:
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
try {
|
|
1187
|
+
const [createForm] = useState(() => FormReact.make(apiKeyFormBuilder, {
|
|
1188
|
+
fields: { name: TextField },
|
|
1189
|
+
onSubmit: (_, { decoded: value }) => Effect.tryPromise({
|
|
1190
|
+
try: async () => {
|
|
1191
|
+
setCreatedKey(null);
|
|
1117
1192
|
const created = await createApiKey({
|
|
1118
1193
|
configId: "organization",
|
|
1119
1194
|
organizationId: organization.id,
|
|
1120
1195
|
name: value.name.trim(),
|
|
1121
1196
|
}, m.user_api_key_create_error());
|
|
1122
1197
|
setCreatedKey(created.key);
|
|
1123
|
-
createForm.reset();
|
|
1124
1198
|
refreshKeys();
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1199
|
+
return created;
|
|
1200
|
+
},
|
|
1201
|
+
catch: (cause) => cause instanceof Error
|
|
1202
|
+
? cause
|
|
1203
|
+
: new Error(m.user_api_key_create_error()),
|
|
1204
|
+
}),
|
|
1205
|
+
}));
|
|
1206
|
+
const submitApiKey = useAtomSet(createForm.submit);
|
|
1207
|
+
const resetApiKey = useAtomSet(createForm.reset);
|
|
1208
|
+
const createResult = useAtomValue(createForm.submit);
|
|
1209
|
+
useEffect(() => {
|
|
1210
|
+
if (AsyncResult.isSuccess(createResult))
|
|
1211
|
+
resetApiKey();
|
|
1212
|
+
}, [createResult, resetApiKey]);
|
|
1138
1213
|
const deleteKey = async (key) => {
|
|
1139
1214
|
const result = await authClient.apiKey.delete({
|
|
1140
1215
|
configId: "organization",
|
|
@@ -1146,11 +1221,11 @@ function OrganizationApiKeyManager({ authClient, organization, active, }) {
|
|
|
1146
1221
|
}
|
|
1147
1222
|
refreshKeys();
|
|
1148
1223
|
};
|
|
1149
|
-
return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsx(createForm.
|
|
1224
|
+
return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsx(createForm.Initialize, { defaultValues: { name: "" }, children: _jsxs("form", { className: "flex max-w-xl flex-col gap-4", onSubmit: (event) => {
|
|
1150
1225
|
event.preventDefault();
|
|
1151
1226
|
event.stopPropagation();
|
|
1152
|
-
|
|
1153
|
-
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.
|
|
1227
|
+
submitApiKey();
|
|
1228
|
+
}, children: [_jsx("p", { className: "text-muted-foreground text-sm", children: m.api_key_rate_limit_notice() }), _jsx(createForm.name, { label: m.user_api_key_name(), required: true }), _jsx(SubmitError, { result: createResult }), _jsx(SubmitButton, { form: createForm })] }) }), createdKey ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(KeyRound, {}), m.user_api_key_created_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_api_key_created_description() }), _jsx("code", { className: "bg-muted overflow-x-auto rounded-md p-3 text-sm", children: createdKey })] })) : null, keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsx(Separator, {}), _jsx(DataTable, { columns: apiKeyColumns({ m }), data: keys, features: {
|
|
1154
1229
|
export: { baseName: `${organization.slug}-api-keys` },
|
|
1155
1230
|
gallery: false,
|
|
1156
1231
|
rowActions: {
|