@krak-stack/auth 0.1.71 → 0.2.1
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/README.md +4 -3
- package/dist/access.d.ts +5 -7
- package/dist/access.js +11 -7
- package/dist/admin/api.group.d.ts +53 -53
- package/dist/admin/api.group.js +15 -15
- package/dist/admin/schema.d.ts +18 -18
- package/dist/admin/schema.js +3 -3
- package/dist/api.d.ts +1995 -533
- package/dist/api.js +7 -7
- package/dist/auth/api.group.d.ts +793 -0
- package/dist/auth/api.group.js +241 -0
- package/dist/auth/schema.d.ts +808 -0
- package/dist/auth/schema.js +628 -0
- package/dist/components/admin-organization-form.d.ts +1 -1
- package/dist/components/admin-organization-form.js +17 -18
- package/dist/components/admin-organizations.d.ts +4 -5
- package/dist/components/admin-organizations.js +83 -73
- package/dist/components/admin-users.d.ts +5 -6
- package/dist/components/admin-users.js +160 -181
- package/dist/components/api-key-edit-form.d.ts +4 -3
- package/dist/components/api-key-edit-form.js +33 -27
- package/dist/components/api-key-permissions.d.ts +1 -1
- package/dist/components/api-key-rate-limit.d.ts +1 -1
- package/dist/components/api-key-referrers.d.ts +3 -2
- package/dist/components/api-key-referrers.js +2 -3
- package/dist/components/api-key.d.ts +0 -9
- package/dist/components/api-key.js +0 -39
- package/dist/components/auth-atoms.d.ts +178 -0
- package/dist/components/auth-atoms.js +46 -0
- package/dist/components/auth-client-api.d.ts +1371 -556
- package/dist/components/auth-client-api.js +22 -14
- package/dist/components/auth-forms.d.ts +1 -3
- package/dist/components/auth-forms.js +173 -195
- package/dist/components/auth-provider.d.ts +16 -20
- package/dist/components/auth-provider.js +56 -30
- package/dist/components/has-permission.js +1 -1
- package/dist/components/index.d.ts +19 -20
- package/dist/components/index.js +13 -13
- package/dist/components/member-required.d.ts +1 -3
- package/dist/components/member-required.js +102 -78
- package/dist/components/organization-switcher.d.ts +4 -6
- package/dist/components/organization-switcher.js +539 -390
- package/dist/components/project-access-matrix.d.ts +1 -1
- package/dist/components/project-access-matrix.js +9 -13
- package/dist/components/user-button.d.ts +5 -3
- package/dist/components/user-button.js +291 -336
- package/dist/components/utils.d.ts +3 -1
- package/dist/components/utils.js +4 -11
- package/dist/extra/api.group.d.ts +22 -22
- package/dist/extra/api.group.js +9 -9
- package/dist/extra/schema.d.ts +1 -2
- package/dist/extra/schema.js +2 -3
- package/dist/index.d.ts +11 -12
- package/dist/index.js +11 -12
- package/dist/query.d.ts +2 -2
- package/dist/query.js +5 -5
- package/dist/roles.d.ts +5 -4
- package/dist/roles.js +11 -7
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +26 -19
- package/dist/server/actor.d.ts +20 -22
- package/dist/server/actor.js +14 -17
- package/dist/server/api.group.d.ts +29 -29
- package/dist/server/api.group.js +14 -14
- package/dist/server/index.d.ts +14 -14
- package/dist/server/index.js +8 -8
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +1 -1
- package/dist/server/schema.js +1 -1
- package/dist/service.d.ts +1997 -583
- package/dist/service.js +23 -16
- package/package.json +10 -9
- package/dist/better-auth/api.group.d.ts +0 -62
- package/dist/better-auth/api.group.js +0 -39
- package/dist/better-auth/schema.d.ts +0 -72
- package/dist/better-auth/schema.js +0 -110
- package/dist/components/auth-client.d.ts +0 -50
- package/dist/components/auth-client.js +0 -46
|
@@ -7,16 +7,16 @@ import { useState } from "react";
|
|
|
7
7
|
import { toast } from "sonner";
|
|
8
8
|
import { ImageField, SingleSearchableSelectField, SubmitButton, SubmitError, TextField, } from "@krak-stack/registry/effect-form";
|
|
9
9
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
10
|
-
import { AdminCreateOrganizationPayload, } from "../admin/schema";
|
|
11
|
-
import { authClientApi } from "./auth-client-api";
|
|
12
|
-
import { useKrakstackAuth } from "./auth-provider";
|
|
13
|
-
import { assetPath, assetUrl } from "./utils";
|
|
10
|
+
import { AdminCreateOrganizationPayload, } from "../admin/schema.js";
|
|
11
|
+
import { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
12
|
+
import { useKrakstackAuth } from "./auth-provider.js";
|
|
13
|
+
import { assetPath, assetUrl } from "./utils.js";
|
|
14
14
|
const defaultMessages = {
|
|
15
15
|
en: {
|
|
16
16
|
admin_organization_edit_description: "Update {name}'s canonical organization details.",
|
|
17
17
|
field_name: "Name",
|
|
18
18
|
form_submit: "Save",
|
|
19
|
-
organization_create_description: "Create an organization that can be used for
|
|
19
|
+
organization_create_description: "Create an organization that can be used for authentication membership.",
|
|
20
20
|
organization_create_error: "Unable to create organization.",
|
|
21
21
|
organization_create_title: "Create organization",
|
|
22
22
|
organization_created_toast: "Organization created.",
|
|
@@ -36,7 +36,7 @@ const defaultMessages = {
|
|
|
36
36
|
admin_organization_edit_description: "Mettez à jour les détails canoniques de l'organisation {name}.",
|
|
37
37
|
field_name: "Nom",
|
|
38
38
|
form_submit: "Enregistrer",
|
|
39
|
-
organization_create_description: "Créez une organisation utilisable pour les adhésions
|
|
39
|
+
organization_create_description: "Créez une organisation utilisable pour les adhésions d'authentification.",
|
|
40
40
|
organization_create_error: "Impossible de créer l'organisation.",
|
|
41
41
|
organization_create_title: "Créer une organisation",
|
|
42
42
|
organization_created_toast: "Organisation créée.",
|
|
@@ -61,9 +61,6 @@ const organizationOptionsAtom = Atom.family((baseUrl) => authClientApi(baseUrl).
|
|
|
61
61
|
timeToLive: "1 minute",
|
|
62
62
|
reactivityKeys: ["organizations"],
|
|
63
63
|
}));
|
|
64
|
-
const createOrganizationAtom = Atom.family((baseUrl) => authClientApi(baseUrl).mutation("admin", "createOrganization"));
|
|
65
|
-
const updateOrganizationAtom = Atom.family((baseUrl) => authClientApi(baseUrl).mutation("admin", "updateOrganization"));
|
|
66
|
-
const uploadOrganizationLogoAtom = Atom.family((baseUrl) => authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"));
|
|
67
64
|
const slugify = (value) => value
|
|
68
65
|
.trim()
|
|
69
66
|
.toLowerCase()
|
|
@@ -75,6 +72,7 @@ const organizationFormBuilder = FormBuilder.empty
|
|
|
75
72
|
.addField("logo", Schema.UndefinedOr(Schema.NullOr(Schema.Union([Schema.String, Schema.instanceOf(File)]))))
|
|
76
73
|
.addField("parentId", Schema.String);
|
|
77
74
|
const makeOrganizationForm = ({ baseUrl, organization, }) => FormReact.make(organizationFormBuilder, {
|
|
75
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
78
76
|
fields: {
|
|
79
77
|
name: TextField,
|
|
80
78
|
slug: TextField,
|
|
@@ -82,25 +80,26 @@ const makeOrganizationForm = ({ baseUrl, organization, }) => FormReact.make(orga
|
|
|
82
80
|
parentId: SingleSearchableSelectField,
|
|
83
81
|
},
|
|
84
82
|
mode: { validation: "onSubmit" },
|
|
85
|
-
onSubmit: (_, { decoded
|
|
83
|
+
onSubmit: (_, { decoded }) => Effect.gen(function* () {
|
|
84
|
+
const http = yield* authHttpClient(baseUrl);
|
|
86
85
|
const logoValue = decoded.logo;
|
|
87
86
|
let logo = assetPath(logoValue instanceof File ? null : logoValue);
|
|
88
87
|
if (logoValue instanceof File) {
|
|
89
88
|
const payload = new FormData();
|
|
90
89
|
payload.append("file", logoValue);
|
|
91
|
-
const uploaded = yield*
|
|
90
|
+
const uploaded = yield* http.authExtra.uploadUserImage({ payload });
|
|
92
91
|
logo = assetPath(uploaded.url);
|
|
93
92
|
}
|
|
94
|
-
const
|
|
93
|
+
const input = {
|
|
95
94
|
name: decoded.name.trim(),
|
|
96
95
|
slug: slugify(decoded.slug || decoded.name),
|
|
97
96
|
logo: logo ?? undefined,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
};
|
|
98
|
+
const payload = Schema.decodeUnknownSync(AdminCreateOrganizationPayload)(decoded.parentId === noParentOrganization
|
|
99
|
+
? input
|
|
100
|
+
: { ...input, parentId: decoded.parentId });
|
|
102
101
|
const saved = organization
|
|
103
|
-
? yield*
|
|
102
|
+
? yield* http.admin.updateOrganization({
|
|
104
103
|
params: { id: organization.id },
|
|
105
104
|
payload: {
|
|
106
105
|
...payload,
|
|
@@ -109,7 +108,7 @@ const makeOrganizationForm = ({ baseUrl, organization, }) => FormReact.make(orga
|
|
|
109
108
|
: decoded.parentId,
|
|
110
109
|
},
|
|
111
110
|
})
|
|
112
|
-
: yield*
|
|
111
|
+
: yield* http.admin.createOrganization({ payload });
|
|
113
112
|
return saved;
|
|
114
113
|
}),
|
|
115
114
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
from?: ValidateFromPath;
|
|
1
|
+
import { type QueryType } from "@krak-stack/registry/query";
|
|
2
|
+
export declare function AdminOrganizationsTable({ onSearchChange, reloadKey, search, }: {
|
|
3
|
+
onSearchChange?: (search: QueryType) => void;
|
|
5
4
|
reloadKey?: number;
|
|
6
|
-
search?:
|
|
5
|
+
search?: QueryType;
|
|
7
6
|
}): import("react").JSX.Element;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
2
|
+
import { useAtomSet, useAtomSubscribe, useAtomValue } from "@effect/atom-react";
|
|
3
|
+
import { Cause, Effect, Schema } from "effect";
|
|
3
4
|
import { Atom, AsyncResult } from "effect/unstable/reactivity";
|
|
4
5
|
import { Building2, Pencil, Trash2 } from "lucide-react";
|
|
5
6
|
import { useState } from "react";
|
|
6
7
|
import { toast } from "sonner";
|
|
7
8
|
import { DataTable, DataTableListSummary, } from "@krak-stack/registry/data-table";
|
|
9
|
+
import { SortParamsFromString, } from "@krak-stack/registry/query";
|
|
8
10
|
import { ErrorMessage } from "@krak-stack/registry/effect-form";
|
|
9
11
|
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
10
12
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog";
|
|
11
|
-
import { AdminOrganizationForm } from "./admin-organization-form";
|
|
12
|
-
import { authClientApi } from "./auth-client-api";
|
|
13
|
-
import { useKrakstackAuth } from "./auth-provider";
|
|
14
|
-
import { assetUrl, organizationBranding } from "./utils";
|
|
13
|
+
import { AdminOrganizationForm } from "./admin-organization-form.js";
|
|
14
|
+
import { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
15
|
+
import { useKrakstackAuth } from "./auth-provider.js";
|
|
16
|
+
import { assetUrl, organizationBranding } from "./utils.js";
|
|
15
17
|
const defaultMessages = {
|
|
16
18
|
en: {
|
|
17
19
|
admin_column_created: "Created",
|
|
@@ -56,32 +58,49 @@ const organizationDisplay = (organization, locale, baseUrl) => {
|
|
|
56
58
|
image: assetUrl(branding?.logo, baseUrl),
|
|
57
59
|
};
|
|
58
60
|
};
|
|
61
|
+
const AdminOrganizationsFamilyKey = Schema.fromJsonString(Schema.Struct({
|
|
62
|
+
query: Schema.Struct({
|
|
63
|
+
page: Schema.Number,
|
|
64
|
+
pageSize: Schema.Number,
|
|
65
|
+
globalFilter: Schema.optional(Schema.String),
|
|
66
|
+
sort: Schema.optional(Schema.String),
|
|
67
|
+
projectId: Schema.optional(Schema.String),
|
|
68
|
+
}),
|
|
69
|
+
reloadKey: Schema.Number,
|
|
70
|
+
})).annotate({ identifier: "AdminOrganizationsFamilyKey" });
|
|
59
71
|
const organizationsQuery = (search, projectId) => {
|
|
60
|
-
|
|
72
|
+
let query = {
|
|
61
73
|
page: search.page ?? 0,
|
|
62
74
|
pageSize: search.pageSize ?? 10,
|
|
63
|
-
...(search.globalFilter ? { globalFilter: search.globalFilter } : {}),
|
|
64
|
-
...(search.sort ? { sort: search.sort } : {}),
|
|
65
|
-
...(projectId ? { projectId } : {}),
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
query,
|
|
69
|
-
key: JSON.stringify(query),
|
|
70
75
|
};
|
|
76
|
+
if (search.globalFilter)
|
|
77
|
+
query = { ...query, globalFilter: search.globalFilter };
|
|
78
|
+
if (search.sort)
|
|
79
|
+
query = {
|
|
80
|
+
...query,
|
|
81
|
+
sort: Schema.encodeSync(SortParamsFromString)(search.sort),
|
|
82
|
+
};
|
|
83
|
+
if (projectId)
|
|
84
|
+
query = { ...query, projectId };
|
|
85
|
+
return query;
|
|
71
86
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
87
|
+
const adminOrganizationsFamilyKey = (search, projectId, reloadKey) => JSON.stringify({
|
|
88
|
+
query: organizationsQuery(search, projectId),
|
|
89
|
+
reloadKey,
|
|
90
|
+
});
|
|
91
|
+
const organizationsAtom = Atom.family((baseUrl) => Atom.family((key) => {
|
|
92
|
+
const { query, reloadKey } = Schema.decodeUnknownSync(AdminOrganizationsFamilyKey)(key);
|
|
74
93
|
return authClientApi(baseUrl).query("admin", "listOrganizations", {
|
|
75
|
-
query
|
|
94
|
+
query,
|
|
76
95
|
timeToLive: "1 minute",
|
|
77
96
|
reactivityKeys: [
|
|
78
97
|
"organizations",
|
|
79
|
-
...(projectId ? [`project:${projectId}`] : []),
|
|
98
|
+
...(query.projectId ? [`project:${query.projectId}`] : []),
|
|
80
99
|
],
|
|
81
|
-
serializationKey: `organizations:${reloadKey}:${
|
|
100
|
+
serializationKey: `organizations:${reloadKey}:${JSON.stringify(query)}`,
|
|
82
101
|
});
|
|
83
|
-
});
|
|
84
|
-
export function AdminOrganizationsTable({
|
|
102
|
+
}));
|
|
103
|
+
export function AdminOrganizationsTable({ onSearchChange, reloadKey = 0, search, }) {
|
|
85
104
|
const auth = useKrakstackAuth();
|
|
86
105
|
const locale = auth?.locale ?? "en";
|
|
87
106
|
const m = labels(locale);
|
|
@@ -91,16 +110,11 @@ export function AdminOrganizationsTable({ from, reloadKey = 0, search, }) {
|
|
|
91
110
|
const [editingOrganization, setEditingOrganization] = useState(null);
|
|
92
111
|
const [deletingOrganization, setDeletingOrganization] = useState(null);
|
|
93
112
|
const [localSearch, setLocalSearch] = useState({
|
|
94
|
-
|
|
113
|
+
page: 0,
|
|
114
|
+
pageSize: 10,
|
|
95
115
|
});
|
|
96
116
|
const tableSearch = search ?? localSearch;
|
|
97
|
-
const result = useAtomValue(organizationsAtom(
|
|
98
|
-
baseUrl,
|
|
99
|
-
projectId,
|
|
100
|
-
reloadKey: reloadKey + refreshKey,
|
|
101
|
-
search: tableSearch,
|
|
102
|
-
}));
|
|
103
|
-
const deleteOrganization = useAtomSet(authClientApi(baseUrl).mutation("admin", "deleteOrganization"), { mode: "promise" });
|
|
117
|
+
const result = useAtomValue(organizationsAtom(baseUrl)(adminOrganizationsFamilyKey(tableSearch, projectId, reloadKey + refreshKey)));
|
|
104
118
|
const organizations = AsyncResult.match(result, {
|
|
105
119
|
onInitial: () => [],
|
|
106
120
|
onFailure: () => [],
|
|
@@ -121,11 +135,12 @@ export function AdminOrganizationsTable({ from, reloadKey = 0, search, }) {
|
|
|
121
135
|
onFailure: () => false,
|
|
122
136
|
onSuccess: () => false,
|
|
123
137
|
});
|
|
124
|
-
return (_jsxs("div", { className: "flex flex-col gap-4", children: [error ? _jsx(ErrorMessage, { text: error }) : null, _jsx(DataTable, {
|
|
125
|
-
columnVisibility:
|
|
138
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [error ? _jsx(ErrorMessage, { text: error }) : null, _jsx(DataTable, { columnDefs: organizationColumns(m, locale, baseUrl), rowData: organizations, features: {
|
|
139
|
+
columnVisibility: true,
|
|
126
140
|
export: { baseName: "organizations" },
|
|
127
141
|
gallery: false,
|
|
128
142
|
pagination: { mode: "server", rowCount: total },
|
|
143
|
+
refresh: () => setRefreshKey((current) => current + 1),
|
|
129
144
|
rowActions: {
|
|
130
145
|
items: [
|
|
131
146
|
{
|
|
@@ -142,16 +157,15 @@ export function AdminOrganizationsTable({ from, reloadKey = 0, search, }) {
|
|
|
142
157
|
},
|
|
143
158
|
],
|
|
144
159
|
},
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
onSearchChange
|
|
149
|
-
|
|
160
|
+
}, initialState: tableSearch, onStateChange: ({ page, pageSize, globalFilter, sort }) => {
|
|
161
|
+
const nextSearch = { page, pageSize, globalFilter, sort };
|
|
162
|
+
if (onSearchChange) {
|
|
163
|
+
onSearchChange(nextSearch);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
setLocalSearch(nextSearch);
|
|
150
167
|
}
|
|
151
|
-
|
|
152
|
-
await deleteOrganization({
|
|
153
|
-
params: { id: deletingOrganization.id },
|
|
154
|
-
});
|
|
168
|
+
}, status: { loading: isLoading } }), editingOrganization ? (_jsx(AdminOrganizationForm, { organization: editingOrganization, onClose: () => setEditingOrganization(null), onSaved: () => setRefreshKey((current) => current + 1) })) : null, deletingOrganization ? (_jsx(DeleteOrganizationDialog, { labels: m, organization: deletingOrganization, baseUrl: baseUrl, onClose: () => setDeletingOrganization(null), onDeleted: () => {
|
|
155
169
|
toast.success(m.organization_deleted_toast);
|
|
156
170
|
setDeletingOrganization(null);
|
|
157
171
|
setRefreshKey((current) => current + 1);
|
|
@@ -159,27 +173,22 @@ export function AdminOrganizationsTable({ from, reloadKey = 0, search, }) {
|
|
|
159
173
|
}
|
|
160
174
|
const organizationColumns = (m, locale, baseUrl) => [
|
|
161
175
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
accessorKey: "name",
|
|
168
|
-
header: m.admin_column_organization,
|
|
169
|
-
cell: ({ row }) => {
|
|
170
|
-
const display = organizationDisplay(row.original, locale, baseUrl);
|
|
171
|
-
return (_jsx(AppBrand, { to: null, label: display.name, subtitle: row.original.slug, icon: Building2, className: "min-w-56", ...(display.image ? { imageSrc: display.image } : {}) }));
|
|
176
|
+
field: "name",
|
|
177
|
+
headerName: m.admin_column_organization,
|
|
178
|
+
cellRenderer: ({ data }) => {
|
|
179
|
+
const display = organizationDisplay(data, locale, baseUrl);
|
|
180
|
+
return (_jsx(AppBrand, { to: null, label: display.name, subtitle: data.slug, icon: Building2, className: "min-w-56", ...(display.image ? { imageSrc: display.image } : {}) }));
|
|
172
181
|
},
|
|
173
182
|
},
|
|
174
183
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
184
|
+
field: "memberCount",
|
|
185
|
+
headerName: m.admin_column_members,
|
|
186
|
+
cellRenderer: ({ data }) => (_jsx(OrganizationMembers, { baseUrl: baseUrl, members: data.memberPreviews ?? [], total: data.memberCount ?? 0 })),
|
|
178
187
|
},
|
|
179
188
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
field: "projects",
|
|
190
|
+
headerName: m.admin_column_projects,
|
|
191
|
+
cellRenderer: ({ data }) => (_jsx(DataTableListSummary, { emptyLabel: "-", items: (data.projects ?? []).map((project) => {
|
|
183
192
|
const logo = assetUrl(project.logo, baseUrl);
|
|
184
193
|
return {
|
|
185
194
|
label: project.name,
|
|
@@ -189,9 +198,9 @@ const organizationColumns = (m, locale, baseUrl) => [
|
|
|
189
198
|
}), variant: "icon" })),
|
|
190
199
|
},
|
|
191
200
|
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
field: "createdAt",
|
|
202
|
+
headerName: m.admin_column_created,
|
|
203
|
+
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: new Date(data.createdAt).toLocaleDateString() })),
|
|
195
204
|
},
|
|
196
205
|
];
|
|
197
206
|
const initials = (name) => name
|
|
@@ -210,21 +219,22 @@ function OrganizationMembers({ baseUrl, members, total, }) {
|
|
|
210
219
|
};
|
|
211
220
|
}), totalCount: total, variant: "icon" }));
|
|
212
221
|
}
|
|
213
|
-
function DeleteOrganizationDialog({ labels: m, organization, onClose,
|
|
214
|
-
const [
|
|
215
|
-
const
|
|
216
|
-
|
|
222
|
+
function DeleteOrganizationDialog({ baseUrl, labels: m, organization, onClose, onDeleted, }) {
|
|
223
|
+
const [deleteOrganizationAtom] = useState(() => authClientApi(baseUrl).runtime.fn((id) => Effect.flatMap(authHttpClient(baseUrl), (http) => http.admin.deleteOrganization({ params: { id } }))));
|
|
224
|
+
const deleteOrganization = useAtomSet(deleteOrganizationAtom);
|
|
225
|
+
const result = useAtomValue(deleteOrganizationAtom);
|
|
226
|
+
useAtomSubscribe(deleteOrganizationAtom, (current) => {
|
|
227
|
+
if (AsyncResult.isSuccess(current))
|
|
228
|
+
onDeleted();
|
|
229
|
+
});
|
|
230
|
+
const error = AsyncResult.isFailure(result)
|
|
231
|
+
? Cause.squash(result.cause)
|
|
232
|
+
: undefined;
|
|
233
|
+
const isPending = !AsyncResult.isInitial(result) && result.waiting;
|
|
234
|
+
return (_jsx(AlertDialog, { open: true, onOpenChange: (open) => !open && onClose(), children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: m.organization_delete_title }), _jsx(AlertDialogDescription, { children: m.organization_delete_description.replace("{name}", organization.name) })] }), error ? (_jsx(ErrorMessage, { text: error instanceof Error
|
|
235
|
+
? error.message
|
|
236
|
+
: m.organization_delete_error })) : null, _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: isPending, children: m.organization_delete_cancel }), _jsx(AlertDialogAction, { disabled: isPending, onClick: (event) => {
|
|
217
237
|
event.preventDefault();
|
|
218
|
-
|
|
219
|
-
setIsPending(true);
|
|
220
|
-
try {
|
|
221
|
-
await onDelete();
|
|
222
|
-
}
|
|
223
|
-
catch (cause) {
|
|
224
|
-
setError(cause instanceof Error
|
|
225
|
-
? cause.message
|
|
226
|
-
: m.organization_delete_error);
|
|
227
|
-
setIsPending(false);
|
|
228
|
-
}
|
|
238
|
+
deleteOrganization(organization.id);
|
|
229
239
|
}, children: m.organization_delete_confirm })] })] }) }));
|
|
230
240
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
from?: ValidateFromPath;
|
|
1
|
+
import { type QueryType } from "@krak-stack/registry/query";
|
|
2
|
+
export declare function AdminUsersTable({ onSearchChange, reloadKey, search, }: {
|
|
3
|
+
onSearchChange?: (search: QueryType) => void;
|
|
5
4
|
reloadKey?: number;
|
|
6
|
-
search?:
|
|
5
|
+
search?: QueryType;
|
|
7
6
|
}): import("react").JSX.Element;
|
|
8
|
-
export declare function useAdminUsersTotal(search:
|
|
7
|
+
export declare function useAdminUsersTotal(search: QueryType): number;
|