@krak-stack/auth 0.1.14 → 0.1.15
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/client.d.ts +8 -0
- package/dist/components/organization-switcher.d.ts +13 -1
- package/dist/components/organization-switcher.js +80 -7
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +5 -1
- package/dist/server/api.d.ts +4 -0
- package/dist/server/schema.d.ts +1 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare const AuthApiClients_base: Context.ServiceClass<AuthApiClients, "@krak-s
|
|
|
24
24
|
readonly locale: "en" | "fr";
|
|
25
25
|
readonly name: string;
|
|
26
26
|
readonly logo: string | null;
|
|
27
|
+
readonly icon: string | null;
|
|
27
28
|
readonly contactEmail: string | null;
|
|
28
29
|
readonly location: string | null;
|
|
29
30
|
}[];
|
|
@@ -47,6 +48,7 @@ declare const AuthApiClients_base: Context.ServiceClass<AuthApiClients, "@krak-s
|
|
|
47
48
|
readonly locale: "en" | "fr";
|
|
48
49
|
readonly name: string;
|
|
49
50
|
readonly logo: string | null;
|
|
51
|
+
readonly icon: string | null;
|
|
50
52
|
readonly contactEmail: string | null;
|
|
51
53
|
readonly location: string | null;
|
|
52
54
|
}[];
|
|
@@ -275,6 +277,7 @@ declare const AuthApiClients_base: Context.ServiceClass<AuthApiClients, "@krak-s
|
|
|
275
277
|
readonly locale: "en" | "fr";
|
|
276
278
|
readonly name: string;
|
|
277
279
|
readonly logo: string | null;
|
|
280
|
+
readonly icon: string | null;
|
|
278
281
|
readonly contactEmail: string | null;
|
|
279
282
|
readonly location: string | null;
|
|
280
283
|
}[];
|
|
@@ -298,6 +301,7 @@ declare const AuthApiClients_base: Context.ServiceClass<AuthApiClients, "@krak-s
|
|
|
298
301
|
readonly locale: "en" | "fr";
|
|
299
302
|
readonly name: string;
|
|
300
303
|
readonly logo: string | null;
|
|
304
|
+
readonly icon: string | null;
|
|
301
305
|
readonly contactEmail: string | null;
|
|
302
306
|
readonly location: string | null;
|
|
303
307
|
}[];
|
|
@@ -555,6 +559,7 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
555
559
|
readonly locale: "en" | "fr";
|
|
556
560
|
readonly name: string;
|
|
557
561
|
readonly logo: string | null;
|
|
562
|
+
readonly icon: string | null;
|
|
558
563
|
readonly contactEmail: string | null;
|
|
559
564
|
readonly location: string | null;
|
|
560
565
|
}[];
|
|
@@ -578,6 +583,7 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
578
583
|
readonly locale: "en" | "fr";
|
|
579
584
|
readonly name: string;
|
|
580
585
|
readonly logo: string | null;
|
|
586
|
+
readonly icon: string | null;
|
|
581
587
|
readonly contactEmail: string | null;
|
|
582
588
|
readonly location: string | null;
|
|
583
589
|
}[];
|
|
@@ -804,6 +810,7 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
804
810
|
readonly locale: "en" | "fr";
|
|
805
811
|
readonly name: string;
|
|
806
812
|
readonly logo: string | null;
|
|
813
|
+
readonly icon: string | null;
|
|
807
814
|
readonly contactEmail: string | null;
|
|
808
815
|
readonly location: string | null;
|
|
809
816
|
}[];
|
|
@@ -827,6 +834,7 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
827
834
|
readonly locale: "en" | "fr";
|
|
828
835
|
readonly name: string;
|
|
829
836
|
readonly logo: string | null;
|
|
837
|
+
readonly icon: string | null;
|
|
830
838
|
readonly contactEmail: string | null;
|
|
831
839
|
readonly location: string | null;
|
|
832
840
|
}[];
|
|
@@ -7,6 +7,7 @@ declare const messages: {
|
|
|
7
7
|
readonly organization_contact_email: "Contact email";
|
|
8
8
|
readonly organization_create_description: "Create a workspace for team-based access.";
|
|
9
9
|
readonly organization_create_error: "Could not create the organization.";
|
|
10
|
+
readonly organization_create_slug_conflict: "That organization slug is already in use. Choose a different slug.";
|
|
10
11
|
readonly organization_create_title: "Create organization";
|
|
11
12
|
readonly organization_edit_description: "Update the active organization's canonical details and localized profile.";
|
|
12
13
|
readonly organization_invitation_cancel: "Cancel invitation";
|
|
@@ -32,6 +33,7 @@ declare const messages: {
|
|
|
32
33
|
readonly organization_invite_member_title: "Invite a member";
|
|
33
34
|
readonly organization_loading: "Loading...";
|
|
34
35
|
readonly organization_location: "Location";
|
|
36
|
+
readonly organization_icon: "Icon";
|
|
35
37
|
readonly organization_logo: "Logo";
|
|
36
38
|
readonly organization_logo_upload_error: "Could not upload the organization logo.";
|
|
37
39
|
readonly organization_member_email: "Email";
|
|
@@ -83,6 +85,7 @@ declare const messages: {
|
|
|
83
85
|
readonly organization_contact_email: "E-mail de contact";
|
|
84
86
|
readonly organization_create_description: "Créez un espace de travail pour l'accès en équipe.";
|
|
85
87
|
readonly organization_create_error: "Impossible de créer l'organisation.";
|
|
88
|
+
readonly organization_create_slug_conflict: "Ce slug d'organisation est déjà utilisé. Choisissez un autre slug.";
|
|
86
89
|
readonly organization_create_title: "Créer une organisation";
|
|
87
90
|
readonly organization_edit_description: "Mettez à jour les détails canoniques et le profil localisé de l'organisation active.";
|
|
88
91
|
readonly organization_invitation_cancel: "Annuler l'invitation";
|
|
@@ -108,6 +111,7 @@ declare const messages: {
|
|
|
108
111
|
readonly organization_invite_member_title: "Inviter un membre";
|
|
109
112
|
readonly organization_loading: "Chargement...";
|
|
110
113
|
readonly organization_location: "Emplacement";
|
|
114
|
+
readonly organization_icon: "Icône";
|
|
111
115
|
readonly organization_logo: "Logo";
|
|
112
116
|
readonly organization_logo_upload_error: "Impossible de téléverser le logo de l'organisation.";
|
|
113
117
|
readonly organization_member_email: "Courriel";
|
|
@@ -164,6 +168,14 @@ type OrganizationSwitcherProps = {
|
|
|
164
168
|
renderUnauthenticated?: () => ReactNode;
|
|
165
169
|
locked?: boolean;
|
|
166
170
|
messages?: OrganizationSwitcherMessages;
|
|
171
|
+
onChange?: (organization: OrganizationSummary | null) => void;
|
|
172
|
+
onCreate?: (organization: OrganizationSummary) => void;
|
|
167
173
|
};
|
|
168
|
-
|
|
174
|
+
type OrganizationSummary = {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
slug: string;
|
|
178
|
+
metadata?: unknown;
|
|
179
|
+
};
|
|
180
|
+
export declare function OrganizationSwitcher({ authClient, side, className, renderUnauthenticated, locked, messages, onChange, onCreate, }: OrganizationSwitcherProps): import("react").JSX.Element;
|
|
169
181
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useStore } from "@tanstack/react-form";
|
|
2
3
|
import {} from "@tanstack/react-table";
|
|
3
4
|
import { Schema } from "effect";
|
|
4
5
|
import { Building2, Check, ChevronsUpDown, KeyRound, Mail, PencilIcon, Plus, Trash2, UserPlus, Users, X, } from "lucide-react";
|
|
@@ -21,6 +22,7 @@ const messages = {
|
|
|
21
22
|
organization_contact_email: "Contact email",
|
|
22
23
|
organization_create_description: "Create a workspace for team-based access.",
|
|
23
24
|
organization_create_error: "Could not create the organization.",
|
|
25
|
+
organization_create_slug_conflict: "That organization slug is already in use. Choose a different slug.",
|
|
24
26
|
organization_create_title: "Create organization",
|
|
25
27
|
organization_edit_description: "Update the active organization's canonical details and localized profile.",
|
|
26
28
|
organization_invitation_cancel: "Cancel invitation",
|
|
@@ -46,6 +48,7 @@ const messages = {
|
|
|
46
48
|
organization_invite_member_title: "Invite a member",
|
|
47
49
|
organization_loading: "Loading...",
|
|
48
50
|
organization_location: "Location",
|
|
51
|
+
organization_icon: "Icon",
|
|
49
52
|
organization_logo: "Logo",
|
|
50
53
|
organization_logo_upload_error: "Could not upload the organization logo.",
|
|
51
54
|
organization_member_email: "Email",
|
|
@@ -97,6 +100,7 @@ const messages = {
|
|
|
97
100
|
organization_contact_email: "E-mail de contact",
|
|
98
101
|
organization_create_description: "Créez un espace de travail pour l'accès en équipe.",
|
|
99
102
|
organization_create_error: "Impossible de créer l'organisation.",
|
|
103
|
+
organization_create_slug_conflict: "Ce slug d'organisation est déjà utilisé. Choisissez un autre slug.",
|
|
100
104
|
organization_create_title: "Créer une organisation",
|
|
101
105
|
organization_edit_description: "Mettez à jour les détails canoniques et le profil localisé de l'organisation active.",
|
|
102
106
|
organization_invitation_cancel: "Annuler l'invitation",
|
|
@@ -122,6 +126,7 @@ const messages = {
|
|
|
122
126
|
organization_invite_member_title: "Inviter un membre",
|
|
123
127
|
organization_loading: "Chargement...",
|
|
124
128
|
organization_location: "Emplacement",
|
|
129
|
+
organization_icon: "Icône",
|
|
125
130
|
organization_logo: "Logo",
|
|
126
131
|
organization_logo_upload_error: "Impossible de téléverser le logo de l'organisation.",
|
|
127
132
|
organization_member_email: "Courriel",
|
|
@@ -193,6 +198,16 @@ const slugify = (value) => value
|
|
|
193
198
|
.toLowerCase()
|
|
194
199
|
.replace(/[^a-z0-9]+/g, "-")
|
|
195
200
|
.replace(/^-+|-+$/g, "");
|
|
201
|
+
const isOrganizationSlugConflict = (error) => {
|
|
202
|
+
if (!isRecord(error))
|
|
203
|
+
return false;
|
|
204
|
+
const code = typeof error.code === "string" ? error.code : "";
|
|
205
|
+
const message = typeof error.message === "string" ? error.message : "";
|
|
206
|
+
return [code, message].some((value) => {
|
|
207
|
+
const normalized = value.toLowerCase().replaceAll("_", " ");
|
|
208
|
+
return normalized.includes("organization already exists");
|
|
209
|
+
});
|
|
210
|
+
};
|
|
196
211
|
const nullableString = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
197
212
|
const centralAuthUrl = (path) => new URL(path, import.meta.env.VITE_KRAKSTACK_AUTH_URL).toString();
|
|
198
213
|
const parsePresignedUpload = (value, m) => {
|
|
@@ -263,11 +278,15 @@ const organizationFormDefaults = (organization) => {
|
|
|
263
278
|
enName: en?.name || organization?.name || "",
|
|
264
279
|
enLogo: null,
|
|
265
280
|
enLogoUrl: en?.logo ?? "",
|
|
281
|
+
enIcon: null,
|
|
282
|
+
enIconUrl: en?.icon ?? "",
|
|
266
283
|
enContactEmail: en?.contactEmail ?? "",
|
|
267
284
|
enLocation: en?.location ?? "",
|
|
268
285
|
frName: fr?.name ?? "",
|
|
269
286
|
frLogo: null,
|
|
270
287
|
frLogoUrl: fr?.logo ?? "",
|
|
288
|
+
frIcon: null,
|
|
289
|
+
frIconUrl: fr?.icon ?? "",
|
|
271
290
|
frContactEmail: fr?.contactEmail ?? "",
|
|
272
291
|
frLocation: fr?.location ?? "",
|
|
273
292
|
};
|
|
@@ -298,12 +317,15 @@ const organizationMetadataFromForm = async (value, m) => {
|
|
|
298
317
|
const enName = value.enName.trim() || value.name.trim();
|
|
299
318
|
const frName = value.frName.trim();
|
|
300
319
|
const enLogo = await organizationLogoFromForm(value.enLogo, value.enLogoUrl, m);
|
|
320
|
+
const enIcon = await organizationLogoFromForm(value.enIcon, value.enIconUrl, m);
|
|
301
321
|
const frLogo = await organizationLogoFromForm(value.frLogo, value.frLogoUrl, m);
|
|
322
|
+
const frIcon = await organizationLogoFromForm(value.frIcon, value.frIconUrl, m);
|
|
302
323
|
if (enName) {
|
|
303
324
|
translations.push({
|
|
304
325
|
locale: "en",
|
|
305
326
|
name: enName,
|
|
306
327
|
logo: enLogo,
|
|
328
|
+
icon: enIcon,
|
|
307
329
|
contactEmail: nullableString(value.enContactEmail),
|
|
308
330
|
location: nullableString(value.enLocation),
|
|
309
331
|
});
|
|
@@ -313,13 +335,14 @@ const organizationMetadataFromForm = async (value, m) => {
|
|
|
313
335
|
locale: "fr",
|
|
314
336
|
name: frName,
|
|
315
337
|
logo: frLogo,
|
|
338
|
+
icon: frIcon,
|
|
316
339
|
contactEmail: nullableString(value.frContactEmail),
|
|
317
340
|
location: nullableString(value.frLocation),
|
|
318
341
|
});
|
|
319
342
|
}
|
|
320
343
|
return { translations };
|
|
321
344
|
};
|
|
322
|
-
export function OrganizationSwitcher({ authClient, side = "bottom", className, renderUnauthenticated, locked = false, messages, }) {
|
|
345
|
+
export function OrganizationSwitcher({ authClient, side = "bottom", className, renderUnauthenticated, locked = false, messages, onChange, onCreate, }) {
|
|
323
346
|
const labels = organizationSwitcherMessages(messages);
|
|
324
347
|
const m = organizationMessageFns(labels);
|
|
325
348
|
const session = authClient.useSession();
|
|
@@ -370,8 +393,10 @@ export function OrganizationSwitcher({ authClient, side = "bottom", className, r
|
|
|
370
393
|
const result = await authClient.organization.setActive({
|
|
371
394
|
organizationId: previousActiveId,
|
|
372
395
|
});
|
|
373
|
-
if (!result.error)
|
|
396
|
+
if (!result.error) {
|
|
374
397
|
await refresh();
|
|
398
|
+
onChange?.(organizations.data?.find((organization) => organization.id === previousActiveId) ?? null);
|
|
399
|
+
}
|
|
375
400
|
}
|
|
376
401
|
};
|
|
377
402
|
const activeDisplay = organizationDisplay(active ?? null, m);
|
|
@@ -387,8 +412,10 @@ export function OrganizationSwitcher({ authClient, side = "bottom", className, r
|
|
|
387
412
|
const result = await authClient.organization.setActive({
|
|
388
413
|
organizationId: organization.id,
|
|
389
414
|
});
|
|
390
|
-
if (!result.error)
|
|
415
|
+
if (!result.error) {
|
|
391
416
|
await refresh();
|
|
417
|
+
onChange?.(organization);
|
|
418
|
+
}
|
|
392
419
|
}, children: _jsx(AppBrand, { to: null, label: display.name, subtitle: display.subtitle, icon: Building2, className: "w-full text-left [&>div:first-child]:size-7", ...(display.logo ? { imageSrc: display.logo } : {}) }) }, organization.id));
|
|
393
420
|
})) : !locked && !organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: active
|
|
394
421
|
? m.organization_switcher_no_other_organizations()
|
|
@@ -397,9 +424,15 @@ export function OrganizationSwitcher({ authClient, side = "bottom", className, r
|
|
|
397
424
|
void loadUserInvitations();
|
|
398
425
|
}, children: [_jsx(Mail, {}), _jsxs("span", { className: "flex flex-1 items-center justify-between gap-3", children: [m.organization_user_invitations_title(), userInvitations.length ? (_jsx(Badge, { variant: "secondary", children: userInvitations.length })) : null] })] }), activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })] })) : null] }) })] }), _jsx(Dialog, { open: dialog === "create", onOpenChange: (open) => {
|
|
399
426
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
400
|
-
}, 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, onCreated: async () => {
|
|
401
|
-
|
|
427
|
+
}, 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, onCreated: async (organization) => {
|
|
428
|
+
onCreate?.(organization);
|
|
402
429
|
setDialog(null);
|
|
430
|
+
const activeResult = await authClient.organization.setActive({
|
|
431
|
+
organizationId: organization.id,
|
|
432
|
+
});
|
|
433
|
+
await refresh();
|
|
434
|
+
if (!activeResult.error)
|
|
435
|
+
onChange?.(organization);
|
|
403
436
|
} })] }) }), _jsx(Dialog, { open: dialog === "manage", onOpenChange: (open) => {
|
|
404
437
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
405
438
|
}, 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_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(EditOrganizationSection, { authClient: authClient, organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
@@ -516,17 +549,37 @@ function EditOrganizationSection({ authClient, organization, onUpdated, }) {
|
|
|
516
549
|
event.stopPropagation();
|
|
517
550
|
form.handleSubmit();
|
|
518
551
|
}, children: [_jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.organization_name(), required: true })) }), _jsx(form.AppField, { name: "slug", children: (field) => (_jsx(field.TextField, { label: m.organization_slug(), required: true })) }), _jsx(Separator, { className: "my-2" }), editingLocale === "en" ? (_jsxs(_Fragment, { children: [_jsx(OrganizationTranslationHeader, { locale: "en", editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _jsx(form.AppField, { name: "enName", children: (field) => (_jsx(field.TextField, { label: m.organization_translation_name(), required: true })) }), _jsx(form.AppField, { name: "enLogo", children: (field) => (_jsx(field.ImageField, { label: m.organization_logo(), defaultImageUrl: defaultValues.enLogoUrl, size: {
|
|
552
|
+
width: 175,
|
|
553
|
+
height: 50,
|
|
554
|
+
suggestedWidth: 350,
|
|
555
|
+
suggestedHeight: 100,
|
|
556
|
+
} })) }), _jsx(form.AppField, { name: "enIcon", children: (field) => (_jsx(field.ImageField, { label: m.organization_icon(), defaultImageUrl: defaultValues.enIconUrl, size: {
|
|
519
557
|
width: 96,
|
|
520
558
|
height: 96,
|
|
521
559
|
suggestedWidth: 512,
|
|
522
560
|
suggestedHeight: 512,
|
|
523
561
|
} })) }), _jsx(form.AppField, { name: "enContactEmail", children: (field) => (_jsx(field.TextField, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" })) }), _jsx(form.AppField, { name: "enLocation", children: (field) => (_jsx(field.TextField, { label: m.organization_location() })) })] })) : (_jsxs(_Fragment, { children: [_jsx(OrganizationTranslationHeader, { locale: "fr", editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _jsx(form.AppField, { name: "frName", children: (field) => (_jsx(field.TextField, { label: m.organization_translation_name() })) }), _jsx(form.AppField, { name: "frLogo", children: (field) => (_jsx(field.ImageField, { label: m.organization_logo(), defaultImageUrl: defaultValues.frLogoUrl, size: {
|
|
562
|
+
width: 175,
|
|
563
|
+
height: 50,
|
|
564
|
+
suggestedWidth: 350,
|
|
565
|
+
suggestedHeight: 100,
|
|
566
|
+
} })) }), _jsx(form.AppField, { name: "frIcon", children: (field) => (_jsx(field.ImageField, { label: m.organization_icon(), defaultImageUrl: defaultValues.frIconUrl, size: {
|
|
524
567
|
width: 96,
|
|
525
568
|
height: 96,
|
|
526
569
|
suggestedWidth: 512,
|
|
527
570
|
suggestedHeight: 512,
|
|
528
571
|
} })) }), _jsx(form.AppField, { name: "frContactEmail", children: (field) => (_jsx(field.TextField, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" })) }), _jsx(form.AppField, { name: "frLocation", children: (field) => (_jsx(field.TextField, { label: m.organization_location() })) })] })), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }) }));
|
|
529
572
|
}
|
|
573
|
+
function CreateOrganizationSlugAutoFill({ form, }) {
|
|
574
|
+
const name = useStore(form.store, (state) => state.values.name);
|
|
575
|
+
const slugIsDirty = useStore(form.store, (state) => state.fieldMeta.slug?.isDirty ?? false);
|
|
576
|
+
useEffect(() => {
|
|
577
|
+
if (!slugIsDirty) {
|
|
578
|
+
form.setFieldValue("slug", slugify(name), { dontUpdateMeta: true });
|
|
579
|
+
}
|
|
580
|
+
}, [form, name, slugIsDirty]);
|
|
581
|
+
return null;
|
|
582
|
+
}
|
|
530
583
|
function CreateOrganizationSection({ authClient, onCreated, }) {
|
|
531
584
|
const m = useOrganizationMessages();
|
|
532
585
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
@@ -548,6 +601,16 @@ function CreateOrganizationSection({ authClient, onCreated, }) {
|
|
|
548
601
|
metadata,
|
|
549
602
|
});
|
|
550
603
|
if (result.error) {
|
|
604
|
+
if (isOrganizationSlugConflict(result.error)) {
|
|
605
|
+
formApi.setErrorMap({
|
|
606
|
+
onSubmit: {
|
|
607
|
+
fields: {
|
|
608
|
+
slug: { message: m.organization_create_slug_conflict() },
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
});
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
551
614
|
formApi.setErrorMap({
|
|
552
615
|
onSubmit: {
|
|
553
616
|
form: result.error.message ?? m.organization_create_error(),
|
|
@@ -557,19 +620,29 @@ function CreateOrganizationSection({ authClient, onCreated, }) {
|
|
|
557
620
|
return;
|
|
558
621
|
}
|
|
559
622
|
form.reset();
|
|
560
|
-
await onCreated();
|
|
623
|
+
await onCreated(result.data);
|
|
561
624
|
},
|
|
562
625
|
});
|
|
563
626
|
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) => {
|
|
564
627
|
event.preventDefault();
|
|
565
628
|
event.stopPropagation();
|
|
566
629
|
form.handleSubmit();
|
|
567
|
-
}, children: [_jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.organization_name(), required: true })) }), _jsx(form.AppField, { name: "slug", children: (field) => (_jsx(field.TextField, { label: m.organization_slug(), description: m.organization_slug_description() })) }), _jsx(Separator, { className: "my-2" }), editingLocale === "en" ? (_jsxs(_Fragment, { children: [_jsx(OrganizationTranslationHeader, { locale: "en", editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _jsx(form.AppField, { name: "enName", children: (field) => (_jsx(field.TextField, { label: m.organization_translation_name(), required: true })) }), _jsx(form.AppField, { name: "enLogo", children: (field) => (_jsx(field.ImageField, { label: m.organization_logo(), defaultImageUrl: defaultValues.enLogoUrl, size: {
|
|
630
|
+
}, children: [_jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.organization_name(), required: true })) }), _jsx(form.AppField, { name: "slug", children: (field) => (_jsx(field.TextField, { label: m.organization_slug(), description: m.organization_slug_description() })) }), _jsx(CreateOrganizationSlugAutoFill, { form: form }), _jsx(Separator, { className: "my-2" }), editingLocale === "en" ? (_jsxs(_Fragment, { children: [_jsx(OrganizationTranslationHeader, { locale: "en", editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _jsx(form.AppField, { name: "enName", children: (field) => (_jsx(field.TextField, { label: m.organization_translation_name(), required: true })) }), _jsx(form.AppField, { name: "enLogo", children: (field) => (_jsx(field.ImageField, { label: m.organization_logo(), defaultImageUrl: defaultValues.enLogoUrl, size: {
|
|
631
|
+
width: 175,
|
|
632
|
+
height: 50,
|
|
633
|
+
suggestedWidth: 350,
|
|
634
|
+
suggestedHeight: 100,
|
|
635
|
+
} })) }), _jsx(form.AppField, { name: "enIcon", children: (field) => (_jsx(field.ImageField, { label: m.organization_icon(), defaultImageUrl: defaultValues.enIconUrl, size: {
|
|
568
636
|
width: 96,
|
|
569
637
|
height: 96,
|
|
570
638
|
suggestedWidth: 512,
|
|
571
639
|
suggestedHeight: 512,
|
|
572
640
|
} })) }), _jsx(form.AppField, { name: "enContactEmail", children: (field) => (_jsx(field.TextField, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" })) }), _jsx(form.AppField, { name: "enLocation", children: (field) => (_jsx(field.TextField, { label: m.organization_location() })) })] })) : (_jsxs(_Fragment, { children: [_jsx(OrganizationTranslationHeader, { locale: "fr", editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _jsx(form.AppField, { name: "frName", children: (field) => (_jsx(field.TextField, { label: m.organization_translation_name() })) }), _jsx(form.AppField, { name: "frLogo", children: (field) => (_jsx(field.ImageField, { label: m.organization_logo(), defaultImageUrl: defaultValues.frLogoUrl, size: {
|
|
641
|
+
width: 175,
|
|
642
|
+
height: 50,
|
|
643
|
+
suggestedWidth: 350,
|
|
644
|
+
suggestedHeight: 100,
|
|
645
|
+
} })) }), _jsx(form.AppField, { name: "frIcon", children: (field) => (_jsx(field.ImageField, { label: m.organization_icon(), defaultImageUrl: defaultValues.frIconUrl, size: {
|
|
573
646
|
width: 96,
|
|
574
647
|
height: 96,
|
|
575
648
|
suggestedWidth: 512,
|
package/dist/schema.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const OrganizationTranslation: Schema.Struct<{
|
|
|
27
27
|
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
28
28
|
readonly name: Schema.String;
|
|
29
29
|
readonly logo: Schema.NullOr<Schema.String>;
|
|
30
|
+
readonly icon: Schema.NullOr<Schema.String>;
|
|
30
31
|
readonly contactEmail: Schema.NullOr<Schema.String>;
|
|
31
32
|
readonly location: Schema.NullOr<Schema.String>;
|
|
32
33
|
}>;
|
|
@@ -35,6 +36,7 @@ export declare const OrganizationMetadata: Schema.Struct<{
|
|
|
35
36
|
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
36
37
|
readonly name: Schema.String;
|
|
37
38
|
readonly logo: Schema.NullOr<Schema.String>;
|
|
39
|
+
readonly icon: Schema.NullOr<Schema.String>;
|
|
38
40
|
readonly contactEmail: Schema.NullOr<Schema.String>;
|
|
39
41
|
readonly location: Schema.NullOr<Schema.String>;
|
|
40
42
|
}>>;
|
|
@@ -49,6 +51,7 @@ export declare const Organization: Schema.Struct<{
|
|
|
49
51
|
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
50
52
|
readonly name: Schema.String;
|
|
51
53
|
readonly logo: Schema.NullOr<Schema.String>;
|
|
54
|
+
readonly icon: Schema.NullOr<Schema.String>;
|
|
52
55
|
readonly contactEmail: Schema.NullOr<Schema.String>;
|
|
53
56
|
readonly location: Schema.NullOr<Schema.String>;
|
|
54
57
|
}>>;
|
package/dist/schema.js
CHANGED
|
@@ -70,6 +70,7 @@ export const OrganizationTranslation = Schema.Struct({
|
|
|
70
70
|
locale: OrganizationLocale,
|
|
71
71
|
name: Schema.String,
|
|
72
72
|
logo: Schema.NullOr(Schema.String),
|
|
73
|
+
icon: Schema.NullOr(Schema.String),
|
|
73
74
|
contactEmail: Schema.NullOr(Schema.String),
|
|
74
75
|
location: Schema.NullOr(Schema.String),
|
|
75
76
|
}).annotate({
|
|
@@ -81,6 +82,7 @@ export const OrganizationTranslation = Schema.Struct({
|
|
|
81
82
|
locale: "en",
|
|
82
83
|
name: "KrakStack",
|
|
83
84
|
logo: "https://example.com/logo.svg",
|
|
85
|
+
icon: "https://example.com/icon.png",
|
|
84
86
|
contactEmail: "team@example.com",
|
|
85
87
|
location: "Montreal, QC",
|
|
86
88
|
},
|
|
@@ -91,7 +93,7 @@ export const OrganizationMetadata = Schema.Struct({
|
|
|
91
93
|
}).annotate({
|
|
92
94
|
identifier: "OrganizationMetadata",
|
|
93
95
|
title: "Organization metadata",
|
|
94
|
-
description: "Localized names, logos, contact emails, and locations stored on an organization record.",
|
|
96
|
+
description: "Localized names, logos, icons, contact emails, and locations stored on an organization record.",
|
|
95
97
|
examples: [
|
|
96
98
|
{
|
|
97
99
|
translations: [
|
|
@@ -99,6 +101,7 @@ export const OrganizationMetadata = Schema.Struct({
|
|
|
99
101
|
locale: "en",
|
|
100
102
|
name: "KrakStack",
|
|
101
103
|
logo: "https://example.com/logo.svg",
|
|
104
|
+
icon: "https://example.com/icon.png",
|
|
102
105
|
contactEmail: "team@example.com",
|
|
103
106
|
location: "Montreal, QC",
|
|
104
107
|
},
|
|
@@ -129,6 +132,7 @@ export const Organization = Schema.Struct({
|
|
|
129
132
|
locale: "en",
|
|
130
133
|
name: "KrakStack",
|
|
131
134
|
logo: null,
|
|
135
|
+
icon: null,
|
|
132
136
|
contactEmail: "team@example.com",
|
|
133
137
|
location: "Montreal, QC",
|
|
134
138
|
},
|
package/dist/server/api.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export declare const ServerOrganizationsApiGroup: HttpApiGroup.HttpApiGroup<"ser
|
|
|
46
46
|
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
47
47
|
readonly name: import("effect/Schema").String;
|
|
48
48
|
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
49
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
49
50
|
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
50
51
|
readonly location: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
51
52
|
}>>;
|
|
@@ -65,6 +66,7 @@ export declare const ServerOrganizationsApiGroup: HttpApiGroup.HttpApiGroup<"ser
|
|
|
65
66
|
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
66
67
|
readonly name: import("effect/Schema").String;
|
|
67
68
|
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
69
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
68
70
|
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
69
71
|
readonly location: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
70
72
|
}>>;
|
|
@@ -155,6 +157,7 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
155
157
|
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
156
158
|
readonly name: import("effect/Schema").String;
|
|
157
159
|
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
160
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
158
161
|
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
159
162
|
readonly location: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
160
163
|
}>>;
|
|
@@ -174,6 +177,7 @@ export declare const ServerApi: HttpApi.HttpApi<"ServerApi", HttpApiGroup.HttpAp
|
|
|
174
177
|
readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
|
|
175
178
|
readonly name: import("effect/Schema").String;
|
|
176
179
|
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
180
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
177
181
|
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
178
182
|
readonly location: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
179
183
|
}>>;
|
package/dist/server/schema.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare const ServerOrganizationsResponse: Schema.Struct<{
|
|
|
47
47
|
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
48
48
|
readonly name: Schema.String;
|
|
49
49
|
readonly logo: Schema.NullOr<Schema.String>;
|
|
50
|
+
readonly icon: Schema.NullOr<Schema.String>;
|
|
50
51
|
readonly contactEmail: Schema.NullOr<Schema.String>;
|
|
51
52
|
readonly location: Schema.NullOr<Schema.String>;
|
|
52
53
|
}>>;
|