@krak-stack/auth 0.2.0 → 0.2.2
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/access.d.ts +1 -3
- package/dist/access.js +1 -3
- package/dist/admin/api.group.d.ts +36 -36
- package/dist/admin/api.group.js +13 -13
- package/dist/api.d.ts +2109 -865
- package/dist/auth/api.group.d.ts +664 -106
- package/dist/auth/api.group.js +8 -8
- package/dist/auth/schema.d.ts +537 -70
- package/dist/auth/schema.js +26 -10
- package/dist/components/admin-organization-form.js +1 -0
- package/dist/components/admin-organizations.d.ts +4 -5
- package/dist/components/admin-organizations.js +34 -31
- package/dist/components/admin-users.d.ts +5 -6
- package/dist/components/admin-users.js +51 -50
- package/dist/components/api-key-edit-form.js +2 -1
- package/dist/components/auth-atoms.d.ts +213 -103
- package/dist/components/auth-client-api.d.ts +1412 -2371
- package/dist/components/auth-client-api.js +11 -7
- package/dist/components/auth-forms.js +6 -1
- package/dist/components/auth-provider.d.ts +13 -13
- package/dist/components/contact-fields.d.ts +40 -0
- package/dist/components/contact-fields.js +86 -0
- package/dist/components/member-required.js +2 -2
- package/dist/components/organization-switcher.js +101 -193
- package/dist/components/user-button.d.ts +73 -0
- package/dist/components/user-button.js +179 -29
- package/dist/extra/api.group.d.ts +19 -19
- package/dist/extra/api.group.js +3 -3
- package/dist/extra/schema.d.ts +1 -2
- package/dist/extra/schema.js +1 -2
- package/dist/query.js +5 -5
- package/dist/schema.d.ts +279 -12
- package/dist/schema.js +162 -42
- package/dist/server/api.group.d.ts +157 -29
- package/dist/server/api.group.js +12 -12
- package/dist/server/schema.d.ts +64 -0
- package/dist/service.d.ts +3380 -2446
- package/package.json +4 -4
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createElement as _createElement } from "react";
|
|
2
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
4
3
|
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
@@ -7,17 +6,15 @@ import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
|
7
6
|
import { ArrowLeft, Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
8
7
|
import { createContext, useContext, useEffect, useEffectEvent, useRef, useState, } from "react";
|
|
9
8
|
import { DataTable, DataTableRelationshipCell, } from "@krak-stack/registry/data-table";
|
|
10
|
-
import {
|
|
9
|
+
import { CheckboxField, ImageField, SelectField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
11
10
|
import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
|
|
12
11
|
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
13
|
-
import {
|
|
14
|
-
import { Input } from "@/components/ui/input";
|
|
12
|
+
import { FieldSet } from "@/components/ui/field";
|
|
15
13
|
import { Badge } from "@/components/ui/badge";
|
|
16
14
|
import { Button } from "@/components/ui/button";
|
|
17
15
|
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
18
16
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
19
17
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
20
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select";
|
|
21
18
|
import { Separator } from "@/components/ui/separator";
|
|
22
19
|
import { OrganizationEmail, OrganizationAddress, OrganizationMetadata, OrganizationPhone, OrganizationSocial, OrganizationTranslation, OrganizationWebsite, decodeOrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
23
20
|
import { isOrganizationRole, normalizeOrganizationRole, normalizeOrganizationRoles, organizationRoles, parseRoleList, } from "../roles.js";
|
|
@@ -28,6 +25,7 @@ import { parseApiKeyReferrers } from "./api-key.js";
|
|
|
28
25
|
import { ApiKeyPermissions } from "./api-key-permissions.js";
|
|
29
26
|
import { ApiKeyRateLimit, apiKeyUsagePercent } from "./api-key-rate-limit.js";
|
|
30
27
|
import { ApiKeyReferrers, apiKeyReferrers } from "./api-key-referrers.js";
|
|
28
|
+
import { ContactAddressesField, ContactEmailsField, ContactPhonesField, ContactSocialsField, ContactWebsitesField, } from "./contact-fields.js";
|
|
31
29
|
import { useOpenedOnce } from "./hooks.js";
|
|
32
30
|
import { invitationDisplayStatus, isInvitationExpired, useInvitationExpirationClock, } from "./invitation-expiration.js";
|
|
33
31
|
import { ExtraUploadedAsset } from "../extra/schema.js";
|
|
@@ -332,6 +330,25 @@ const organizationMessageFns = (labels) => {
|
|
|
332
330
|
};
|
|
333
331
|
const OrganizationMessagesContext = createContext(organizationMessageFns(organizationSwitcherMessages()));
|
|
334
332
|
const useOrganizationMessages = () => useContext(OrganizationMessagesContext);
|
|
333
|
+
const organizationContactFieldMessages = (m) => ({
|
|
334
|
+
addAddress: m.organization_address_add(),
|
|
335
|
+
addEmail: m.organization_contact_add_email(),
|
|
336
|
+
addPhone: m.organization_contact_add_phone(),
|
|
337
|
+
addSocial: m.organization_contact_add_social(),
|
|
338
|
+
addWebsite: m.organization_contact_add_website(),
|
|
339
|
+
country: m.organization_address_country(),
|
|
340
|
+
email: m.organization_contact_email_type(),
|
|
341
|
+
extension: m.organization_contact_extension(),
|
|
342
|
+
label: m.organization_contact_label(),
|
|
343
|
+
locality: m.organization_address_locality(),
|
|
344
|
+
phone: m.organization_contact_phone_type(),
|
|
345
|
+
platform: m.organization_contact_platform(),
|
|
346
|
+
postalCode: m.organization_address_postal_code(),
|
|
347
|
+
region: m.organization_address_region(),
|
|
348
|
+
remove: m.organization_contact_remove(),
|
|
349
|
+
street: m.organization_address_street(),
|
|
350
|
+
url: m.organization_contact_url(),
|
|
351
|
+
});
|
|
335
352
|
const normalizeInvitationRole = (role) => {
|
|
336
353
|
const normalized = normalizeOrganizationRole(role);
|
|
337
354
|
return normalized === "support" ? "member" : normalized;
|
|
@@ -390,126 +407,14 @@ const organizationFormBuilder = FormBuilder.empty
|
|
|
390
407
|
.addField("frName", Schema.String)
|
|
391
408
|
.addField("frLogo", organizationImageSchema)
|
|
392
409
|
.addField("frIcon", organizationImageSchema);
|
|
393
|
-
const socialPlatform = (value) => {
|
|
394
|
-
switch (value) {
|
|
395
|
-
case "facebook":
|
|
396
|
-
case "github":
|
|
397
|
-
case "instagram":
|
|
398
|
-
case "linkedin":
|
|
399
|
-
case "tiktok":
|
|
400
|
-
case "x":
|
|
401
|
-
case "youtube":
|
|
402
|
-
return value;
|
|
403
|
-
default:
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
const contactLabel = (translations, locale) => translations?.find((translation) => translation.locale === locale)?.label ??
|
|
408
|
-
"";
|
|
409
|
-
const contactTranslations = (translations, locale, label) => [
|
|
410
|
-
...(translations ?? []).filter((translation) => translation.locale !== locale),
|
|
411
|
-
...(label ? [{ locale, label }] : []),
|
|
412
|
-
];
|
|
413
|
-
const EmailsField = ({ field, props }) => {
|
|
414
|
-
const m = useOrganizationMessages();
|
|
415
|
-
return (_jsx(RepeatableContactField, { addLabel: m.organization_contact_add_email(), emptyValue: {
|
|
416
|
-
email: "",
|
|
417
|
-
translations: [{ locale: props.locale, label: "" }],
|
|
418
|
-
}, error: Option.isSome(field.error) ? field.error.value : undefined, path: field.path, values: field.value, onChange: field.onChange, render: (contact, index, update) => (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(ContactInput, { id: `${field.path}-${index}-email`, label: m.organization_contact_email_type(), placeholder: "team@example.com", type: "email", value: contact.email, onBlur: field.onBlur, onChange: (email) => update({ ...contact, email }) }), _jsx(ContactLabelInput, { id: `${field.path}-${index}-label`, locale: props.locale, translations: contact.translations, onBlur: field.onBlur, onChange: (translations) => update({
|
|
419
|
-
...contact,
|
|
420
|
-
translations,
|
|
421
|
-
}) })] })) }));
|
|
422
|
-
};
|
|
423
|
-
const PhonesField = ({ field, props }) => {
|
|
424
|
-
const m = useOrganizationMessages();
|
|
425
|
-
return (_jsx(RepeatableContactField, { addLabel: m.organization_contact_add_phone(), emptyValue: {
|
|
426
|
-
number: "",
|
|
427
|
-
translations: [{ locale: props.locale, label: "" }],
|
|
428
|
-
}, error: Option.isSome(field.error) ? field.error.value : undefined, path: field.path, values: field.value, onChange: field.onChange, render: (phone, index, update) => (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(ContactInput, { id: `${field.path}-${index}-number`, label: m.organization_contact_phone_type(), placeholder: "+1 514 555 0100", type: "tel", value: phone.number, onBlur: field.onBlur, onChange: (number) => update({ ...phone, number }) }), _jsx(ContactInput, { id: `${field.path}-${index}-extension`, label: m.organization_contact_extension(), value: phone.extension ?? "", onBlur: field.onBlur, onChange: (extension) => update({
|
|
429
|
-
...phone,
|
|
430
|
-
...(extension ? { extension } : { extension: undefined }),
|
|
431
|
-
}) }), _jsx(ContactLabelInput, { id: `${field.path}-${index}-label`, locale: props.locale, translations: phone.translations, onBlur: field.onBlur, onChange: (translations) => update({
|
|
432
|
-
...phone,
|
|
433
|
-
translations,
|
|
434
|
-
}) })] })) }));
|
|
435
|
-
};
|
|
436
|
-
function ContactInput({ className, id, label, onBlur, onChange, placeholder, type = "text", value, }) {
|
|
437
|
-
return (_jsxs("div", { className: className, children: [_jsx(FieldLabel, { htmlFor: id, children: label }), _jsx(Input, { id: id, className: "mt-2", value: value, type: type, placeholder: placeholder, onBlur: onBlur, onChange: (event) => onChange(event.target.value) })] }));
|
|
438
|
-
}
|
|
439
|
-
function ContactLabelInput({ id, locale, onBlur, onChange, translations, }) {
|
|
440
|
-
const m = useOrganizationMessages();
|
|
441
|
-
return (_jsx(ContactInput, { id: id, label: m.organization_contact_label(), value: contactLabel(translations, locale), onBlur: onBlur, onChange: (label) => onChange(contactTranslations(translations, locale, label)) }));
|
|
442
|
-
}
|
|
443
|
-
const WebsitesField = ({ field, props }) => {
|
|
444
|
-
const m = useOrganizationMessages();
|
|
445
|
-
return (_jsx(RepeatableContactField, { addLabel: m.organization_contact_add_website(), emptyValue: {
|
|
446
|
-
url: "",
|
|
447
|
-
translations: [{ locale: props.locale, label: "" }],
|
|
448
|
-
}, error: Option.isSome(field.error) ? field.error.value : undefined, path: field.path, values: field.value, onChange: field.onChange, render: (website, index, update) => (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(ContactInput, { id: `${field.path}-${index}-url`, label: m.organization_contact_url(), placeholder: "https://example.com", type: "url", value: website.url, onBlur: field.onBlur, onChange: (url) => update({ ...website, url }) }), _jsx(ContactLabelInput, { id: `${field.path}-${index}-label`, locale: props.locale, translations: website.translations, onBlur: field.onBlur, onChange: (translations) => update({
|
|
449
|
-
...website,
|
|
450
|
-
translations,
|
|
451
|
-
}) })] })) }));
|
|
452
|
-
};
|
|
453
|
-
function RepeatableContactField({ addLabel, emptyValue, error, onChange, path, render, values, }) {
|
|
454
|
-
const m = useOrganizationMessages();
|
|
455
|
-
return (_jsx(Field, { children: _jsxs("div", { className: "flex flex-col gap-3", children: [values.map((value, index) => (_jsxs("div", { className: "bg-muted/20 relative rounded-lg border p-4 pr-12", children: [render(value, index, (next) => onChange(values.map((item, itemIndex) => itemIndex === index ? next : item))), _jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "absolute top-2 right-2", "aria-label": m.organization_contact_remove(), onClick: () => onChange(values.filter((_, itemIndex) => itemIndex !== index)), children: _jsx(Trash2, {}) })] }, `${path}-${index}`))), _jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "self-start", onClick: () => onChange([...values, emptyValue]), children: [_jsx(Plus, {}), addLabel] }), error ? _jsx(ErrorMessage, { text: error }) : null] }) }));
|
|
456
|
-
}
|
|
457
|
-
function SocialPlatformSelect({ value, onChange, }) {
|
|
458
|
-
const m = useOrganizationMessages();
|
|
459
|
-
const items = [
|
|
460
|
-
{ label: "Facebook", value: "facebook" },
|
|
461
|
-
{ label: "GitHub", value: "github" },
|
|
462
|
-
{ label: "Instagram", value: "instagram" },
|
|
463
|
-
{ label: "LinkedIn", value: "linkedin" },
|
|
464
|
-
{ label: "TikTok", value: "tiktok" },
|
|
465
|
-
{ label: "X", value: "x" },
|
|
466
|
-
{ label: "YouTube", value: "youtube" },
|
|
467
|
-
];
|
|
468
|
-
return (_jsxs("div", { children: [_jsx(FieldLabel, { children: m.organization_contact_platform() }), _jsxs(Select, { items: items, value: value, onValueChange: (next) => {
|
|
469
|
-
const platform = socialPlatform(next);
|
|
470
|
-
if (platform)
|
|
471
|
-
onChange(platform);
|
|
472
|
-
}, children: [_jsx(SelectTrigger, { className: "mt-2 w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: items.map((item) => (_jsx(SelectItem, { value: item.value, children: item.label }, item.value))) })] })] }));
|
|
473
|
-
}
|
|
474
|
-
const SocialsField = ({ field, props }) => {
|
|
475
|
-
const m = useOrganizationMessages();
|
|
476
|
-
return (_jsx(RepeatableContactField, { addLabel: m.organization_contact_add_social(), emptyValue: {
|
|
477
|
-
platform: "linkedin",
|
|
478
|
-
url: "",
|
|
479
|
-
translations: [{ locale: props.locale, label: "" }],
|
|
480
|
-
}, error: Option.isSome(field.error) ? field.error.value : undefined, path: field.path, values: field.value, onChange: field.onChange, render: (social, index, update) => (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(SocialPlatformSelect, { value: social.platform, onChange: (platform) => update({ ...social, platform }) }), _jsx(ContactInput, { id: `${field.path}-${index}-url`, label: m.organization_contact_url(), placeholder: "https://example.com/profile", type: "url", value: social.url, onBlur: field.onBlur, onChange: (url) => update({ ...social, url }) }), _jsx(ContactLabelInput, { id: `${field.path}-${index}-label`, locale: props.locale, translations: social.translations, onBlur: field.onBlur, onChange: (translations) => update({
|
|
481
|
-
...social,
|
|
482
|
-
translations,
|
|
483
|
-
}) })] })) }));
|
|
484
|
-
};
|
|
485
|
-
const AddressesField = ({ field, props }) => {
|
|
486
|
-
const m = useOrganizationMessages();
|
|
487
|
-
const inputs = [
|
|
488
|
-
{
|
|
489
|
-
key: "streetAddress",
|
|
490
|
-
label: m.organization_address_street(),
|
|
491
|
-
className: "sm:col-span-2",
|
|
492
|
-
},
|
|
493
|
-
{ key: "locality", label: m.organization_address_locality() },
|
|
494
|
-
{ key: "region", label: m.organization_address_region() },
|
|
495
|
-
{ key: "postalCode", label: m.organization_address_postal_code() },
|
|
496
|
-
{ key: "country", label: m.organization_address_country() },
|
|
497
|
-
];
|
|
498
|
-
return (_jsx(RepeatableContactField, { addLabel: m.organization_address_add(), emptyValue: {
|
|
499
|
-
translations: [{ locale: props.locale, label: "" }],
|
|
500
|
-
}, error: Option.isSome(field.error) ? field.error.value : undefined, path: field.path, values: field.value, onChange: field.onChange, render: (address, index, update) => (_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(ContactLabelInput, { id: `${field.path}-${index}-label`, locale: props.locale, translations: address.translations, onBlur: field.onBlur, onChange: (translations) => update({
|
|
501
|
-
...address,
|
|
502
|
-
translations,
|
|
503
|
-
}) }), inputs.map((input) => (_createElement(ContactInput, { ...(input.className ? { className: input.className } : {}), id: `${field.path}-${index}-${input.key}`, key: input.key, label: input.label, value: address[input.key] ?? "", onBlur: field.onBlur, onChange: (value) => update({ ...address, [input.key]: value }) })))] })) }));
|
|
504
|
-
};
|
|
505
410
|
const organizationFormFields = {
|
|
506
411
|
parentId: SelectField,
|
|
507
412
|
slug: TextField,
|
|
508
|
-
emails:
|
|
509
|
-
phones:
|
|
510
|
-
websites:
|
|
511
|
-
socials:
|
|
512
|
-
addresses:
|
|
413
|
+
emails: ContactEmailsField,
|
|
414
|
+
phones: ContactPhonesField,
|
|
415
|
+
websites: ContactWebsitesField,
|
|
416
|
+
socials: ContactSocialsField,
|
|
417
|
+
addresses: ContactAddressesField,
|
|
513
418
|
enName: TextField,
|
|
514
419
|
enLogo: ImageField,
|
|
515
420
|
enIcon: ImageField,
|
|
@@ -558,7 +463,7 @@ const organizationFailureMessage = (cause, fallback) => {
|
|
|
558
463
|
};
|
|
559
464
|
const decodeUploadedAsset = Schema.decodeUnknownEffect(ExtraUploadedAsset);
|
|
560
465
|
const OrganizationMetadataRecord = Schema.Record(Schema.String, Schema.Json);
|
|
561
|
-
const normalizeOrganizationMetadata = (metadata) => Schema.
|
|
466
|
+
const normalizeOrganizationMetadata = (metadata) => Schema.decodeUnknownEffect(OrganizationMetadataRecord)(metadata);
|
|
562
467
|
const uploadImageAsset = (file, m, uploadImage) => {
|
|
563
468
|
const payload = new FormData();
|
|
564
469
|
payload.append("file", file);
|
|
@@ -1033,11 +938,11 @@ function UserInvitationsManager({ baseUrl, invitations, loading, error, activeOr
|
|
|
1033
938
|
setActingInvitationId(null);
|
|
1034
939
|
}
|
|
1035
940
|
};
|
|
1036
|
-
return (_jsxs("section", { className: "flex min-w-0 flex-col gap-4", children: [error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, actionError ? (_jsx("p", { className: "text-destructive text-sm", children: actionError })) : null, _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, {
|
|
941
|
+
return (_jsxs("section", { className: "flex min-w-0 flex-col gap-4", children: [error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, actionError ? (_jsx("p", { className: "text-destructive text-sm", children: actionError })) : null, _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columnDefs: userInvitationColumns({
|
|
1037
942
|
baseUrl,
|
|
1038
943
|
m,
|
|
1039
944
|
now: invitationNow,
|
|
1040
|
-
}),
|
|
945
|
+
}), rowData: invitations, features: {
|
|
1041
946
|
export: { baseName: "organization-invitations" },
|
|
1042
947
|
gallery: false,
|
|
1043
948
|
rowActions: {
|
|
@@ -1049,7 +954,7 @@ function UserInvitationsManager({ baseUrl, invitations, loading, error, activeOr
|
|
|
1049
954
|
onReject: rejectInvitation,
|
|
1050
955
|
}),
|
|
1051
956
|
},
|
|
1052
|
-
},
|
|
957
|
+
}, status: {
|
|
1053
958
|
empty: loading
|
|
1054
959
|
? m.user_loading()
|
|
1055
960
|
: m.organization_user_invitations_empty(),
|
|
@@ -1058,24 +963,24 @@ function UserInvitationsManager({ baseUrl, invitations, loading, error, activeOr
|
|
|
1058
963
|
}
|
|
1059
964
|
const userInvitationColumns = ({ baseUrl, m, now, }) => [
|
|
1060
965
|
{
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
966
|
+
field: "organizationName",
|
|
967
|
+
headerName: m.organization_invitation_organization(),
|
|
968
|
+
cellRenderer: ({ data }) => (_jsx(InvitationOrganizationBrand, { baseUrl: baseUrl, invitation: data })),
|
|
1064
969
|
},
|
|
1065
970
|
{
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
971
|
+
field: "role",
|
|
972
|
+
headerName: m.organization_member_role(),
|
|
973
|
+
cellRenderer: ({ data }) => (_jsx(Badge, { variant: "secondary", children: organizationRoleLabel(data.role, m) })),
|
|
1069
974
|
},
|
|
1070
975
|
{
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
976
|
+
field: "status",
|
|
977
|
+
headerName: m.organization_invitation_status(),
|
|
978
|
+
cellRenderer: ({ data }) => (_jsx(Badge, { variant: isInvitationExpired(data, now) ? "destructive" : "default", children: invitationStatusLabel(invitationDisplayStatus(data, now), m) })),
|
|
1074
979
|
},
|
|
1075
980
|
{
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
981
|
+
field: "expiresAt",
|
|
982
|
+
headerName: m.organization_invitation_expires(),
|
|
983
|
+
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(data.expiresAt) })),
|
|
1079
984
|
},
|
|
1080
985
|
];
|
|
1081
986
|
function InvitationOrganizationBrand({ baseUrl, invitation, }) {
|
|
@@ -1112,6 +1017,7 @@ function EditOrganizationSection({ baseUrl, editingLocale, organization, onUpdat
|
|
|
1112
1017
|
const [defaultLocale] = useState(currentOrganizationLocale);
|
|
1113
1018
|
const defaultValues = organizationFormDefaults(organization, baseUrl);
|
|
1114
1019
|
const [form] = useState(() => FormReact.make(organizationFormBuilder, {
|
|
1020
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
1115
1021
|
fields: organizationFormFields,
|
|
1116
1022
|
onSubmit: (_, { decoded: value }) => Effect.gen(function* () {
|
|
1117
1023
|
const name = organizationNameFromForm(value, defaultLocale);
|
|
@@ -1167,13 +1073,14 @@ function EditOrganizationSection({ baseUrl, editingLocale, organization, onUpdat
|
|
|
1167
1073
|
height: 96,
|
|
1168
1074
|
suggestedWidth: 512,
|
|
1169
1075
|
suggestedHeight: 512,
|
|
1170
|
-
} })] })] }), _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 }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale }) })] }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationFormSection, { title: m.organization_address(), children: _jsx(form.addresses, { locale: editingLocale }) }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) }) }));
|
|
1076
|
+
} })] })] }), _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(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) }) }));
|
|
1171
1077
|
}
|
|
1172
1078
|
function CreateOrganizationSection({ baseUrl, editingLocale, organizations, onCreated, }) {
|
|
1173
1079
|
const m = useOrganizationMessages();
|
|
1174
1080
|
const [defaultLocale] = useState(currentOrganizationLocale);
|
|
1175
1081
|
const defaultValues = organizationFormDefaults(undefined, baseUrl);
|
|
1176
1082
|
const [form] = useState(() => FormReact.make(organizationFormBuilder, {
|
|
1083
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
1177
1084
|
fields: organizationFormFields,
|
|
1178
1085
|
onSubmit: (_, { decoded: value }) => Effect.gen(function* () {
|
|
1179
1086
|
const name = organizationNameFromForm(value, defaultLocale);
|
|
@@ -1249,7 +1156,7 @@ function CreateOrganizationSection({ baseUrl, editingLocale, organizations, onCr
|
|
|
1249
1156
|
height: 96,
|
|
1250
1157
|
suggestedWidth: 512,
|
|
1251
1158
|
suggestedHeight: 512,
|
|
1252
|
-
} })] })] }), _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 }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale }) }), _jsx(OrganizationContactGroup, { title: m.organization_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale }) })] }), _jsx(Separator, { className: "my-2" }), _jsx(OrganizationFormSection, { title: m.organization_address(), children: _jsx(form.addresses, { locale: editingLocale }) }), _jsx(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) }) }));
|
|
1159
|
+
} })] })] }), _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(SubmitError, { result: submitResult }), _jsx(SubmitButton, { form: form })] }) }) }));
|
|
1253
1160
|
}
|
|
1254
1161
|
function OrganizationFormSection({ children, description, title, }) {
|
|
1255
1162
|
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] }));
|
|
@@ -1328,6 +1235,7 @@ function OrganizationMembersManager({ baseUrl, canManageMembers, organization, c
|
|
|
1328
1235
|
});
|
|
1329
1236
|
}, [currentInvitations, currentMembers]);
|
|
1330
1237
|
const [inviteForm] = useState(() => FormReact.make(inviteMemberFormBuilder, {
|
|
1238
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
1331
1239
|
fields: {
|
|
1332
1240
|
email: TextField,
|
|
1333
1241
|
role: SelectField,
|
|
@@ -1441,12 +1349,12 @@ function OrganizationMembersManager({ baseUrl, canManageMembers, organization, c
|
|
|
1441
1349
|
}, children: [_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) => ({
|
|
1442
1350
|
label: organizationRoleLabel(role, m),
|
|
1443
1351
|
value: role,
|
|
1444
|
-
})) }), _jsx("div", { className: "self-end", children: _jsx(SubmitButton, { form: inviteForm }) }), _jsx(SubmitError, { result: inviteResult })] }) })) : null, !inviting && loadError ? (_jsx("p", { className: "text-destructive text-sm", children: loadError })) : null, !inviting && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !inviting ? (_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, {
|
|
1352
|
+
})) }), _jsx("div", { className: "self-end", children: _jsx(SubmitButton, { form: inviteForm }) }), _jsx(SubmitError, { result: inviteResult })] }) })) : null, !inviting && loadError ? (_jsx("p", { className: "text-destructive text-sm", children: loadError })) : null, !inviting && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !inviting ? (_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, { columnDefs: memberColumns({
|
|
1445
1353
|
m,
|
|
1446
1354
|
baseUrl,
|
|
1447
1355
|
canChangeRoles: canManageMembers,
|
|
1448
1356
|
onRoleChange: updateRole,
|
|
1449
|
-
}),
|
|
1357
|
+
}), rowData: displayedMembers, features: {
|
|
1450
1358
|
export: { baseName: `${organization.slug}-members` },
|
|
1451
1359
|
gallery: false,
|
|
1452
1360
|
rowActions: {
|
|
@@ -1459,10 +1367,10 @@ function OrganizationMembersManager({ baseUrl, canManageMembers, organization, c
|
|
|
1459
1367
|
onRemove: removeMember,
|
|
1460
1368
|
}),
|
|
1461
1369
|
},
|
|
1462
|
-
},
|
|
1370
|
+
}, status: { empty: m.organization_members_empty(), loading } }) })] })) : null, !inviting ? (_jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_invitations_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invitations_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columnDefs: invitationColumns({
|
|
1463
1371
|
m,
|
|
1464
1372
|
now: invitationNow,
|
|
1465
|
-
}),
|
|
1373
|
+
}), rowData: invitations, features: {
|
|
1466
1374
|
export: { baseName: `${organization.slug}-invitations` },
|
|
1467
1375
|
gallery: false,
|
|
1468
1376
|
rowActions: {
|
|
@@ -1472,22 +1380,22 @@ function OrganizationMembersManager({ baseUrl, canManageMembers, organization, c
|
|
|
1472
1380
|
onCancel: cancelInvitation,
|
|
1473
1381
|
}),
|
|
1474
1382
|
},
|
|
1475
|
-
},
|
|
1383
|
+
}, status: { empty: m.organization_invitations_empty(), loading } }) })] })) : null] })] }));
|
|
1476
1384
|
}
|
|
1477
1385
|
const memberColumns = ({ m, baseUrl, canChangeRoles, onRoleChange, }) => [
|
|
1478
1386
|
{
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
const image = assetUrl(
|
|
1483
|
-
return (_jsx(AppBrand, { to: null, label:
|
|
1387
|
+
colId: "user",
|
|
1388
|
+
headerName: m.organization_member_user(),
|
|
1389
|
+
cellRenderer: ({ data }) => {
|
|
1390
|
+
const image = assetUrl(data.user.image, baseUrl);
|
|
1391
|
+
return (_jsx(AppBrand, { to: null, label: data.user.name, subtitle: data.user.email, icon: UserIcon, className: "min-w-0", ...(image ? { imageSrc: image } : {}) }));
|
|
1484
1392
|
},
|
|
1485
1393
|
},
|
|
1486
1394
|
{
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
const member =
|
|
1395
|
+
field: "role",
|
|
1396
|
+
headerName: m.organization_member_role(),
|
|
1397
|
+
cellRenderer: ({ data }) => {
|
|
1398
|
+
const member = data;
|
|
1491
1399
|
const roles = normalizeOrganizationRoles(member.role);
|
|
1492
1400
|
const roleOptions = roles.map((role) => ({
|
|
1493
1401
|
label: organizationRoleLabel(role, m),
|
|
@@ -1512,9 +1420,9 @@ const memberColumns = ({ m, baseUrl, canChangeRoles, onRoleChange, }) => [
|
|
|
1512
1420
|
},
|
|
1513
1421
|
},
|
|
1514
1422
|
{
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1423
|
+
field: "createdAt",
|
|
1424
|
+
headerName: m.organization_member_joined(),
|
|
1425
|
+
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(data.createdAt) })),
|
|
1518
1426
|
},
|
|
1519
1427
|
];
|
|
1520
1428
|
const memberRowActions = ({ m, canRemoveMembers, currentUserId, leavingOrganization, onLeave, onRemove, }) => [
|
|
@@ -1537,24 +1445,24 @@ const memberRowActions = ({ m, canRemoveMembers, currentUserId, leavingOrganizat
|
|
|
1537
1445
|
];
|
|
1538
1446
|
const invitationColumns = ({ m, now, }) => [
|
|
1539
1447
|
{
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1448
|
+
field: "email",
|
|
1449
|
+
headerName: m.organization_member_email(),
|
|
1450
|
+
cellRenderer: ({ data }) => (_jsx("p", { className: "truncate font-medium", children: data.email })),
|
|
1543
1451
|
},
|
|
1544
1452
|
{
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1453
|
+
field: "role",
|
|
1454
|
+
headerName: m.organization_member_role(),
|
|
1455
|
+
cellRenderer: ({ data }) => (_jsx(Badge, { variant: "secondary", children: organizationRoleLabel(data.role, m) })),
|
|
1548
1456
|
},
|
|
1549
1457
|
{
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1458
|
+
field: "status",
|
|
1459
|
+
headerName: m.organization_invitation_status(),
|
|
1460
|
+
cellRenderer: ({ data }) => (_jsx(Badge, { variant: isInvitationExpired(data, now) ? "destructive" : "default", children: invitationStatusLabel(invitationDisplayStatus(data, now), m) })),
|
|
1553
1461
|
},
|
|
1554
1462
|
{
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1463
|
+
field: "expiresAt",
|
|
1464
|
+
headerName: m.organization_invitation_expires(),
|
|
1465
|
+
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(data.expiresAt) })),
|
|
1558
1466
|
},
|
|
1559
1467
|
];
|
|
1560
1468
|
const invitationRowActions = ({ m, cancellingInvitationId, onCancel, }) => [
|
|
@@ -1596,6 +1504,7 @@ function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLa
|
|
|
1596
1504
|
});
|
|
1597
1505
|
const loading = keysResult._tag === "Initial";
|
|
1598
1506
|
const [createForm] = useState(() => FormReact.make(apiKeyFormBuilder, {
|
|
1507
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
1599
1508
|
fields: { name: TextField, referrers: TextAreaField },
|
|
1600
1509
|
onSubmit: (_, { decoded: value }) => Effect.gen(function* () {
|
|
1601
1510
|
yield* Effect.sync(() => setCreatedKey(null));
|
|
@@ -1669,7 +1578,7 @@ function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLa
|
|
|
1669
1578
|
}, children: [_jsx(createForm.name, { label: m.user_api_key_name(), required: true }), _jsx(createForm.referrers, { label: m.user_api_key_referrers(), description: m.user_api_key_referrers_description(), placeholder: m.user_api_key_referrers_placeholder(), rows: 3 }), _jsx(ApiKeyPermissions, { description: m.user_api_key_permissions_description(), idPrefix: "organization-create", permissions: permissions, labels: permissionLabels, selected: selectedPermissions, title: m.user_api_key_permissions(), onChange: togglePermission }), _jsx(SubmitError, { result: createResult }), _jsx(SubmitButton, { form: createForm })] }) }) })) : null, creating && createdKey ? (_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: _jsxs("div", { className: "bg-muted/50 flex min-w-0 items-center justify-between gap-3 rounded-md border px-3 py-2", children: [_jsx("code", { className: "block min-w-0 flex-1 overflow-x-auto text-sm whitespace-nowrap", children: createdKey }), _jsx(CopyButton, { className: "shrink-0", messages: {
|
|
1670
1579
|
copied: m.user_api_key_copied(),
|
|
1671
1580
|
copy: m.user_api_key_copy(),
|
|
1672
|
-
}, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0 overflow-x-hidden", children: _jsx(DataTable, {
|
|
1581
|
+
}, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0 overflow-x-hidden", children: _jsx(DataTable, { columnDefs: apiKeyColumns({ m }), rowData: keys, features: {
|
|
1673
1582
|
export: { baseName: `${organization.slug}-api-keys` },
|
|
1674
1583
|
gallery: false,
|
|
1675
1584
|
rowActions: {
|
|
@@ -1679,7 +1588,7 @@ function OrganizationApiKeyManager({ baseUrl, organization, active, permissionLa
|
|
|
1679
1588
|
onEdit: (key) => setEditingKey(key),
|
|
1680
1589
|
}),
|
|
1681
1590
|
},
|
|
1682
|
-
},
|
|
1591
|
+
}, status: {
|
|
1683
1592
|
empty: loading ? m.user_loading() : m.table_empty(),
|
|
1684
1593
|
loading,
|
|
1685
1594
|
} }) })) : null, editingKey ? (_jsx(OrganizationApiKeyEditForm, { baseUrl: baseUrl, keyData: editingKey, permissions: permissions, permissionLabels: permissionLabels, messages: {
|
|
@@ -1716,6 +1625,7 @@ function OrganizationApiKeyEditForm({ baseUrl, keyData, messages, permissions, p
|
|
|
1716
1625
|
permissionOptionsRef.current = permissionOptions;
|
|
1717
1626
|
permissionsRef.current = permissions;
|
|
1718
1627
|
const [form] = useState(() => FormReact.make(editApiKeyFormBuilder, {
|
|
1628
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
1719
1629
|
fields: {
|
|
1720
1630
|
name: TextField,
|
|
1721
1631
|
enabled: CheckboxField,
|
|
@@ -1769,39 +1679,37 @@ function OrganizationApiKeyEditForm({ baseUrl, keyData, messages, permissions, p
|
|
|
1769
1679
|
}
|
|
1770
1680
|
const apiKeyColumns = ({ m, }) => [
|
|
1771
1681
|
{
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
? m.user_api_key_starts_with({ start:
|
|
1682
|
+
field: "name",
|
|
1683
|
+
headerName: m.user_api_key_name(),
|
|
1684
|
+
cellRenderer: ({ data }) => (_jsxs("div", { className: "min-w-0", children: [_jsx("p", { className: "truncate font-medium", children: data.name }), _jsx("p", { className: "text-muted-foreground text-sm", children: data.start
|
|
1685
|
+
? m.user_api_key_starts_with({ start: data.start })
|
|
1776
1686
|
: m.user_api_key_hidden() })] })),
|
|
1777
1687
|
},
|
|
1778
1688
|
{
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
? m.user_api_key_enabled()
|
|
1783
|
-
: m.user_api_key_disabled() })),
|
|
1689
|
+
field: "enabled",
|
|
1690
|
+
headerName: m.user_api_key_status(),
|
|
1691
|
+
cellRenderer: ({ data }) => (_jsx(Badge, { variant: data.enabled ? "default" : "secondary", children: data.enabled ? m.user_api_key_enabled() : m.user_api_key_disabled() })),
|
|
1784
1692
|
},
|
|
1785
1693
|
{
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
const values = organizationApiKeyFormattedPermissions(
|
|
1694
|
+
colId: "permissions",
|
|
1695
|
+
valueGetter: ({ data }) => data.permissions,
|
|
1696
|
+
headerName: m.user_api_key_permissions(),
|
|
1697
|
+
cellRenderer: ({ data }) => {
|
|
1698
|
+
const values = organizationApiKeyFormattedPermissions(data.permissions);
|
|
1791
1699
|
return values.length > 0 ? (_jsx("div", { className: "flex flex-wrap gap-1", children: values.map((value) => (_jsx(Badge, { variant: "outline", children: value }, value))) })) : (_jsx("span", { className: "text-muted-foreground text-sm", children: m.user_api_key_no_permissions() }));
|
|
1792
1700
|
},
|
|
1793
1701
|
},
|
|
1794
1702
|
{
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1703
|
+
colId: "referrers",
|
|
1704
|
+
valueGetter: ({ data }) => data.metadata,
|
|
1705
|
+
headerName: m.user_api_key_referrers_column(),
|
|
1706
|
+
cellRenderer: ({ data }) => (_jsx(ApiKeyReferrers, { metadata: data.metadata, unrestrictedLabel: m.user_api_key_referrers_any() })),
|
|
1799
1707
|
},
|
|
1800
1708
|
{
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1709
|
+
colId: "rateLimit",
|
|
1710
|
+
valueGetter: ({ data }) => apiKeyUsagePercent(data),
|
|
1711
|
+
headerName: m.user_api_key_rate_limit(),
|
|
1712
|
+
cellRenderer: ({ data }) => (_jsx(ApiKeyRateLimit, { keyData: data, messages: {
|
|
1805
1713
|
disabled: m.user_api_key_disabled(),
|
|
1806
1714
|
none: m.user_api_key_window_none(),
|
|
1807
1715
|
unlimited: m.user_api_key_unlimited(),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { type ComponentProps, type ReactNode } from "react";
|
|
2
3
|
import { DropdownMenuContent } from "@/components/ui/dropdown-menu";
|
|
4
|
+
import { type ContactEmail as ContactEmailValue, type ContactPhone as ContactPhoneValue, type ContactSocial as ContactSocialValue, type ContactWebsite as ContactWebsiteValue, UserMetadata } from "../schema.js";
|
|
3
5
|
declare const messages: {
|
|
4
6
|
readonly en: {
|
|
5
7
|
readonly table_empty: "No results.";
|
|
@@ -89,6 +91,22 @@ declare const messages: {
|
|
|
89
91
|
readonly user_form_title: "Account";
|
|
90
92
|
readonly user_form_update_error: "Unable to update your account.";
|
|
91
93
|
readonly user_loading: "Loading...";
|
|
94
|
+
readonly user_contact_add_email: "Add email";
|
|
95
|
+
readonly user_contact_add_phone: "Add phone";
|
|
96
|
+
readonly user_contact_add_social: "Add social profile";
|
|
97
|
+
readonly user_contact_add_website: "Add website";
|
|
98
|
+
readonly user_contact_description: "Add up to 8 public contacts of each type, separately from the email used to sign in.";
|
|
99
|
+
readonly user_contact_email_type: "Email";
|
|
100
|
+
readonly user_contact_extension: "Extension";
|
|
101
|
+
readonly user_contact_label: "Label";
|
|
102
|
+
readonly user_contact_phone_type: "Phone";
|
|
103
|
+
readonly user_contact_platform: "Platform";
|
|
104
|
+
readonly user_contact_remove: "Remove contact method";
|
|
105
|
+
readonly user_contact_social_type: "Social";
|
|
106
|
+
readonly user_contact_title: "Contact methods";
|
|
107
|
+
readonly user_contact_url: "URL";
|
|
108
|
+
readonly user_contact_validation_error: "Review your contact methods and keep the total metadata below 2 KB.";
|
|
109
|
+
readonly user_contact_website_type: "Website";
|
|
92
110
|
readonly user_profile_description: "Update your public profile details.";
|
|
93
111
|
readonly user_profile_image_upload_error: "Could not upload your profile photo.";
|
|
94
112
|
readonly user_profile_photo_upload_label: "Profile photo";
|
|
@@ -198,6 +216,22 @@ declare const messages: {
|
|
|
198
216
|
readonly user_form_title: "Compte";
|
|
199
217
|
readonly user_form_update_error: "Impossible de mettre à jour votre compte.";
|
|
200
218
|
readonly user_loading: "Chargement...";
|
|
219
|
+
readonly user_contact_add_email: "Ajouter un courriel";
|
|
220
|
+
readonly user_contact_add_phone: "Ajouter un téléphone";
|
|
221
|
+
readonly user_contact_add_social: "Ajouter un profil social";
|
|
222
|
+
readonly user_contact_add_website: "Ajouter un site Web";
|
|
223
|
+
readonly user_contact_description: "Ajoutez jusqu’à 8 coordonnées publiques de chaque type, distinctes du courriel utilisé pour vous connecter.";
|
|
224
|
+
readonly user_contact_email_type: "Courriel";
|
|
225
|
+
readonly user_contact_extension: "Poste";
|
|
226
|
+
readonly user_contact_label: "Libellé";
|
|
227
|
+
readonly user_contact_phone_type: "Téléphone";
|
|
228
|
+
readonly user_contact_platform: "Plateforme";
|
|
229
|
+
readonly user_contact_remove: "Supprimer le moyen de contact";
|
|
230
|
+
readonly user_contact_social_type: "Réseau social";
|
|
231
|
+
readonly user_contact_title: "Moyens de contact";
|
|
232
|
+
readonly user_contact_url: "URL";
|
|
233
|
+
readonly user_contact_validation_error: "Vérifiez vos moyens de contact et limitez les métadonnées totales à 2 Ko.";
|
|
234
|
+
readonly user_contact_website_type: "Site Web";
|
|
201
235
|
readonly user_profile_description: "Mettez à jour les informations de votre profil public.";
|
|
202
236
|
readonly user_profile_image_upload_error: "Impossible de téléverser votre photo de profil.";
|
|
203
237
|
readonly user_profile_photo_upload_label: "Photo de profil";
|
|
@@ -222,6 +256,45 @@ declare const messages: {
|
|
|
222
256
|
};
|
|
223
257
|
type UserButtonMessageKey = keyof (typeof messages)["en"];
|
|
224
258
|
export type UserButtonMessages = Partial<Record<UserButtonMessageKey, string>>;
|
|
259
|
+
type UserFormType = {
|
|
260
|
+
name: string;
|
|
261
|
+
image: File | string | null;
|
|
262
|
+
emails: ReadonlyArray<ContactEmailValue>;
|
|
263
|
+
phones: ReadonlyArray<ContactPhoneValue>;
|
|
264
|
+
websites: ReadonlyArray<ContactWebsiteValue>;
|
|
265
|
+
socials: ReadonlyArray<ContactSocialValue>;
|
|
266
|
+
};
|
|
267
|
+
export declare const UserContactEmailsForm: Schema.$Array<Schema.Struct<{
|
|
268
|
+
readonly email: Schema.String;
|
|
269
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
270
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
271
|
+
readonly label: Schema.String;
|
|
272
|
+
}>>;
|
|
273
|
+
}>>;
|
|
274
|
+
export declare const UserContactPhonesForm: Schema.$Array<Schema.Struct<{
|
|
275
|
+
readonly number: Schema.String;
|
|
276
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
277
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
278
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
279
|
+
readonly label: Schema.String;
|
|
280
|
+
}>>;
|
|
281
|
+
}>>;
|
|
282
|
+
export declare const UserContactWebsitesForm: Schema.$Array<Schema.Struct<{
|
|
283
|
+
readonly url: Schema.String;
|
|
284
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
285
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
286
|
+
readonly label: Schema.String;
|
|
287
|
+
}>>;
|
|
288
|
+
}>>;
|
|
289
|
+
export declare const UserContactSocialsForm: Schema.$Array<Schema.Struct<{
|
|
290
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
291
|
+
readonly url: Schema.String;
|
|
292
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
293
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
294
|
+
readonly label: Schema.String;
|
|
295
|
+
}>>;
|
|
296
|
+
}>>;
|
|
297
|
+
export declare const userMetadataFromForm: (value: UserFormType) => UserMetadata;
|
|
225
298
|
export type UserButtonProps = {
|
|
226
299
|
baseUrl?: string | undefined;
|
|
227
300
|
signOutRedirect?: string;
|