@acmekit/dashboard 2.13.7 → 2.13.9
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/api-key-management-create-VWUERPPB.mjs +170 -0
- package/dist/api-key-management-detail-V4ENQHYY.mjs +306 -0
- package/dist/api-key-management-edit-R44OHS7B.mjs +106 -0
- package/dist/api-key-management-list-K2XPKF5E.mjs +400 -0
- package/dist/app.js +16765 -1370
- package/dist/app.mjs +786 -1030
- package/dist/chunk-22YYMH6M.mjs +382 -0
- package/dist/chunk-2U3RK3JG.mjs +474 -0
- package/dist/chunk-535OVBXR.mjs +226 -0
- package/dist/chunk-774WSTCC.mjs +19 -0
- package/dist/chunk-C76H5USB.mjs +16 -0
- package/dist/chunk-DFFLVEZ5.mjs +40 -0
- package/dist/chunk-DN3MIYQH.mjs +140 -0
- package/dist/chunk-DQCEH3X2.mjs +28 -0
- package/dist/chunk-DTY37DDZ.mjs +20 -0
- package/dist/chunk-EFRMWHRX.mjs +84 -0
- package/dist/chunk-FXYH54JP.mjs +16 -0
- package/dist/chunk-G22WWLPG.mjs +44 -0
- package/dist/chunk-G2VJOHHV.mjs +32 -0
- package/dist/chunk-GBFVWROS.mjs +58 -0
- package/dist/chunk-ITNQKZQQ.mjs +142 -0
- package/dist/chunk-IUCDCPJU.mjs +0 -0
- package/dist/chunk-LKWTBYYC.mjs +35 -0
- package/dist/{chunk-4VYJHIB3.mjs → chunk-ND3ODI36.mjs} +0 -72
- package/dist/chunk-OAHCJFG3.mjs +17 -0
- package/dist/chunk-RPAL6FHW.mjs +73 -0
- package/dist/{chunk-JSJZMTQG.mjs → chunk-RREPQMYC.mjs} +14 -41
- package/dist/chunk-S3REQHPQ.mjs +86 -0
- package/dist/chunk-S4DMV3ZT.mjs +35 -0
- package/dist/chunk-ST2YB7JN.mjs +74 -0
- package/dist/chunk-TCNCAWYD.mjs +9 -0
- package/dist/chunk-ULSPL3DR.mjs +126 -0
- package/dist/chunk-WILMJYUB.mjs +35 -0
- package/dist/chunk-XIM7X4FB.mjs +83 -0
- package/dist/chunk-YLPAZ2DP.mjs +1837 -0
- package/dist/chunk-YRWSG3YM.mjs +80 -0
- package/dist/{invite-S5USGDOZ.mjs → invite-XGPZZBUP.mjs} +15 -7
- package/dist/{login-AIMR26AL.mjs → login-GNP3QIPI.mjs} +25 -12
- package/dist/profile-detail-YX27F7N6.mjs +96 -0
- package/dist/profile-edit-2VRDU75O.mjs +173 -0
- package/dist/{reset-password-UQPRHMB3.mjs → reset-password-TWRNZO6Z.mjs} +7 -3
- package/dist/settings-3XWLL5LG.mjs +545 -0
- package/dist/translation-list-CCEQJNED.mjs +581 -0
- package/dist/translations-edit-E57GVUFV.mjs +5376 -0
- package/dist/user-detail-KUSRRVNX.mjs +169 -0
- package/dist/user-edit-HTN3ZGCL.mjs +114 -0
- package/dist/user-invite-E3FAAU3V.mjs +361 -0
- package/dist/user-list-KNJ5S3IM.mjs +1116 -0
- package/dist/user-metadata-5GQK75DT.mjs +425 -0
- package/dist/workflow-execution-detail-LZXCRVNC.mjs +819 -0
- package/dist/workflow-execution-list-HQ3V6TML.mjs +175 -0
- package/package.json +9 -9
- package/src/components/layout/settings-layout/settings-layout.tsx +8 -2
- package/src/dashboard-app/routes/get-route.map.tsx +1 -14
- package/src/hooks/api/api-keys.tsx +0 -49
- package/src/hooks/api/index.ts +0 -1
- package/src/providers/keybind-provider/hooks.tsx +0 -145
- package/src/routes/translations/translation-list/translation-list.tsx +10 -21
- package/src/routes/translations/translations-edit/translations-edit.tsx +14 -11
- package/src/vite-env.d.ts +3 -1
- package/dist/chunk-FBTP4AJM.mjs +0 -221
- package/dist/chunk-QYOO4QR6.mjs +0 -73
- package/src/components/data-table/helpers/sales-channels/index.ts +0 -4
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.tsx +0 -61
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.tsx +0 -22
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.tsx +0 -33
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-query.tsx +0 -30
- package/src/routes/api-key-management/api-key-management-detail/components/api-key-sales-channel-section/api-key-sales-channel-section.tsx +0 -206
- package/src/routes/api-key-management/api-key-management-detail/components/api-key-sales-channel-section/index.ts +0 -1
- package/src/routes/store/common/hooks/use-currencies-table-columns.tsx +0 -29
- package/src/routes/store/common/hooks/use-currencies-table-query.tsx +0 -21
- package/src/routes/store/common/hooks/use-locales-table-columns.tsx +0 -29
- package/src/routes/store/common/hooks/use-locales-table-query.tsx +0 -21
- package/src/routes/store/store-detail/components/store-general-section/index.ts +0 -1
- package/src/routes/store/store-detail/components/store-general-section/store-general-section.tsx +0 -48
- package/src/routes/store/store-detail/index.ts +0 -2
- package/src/routes/store/store-detail/loader.ts +0 -18
- package/src/routes/store/store-detail/store-detail.tsx +0 -42
- package/src/routes/store/store-edit/components/edit-store-form/edit-store-form.tsx +0 -83
- package/src/routes/store/store-edit/index.ts +0 -1
- package/src/routes/store/store-edit/store-edit.tsx +0 -25
- package/src/routes/store/store-metadata/index.ts +0 -1
- package/src/routes/store/store-metadata/store-metadata.tsx +0 -24
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import "./chunk-ST2YB7JN.mjs";
|
|
2
|
+
import "./chunk-GBFVWROS.mjs";
|
|
3
|
+
import "./chunk-EFRMWHRX.mjs";
|
|
4
|
+
import "./chunk-LKWTBYYC.mjs";
|
|
5
|
+
import "./chunk-ULSPL3DR.mjs";
|
|
6
|
+
import "./chunk-DN3MIYQH.mjs";
|
|
7
|
+
import "./chunk-XIM7X4FB.mjs";
|
|
8
|
+
import {
|
|
9
|
+
Skeleton
|
|
10
|
+
} from "./chunk-ITNQKZQQ.mjs";
|
|
11
|
+
import {
|
|
12
|
+
ConditionalTooltip
|
|
13
|
+
} from "./chunk-OAHCJFG3.mjs";
|
|
14
|
+
import {
|
|
15
|
+
useDocumentDirection
|
|
16
|
+
} from "./chunk-S4DMV3ZT.mjs";
|
|
17
|
+
import "./chunk-IUCDCPJU.mjs";
|
|
18
|
+
import {
|
|
19
|
+
KeyboundForm,
|
|
20
|
+
RouteDrawer,
|
|
21
|
+
useRouteModal
|
|
22
|
+
} from "./chunk-2U3RK3JG.mjs";
|
|
23
|
+
import {
|
|
24
|
+
Form
|
|
25
|
+
} from "./chunk-ND3ODI36.mjs";
|
|
26
|
+
import {
|
|
27
|
+
useUpdateUser,
|
|
28
|
+
useUser
|
|
29
|
+
} from "./chunk-YRWSG3YM.mjs";
|
|
30
|
+
import "./chunk-FXYH54JP.mjs";
|
|
31
|
+
import "./chunk-774WSTCC.mjs";
|
|
32
|
+
import "./chunk-DTY37DDZ.mjs";
|
|
33
|
+
import "./chunk-QZ7TP4HQ.mjs";
|
|
34
|
+
|
|
35
|
+
// src/routes/users/user-metadata/user-metadata.tsx
|
|
36
|
+
import { useParams } from "react-router-dom";
|
|
37
|
+
|
|
38
|
+
// src/components/forms/metadata-form/metadata-form.tsx
|
|
39
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
40
|
+
import {
|
|
41
|
+
Button,
|
|
42
|
+
DropdownMenu,
|
|
43
|
+
Heading,
|
|
44
|
+
IconButton,
|
|
45
|
+
InlineTip,
|
|
46
|
+
clx,
|
|
47
|
+
toast
|
|
48
|
+
} from "@acmekit/ui";
|
|
49
|
+
import { useFieldArray, useForm } from "react-hook-form";
|
|
50
|
+
import { useTranslation } from "react-i18next";
|
|
51
|
+
import { z } from "zod";
|
|
52
|
+
import {
|
|
53
|
+
ArrowDownMini,
|
|
54
|
+
ArrowUpMini,
|
|
55
|
+
EllipsisVertical,
|
|
56
|
+
Trash
|
|
57
|
+
} from "@acmekit/icons";
|
|
58
|
+
import { forwardRef } from "react";
|
|
59
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
60
|
+
var MetadataFieldSchema = z.object({
|
|
61
|
+
key: z.string(),
|
|
62
|
+
disabled: z.boolean().optional(),
|
|
63
|
+
value: z.any()
|
|
64
|
+
});
|
|
65
|
+
var MetadataSchema = z.object({
|
|
66
|
+
metadata: z.array(MetadataFieldSchema)
|
|
67
|
+
});
|
|
68
|
+
var MetadataForm = (props) => {
|
|
69
|
+
const { t } = useTranslation();
|
|
70
|
+
const { isPending, ...innerProps } = props;
|
|
71
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
72
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: t("metadata.edit.header") }) }),
|
|
74
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: t("metadata.edit.description") })
|
|
75
|
+
] }),
|
|
76
|
+
isPending ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(InnerForm, { ...innerProps })
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
var METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
80
|
+
var METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
81
|
+
var InnerForm = ({
|
|
82
|
+
metadata,
|
|
83
|
+
hook,
|
|
84
|
+
isMutating
|
|
85
|
+
}) => {
|
|
86
|
+
const { t } = useTranslation();
|
|
87
|
+
const { handleSuccess } = useRouteModal();
|
|
88
|
+
const direction = useDocumentDirection();
|
|
89
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
90
|
+
const form = useForm({
|
|
91
|
+
defaultValues: {
|
|
92
|
+
metadata: getDefaultValues(metadata)
|
|
93
|
+
},
|
|
94
|
+
resolver: zodResolver(MetadataSchema)
|
|
95
|
+
});
|
|
96
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
97
|
+
const parsedData = parseValues(data, metadata);
|
|
98
|
+
await hook(
|
|
99
|
+
{
|
|
100
|
+
metadata: parsedData
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
onSuccess: () => {
|
|
104
|
+
toast.success(t("metadata.edit.successToast"));
|
|
105
|
+
handleSuccess();
|
|
106
|
+
},
|
|
107
|
+
onError: (error) => {
|
|
108
|
+
toast.error(error.message);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
const { fields, insert, remove } = useFieldArray({
|
|
114
|
+
control: form.control,
|
|
115
|
+
name: "metadata"
|
|
116
|
+
});
|
|
117
|
+
function deleteRow(index) {
|
|
118
|
+
remove(index);
|
|
119
|
+
if (fields.length === 1) {
|
|
120
|
+
insert(0, {
|
|
121
|
+
key: "",
|
|
122
|
+
value: "",
|
|
123
|
+
disabled: false
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function insertRow(index, position) {
|
|
128
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
129
|
+
key: "",
|
|
130
|
+
value: "",
|
|
131
|
+
disabled: false
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
135
|
+
KeyboundForm,
|
|
136
|
+
{
|
|
137
|
+
onSubmit: handleSubmit,
|
|
138
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
141
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: t("metadata.edit.labels.key") }) }),
|
|
144
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: t("metadata.edit.labels.value") }) })
|
|
145
|
+
] }),
|
|
146
|
+
fields.map((field, index) => {
|
|
147
|
+
const isDisabled = field.disabled || false;
|
|
148
|
+
let placeholder = "-";
|
|
149
|
+
if (typeof field.value === "object") {
|
|
150
|
+
placeholder = "{ ... }";
|
|
151
|
+
}
|
|
152
|
+
if (Array.isArray(field.value)) {
|
|
153
|
+
placeholder = "[ ... ]";
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsx(
|
|
156
|
+
ConditionalTooltip,
|
|
157
|
+
{
|
|
158
|
+
showTooltip: isDisabled,
|
|
159
|
+
content: t("metadata.edit.complexRow.tooltip"),
|
|
160
|
+
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
161
|
+
/* @__PURE__ */ jsxs(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
className: clx("grid grid-cols-2 divide-x", {
|
|
165
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
166
|
+
}),
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
Form.Field,
|
|
170
|
+
{
|
|
171
|
+
control: form.control,
|
|
172
|
+
name: `metadata.${index}.key`,
|
|
173
|
+
render: ({ field: field2 }) => {
|
|
174
|
+
return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
175
|
+
GridInput,
|
|
176
|
+
{
|
|
177
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
178
|
+
...field2,
|
|
179
|
+
disabled: isDisabled,
|
|
180
|
+
placeholder: "Key"
|
|
181
|
+
}
|
|
182
|
+
) }) });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ jsx(
|
|
187
|
+
Form.Field,
|
|
188
|
+
{
|
|
189
|
+
control: form.control,
|
|
190
|
+
name: `metadata.${index}.value`,
|
|
191
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
192
|
+
return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
193
|
+
GridInput,
|
|
194
|
+
{
|
|
195
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
196
|
+
...field2,
|
|
197
|
+
value: isDisabled ? placeholder : value,
|
|
198
|
+
disabled: isDisabled,
|
|
199
|
+
placeholder: "Value"
|
|
200
|
+
}
|
|
201
|
+
) }) });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ jsxs(
|
|
209
|
+
DropdownMenu,
|
|
210
|
+
{
|
|
211
|
+
dir: direction,
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
DropdownMenu.Trigger,
|
|
215
|
+
{
|
|
216
|
+
className: clx(
|
|
217
|
+
"invisible absolute inset-y-0 -end-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
218
|
+
{
|
|
219
|
+
hidden: isDisabled
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
disabled: isDisabled,
|
|
223
|
+
asChild: true,
|
|
224
|
+
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
228
|
+
/* @__PURE__ */ jsxs(
|
|
229
|
+
DropdownMenu.Item,
|
|
230
|
+
{
|
|
231
|
+
className: "gap-x-2",
|
|
232
|
+
onClick: () => insertRow(index, "above"),
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
235
|
+
t("metadata.edit.actions.insertRowAbove")
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
/* @__PURE__ */ jsxs(
|
|
240
|
+
DropdownMenu.Item,
|
|
241
|
+
{
|
|
242
|
+
className: "gap-x-2",
|
|
243
|
+
onClick: () => insertRow(index, "below"),
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
246
|
+
t("metadata.edit.actions.insertRowBelow")
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
251
|
+
/* @__PURE__ */ jsxs(
|
|
252
|
+
DropdownMenu.Item,
|
|
253
|
+
{
|
|
254
|
+
className: "gap-x-2",
|
|
255
|
+
onClick: () => deleteRow(index),
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
258
|
+
t("metadata.edit.actions.deleteRow")
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
] })
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] })
|
|
267
|
+
},
|
|
268
|
+
field.id
|
|
269
|
+
);
|
|
270
|
+
})
|
|
271
|
+
] }),
|
|
272
|
+
hasUneditableRows && /* @__PURE__ */ jsx(
|
|
273
|
+
InlineTip,
|
|
274
|
+
{
|
|
275
|
+
variant: "warning",
|
|
276
|
+
label: t("metadata.edit.complexRow.label"),
|
|
277
|
+
children: t("metadata.edit.complexRow.description")
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
282
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
283
|
+
Button,
|
|
284
|
+
{
|
|
285
|
+
size: "small",
|
|
286
|
+
variant: "secondary",
|
|
287
|
+
type: "button",
|
|
288
|
+
disabled: isMutating,
|
|
289
|
+
children: t("actions.cancel")
|
|
290
|
+
}
|
|
291
|
+
) }),
|
|
292
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isMutating, children: t("actions.save") })
|
|
293
|
+
] }) })
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
) });
|
|
297
|
+
};
|
|
298
|
+
var GridInput = forwardRef(({ className, ...props }, ref) => {
|
|
299
|
+
return /* @__PURE__ */ jsx(
|
|
300
|
+
"input",
|
|
301
|
+
{
|
|
302
|
+
ref,
|
|
303
|
+
...props,
|
|
304
|
+
autoComplete: "off",
|
|
305
|
+
className: clx(
|
|
306
|
+
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
307
|
+
className
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
});
|
|
312
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
313
|
+
var PlaceholderInner = () => {
|
|
314
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
315
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
316
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
317
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
318
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
319
|
+
] }) })
|
|
320
|
+
] });
|
|
321
|
+
};
|
|
322
|
+
var EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
323
|
+
function getDefaultValues(metadata) {
|
|
324
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
325
|
+
return [
|
|
326
|
+
{
|
|
327
|
+
key: "",
|
|
328
|
+
value: "",
|
|
329
|
+
disabled: false
|
|
330
|
+
}
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
334
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
335
|
+
return {
|
|
336
|
+
key,
|
|
337
|
+
value,
|
|
338
|
+
disabled: true
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
let stringValue = value;
|
|
342
|
+
if (typeof value !== "string") {
|
|
343
|
+
stringValue = JSON.stringify(value);
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
key,
|
|
347
|
+
value: stringValue,
|
|
348
|
+
original_key: key
|
|
349
|
+
};
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function parseValues(values, original) {
|
|
353
|
+
const metadata = values.metadata;
|
|
354
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
355
|
+
if (isEmpty) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
const update = {};
|
|
359
|
+
if (original) {
|
|
360
|
+
Object.keys(original).forEach((originalKey) => {
|
|
361
|
+
const exists = metadata.some((field) => field.key === originalKey);
|
|
362
|
+
if (!exists) {
|
|
363
|
+
update[originalKey] = "";
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
metadata.forEach((field) => {
|
|
368
|
+
let key = field.key;
|
|
369
|
+
let value = field.value;
|
|
370
|
+
const disabled = field.disabled;
|
|
371
|
+
if (!key) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (disabled) {
|
|
375
|
+
update[key] = value;
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
key = key.trim();
|
|
379
|
+
value = value?.trim() ?? "";
|
|
380
|
+
if (value === "true") {
|
|
381
|
+
update[key] = true;
|
|
382
|
+
} else if (value === "false") {
|
|
383
|
+
update[key] = false;
|
|
384
|
+
} else {
|
|
385
|
+
const isNumeric = /^-?\d*\.?\d+$/.test(value);
|
|
386
|
+
if (isNumeric) {
|
|
387
|
+
update[key] = parseFloat(value);
|
|
388
|
+
} else {
|
|
389
|
+
update[key] = value;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
return update;
|
|
394
|
+
}
|
|
395
|
+
function getHasUneditableRows(metadata) {
|
|
396
|
+
if (!metadata) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
return Object.values(metadata).some(
|
|
400
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// src/routes/users/user-metadata/user-metadata.tsx
|
|
405
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
406
|
+
var UserMetadata = () => {
|
|
407
|
+
const { id } = useParams();
|
|
408
|
+
const { user, isPending, isError, error } = useUser(id);
|
|
409
|
+
const { mutateAsync, isPending: isMutating } = useUpdateUser(id);
|
|
410
|
+
if (isError) {
|
|
411
|
+
throw error;
|
|
412
|
+
}
|
|
413
|
+
return /* @__PURE__ */ jsx2(RouteDrawer, { children: /* @__PURE__ */ jsx2(
|
|
414
|
+
MetadataForm,
|
|
415
|
+
{
|
|
416
|
+
isPending,
|
|
417
|
+
isMutating,
|
|
418
|
+
hook: mutateAsync,
|
|
419
|
+
metadata: user?.metadata
|
|
420
|
+
}
|
|
421
|
+
) });
|
|
422
|
+
};
|
|
423
|
+
export {
|
|
424
|
+
UserMetadata as Component
|
|
425
|
+
};
|