@sensinum/strapi-plugin-multi-domain 5.2.2 → 5.3.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/{_chunks/About-BwHHM2-e.mjs → admin/About-DfCon-RP.mjs} +5 -5
- package/dist/{_chunks/About-BMKe8Nmq.js → admin/About-DfcPwQ3q.js} +2 -2
- package/dist/admin/QueryProvider-CCX1cgmZ.js +1 -0
- package/dist/{_chunks/QueryProvider-DLzv0qqi.mjs → admin/QueryProvider-oO97LaUB.mjs} +2 -2
- package/dist/{_chunks/Settings-v1cjVAKt.mjs → admin/Settings-Dj3h2ayB.mjs} +3 -3
- package/dist/{_chunks/Settings-dlu3XY5j.js → admin/Settings-tt-Wetcr.js} +1 -1
- package/dist/{_chunks/TenantCustomField-cjk2h9Sy.js → admin/TenantCustomField-Bf6uUoKE.js} +1 -1
- package/dist/{_chunks/TenantCustomField-Cc17Wct3.mjs → admin/TenantCustomField-CS8x0CkO.mjs} +24 -24
- package/dist/admin/TenantEdit-BT3-tB_B.js +1 -0
- package/dist/admin/TenantEdit-BY_7PPAr.mjs +490 -0
- package/dist/admin/TenantList-DrfJNPpi.js +1 -0
- package/dist/{_chunks/TenantList-CONeayj-.mjs → admin/TenantList-dIxGcZPl.mjs} +43 -45
- package/dist/{_chunks/index-D6ydxf5B.mjs → admin/index-7tHbI_K_.mjs} +55 -54
- package/dist/admin/index-Cci_046h.js +1 -0
- package/dist/admin/index-Doprxev-.mjs +187 -0
- package/dist/admin/index-oNXgzV7S.js +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/{_chunks/useGetMessage-B8BN0qvw.mjs → admin/useGetMessage-CTdHvgbI.mjs} +1 -1
- package/dist/admin/useGetMessage-DS88gOrN.js +1 -0
- package/dist/admin/useSettings-C7vR1hfw.js +1 -0
- package/dist/{_chunks/useSettings-CimYpZ4J.mjs → admin/useSettings-bLTyn7Pl.mjs} +2 -2
- package/dist/{_chunks/useTenants-DezjZnH2.mjs → admin/useTenants-Da8khjOe.mjs} +4 -4
- package/dist/admin/useTenants-vVkOIEvT.js +1 -0
- package/dist/server/index.js +4 -6
- package/dist/server/index.mjs +3396 -7192
- package/package.json +20 -21
- package/dist/_chunks/QueryProvider-DUoM4JhC.js +0 -1
- package/dist/_chunks/TenantEdit-BTFMfW4k.js +0 -1
- package/dist/_chunks/TenantEdit-CVAR1Ief.mjs +0 -494
- package/dist/_chunks/TenantList-D2kRXKow.js +0 -1
- package/dist/_chunks/index-Bmegt3iZ.js +0 -1
- package/dist/_chunks/index-BoaWY6pN.js +0 -1
- package/dist/_chunks/index-DMvlWHGg.mjs +0 -182
- package/dist/_chunks/useGetMessage-Qu_lnA6t.js +0 -1
- package/dist/_chunks/useSettings-Bvg8rV47.js +0 -1
- package/dist/_chunks/useTenants-BWUvXqt6.js +0 -1
- package/dist/shared/config.d.ts +0 -7
- package/dist/shared/config.d.ts.map +0 -1
- package/dist/shared/permissions.d.ts +0 -35
- package/dist/shared/permissions.d.ts.map +0 -1
- package/dist/shared/pluginIds.d.ts +0 -9
- package/dist/shared/pluginIds.d.ts.map +0 -1
- package/dist/shared/schemas/admin.d.ts +0 -26
- package/dist/shared/schemas/admin.d.ts.map +0 -1
- package/dist/shared/schemas/index.d.ts +0 -8
- package/dist/shared/schemas/index.d.ts.map +0 -1
- package/dist/shared/schemas/permision.schema.d.ts +0 -28
- package/dist/shared/schemas/permision.schema.d.ts.map +0 -1
- package/dist/shared/schemas/query-params.schema.d.ts +0 -19
- package/dist/shared/schemas/query-params.schema.d.ts.map +0 -1
- package/dist/shared/schemas/role.schema.d.ts +0 -101
- package/dist/shared/schemas/role.schema.d.ts.map +0 -1
- package/dist/shared/schemas/tenant.schema.d.ts +0 -428
- package/dist/shared/schemas/tenant.schema.d.ts.map +0 -1
- package/dist/shared/schemas/token.schema.d.ts +0 -13
- package/dist/shared/schemas/token.schema.d.ts.map +0 -1
- package/dist/shared/schemas/uniq-validation.schema.d.ts +0 -18
- package/dist/shared/schemas/uniq-validation.schema.d.ts.map +0 -1
- package/dist/shared/schemas/utils.d.ts +0 -3
- package/dist/shared/schemas/utils.d.ts.map +0 -1
- /package/dist/{_chunks → admin}/en-Cf69p5po.mjs +0 -0
- /package/dist/{_chunks → admin}/en-hAVH8fH0.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),e=require("@tanstack/react-query"),i=new e.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,staleTime:300*1e3,gcTime:600*1e3},mutations:{retry:!1}}}),s=({children:r})=>t.jsx(e.QueryClientProvider,{client:i,children:r});exports.QueryProvider=s;
|
|
@@ -2,9 +2,9 @@ import { jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
|
2
2
|
import { lightTheme as i, darkTheme as a, DesignSystemProvider as n } from "@strapi/design-system";
|
|
3
3
|
import r from "react";
|
|
4
4
|
import { Routes as s, Route as t, Navigate as l } from "react-router-dom";
|
|
5
|
-
import { p, m as d } from "./index-
|
|
6
|
-
import { Q as h } from "./QueryProvider-
|
|
7
|
-
const c = r.lazy(() => import("./TenantList-
|
|
5
|
+
import { p, m as d } from "./index-7tHbI_K_.mjs";
|
|
6
|
+
import { Q as h } from "./QueryProvider-oO97LaUB.mjs";
|
|
7
|
+
const c = r.lazy(() => import("./TenantList-dIxGcZPl.mjs")), g = r.lazy(() => import("./TenantEdit-BY_7PPAr.mjs")), P = () => {
|
|
8
8
|
const o = localStorage.getItem("STRAPI_THEME") === "light" ? i : a;
|
|
9
9
|
return /* @__PURE__ */ e(n, { theme: o, children: /* @__PURE__ */ e(h, { children: /* @__PURE__ */ m(s, { children: [
|
|
10
10
|
/* @__PURE__ */ e(t, { path: "", element: /* @__PURE__ */ e(c, {}) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@strapi/design-system"),i=require("react"),r=require("react-router-dom"),o=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@strapi/design-system"),i=require("react"),r=require("react-router-dom"),o=require("./index-oNXgzV7S.js"),u=require("./QueryProvider-CCX1cgmZ.js"),a=t=>t&&t.__esModule?t:{default:t},n=a(i),l=n.default.lazy(()=>Promise.resolve().then(()=>require("./TenantList-DrfJNPpi.js"))),c=n.default.lazy(()=>Promise.resolve().then(()=>require("./TenantEdit-BT3-tB_B.js"))),d=()=>{const t=localStorage.getItem("STRAPI_THEME")==="light"?s.lightTheme:s.darkTheme;return e.jsx(s.DesignSystemProvider,{theme:t,children:e.jsx(u.QueryProvider,{children:e.jsxs(r.Routes,{children:[e.jsx(r.Route,{path:"",element:e.jsx(l,{})}),e.jsx(r.Route,{path:"/:id",element:e.jsx(c,{})}),e.jsx(r.Route,{path:"*",element:e.jsx(r.Navigate,{to:`/settings/${o.pluginId}/${o.modelRoute}`,replace:!0})})]})})})};exports.default=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("@strapi/design-system"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("@strapi/design-system"),f=require("@strapi/strapi/admin"),e=require("zod"),F=require("react"),S=require("@tanstack/react-query"),q=require("./index-Cci_046h.js"),p=require("./QueryProvider-CCX1cgmZ.js"),C=require("remeda"),M=t=>t&&t.__esModule?t:{default:t},_=M(F),g=e.z.object({modified:e.z.boolean(),isSubmitting:e.z.boolean(),disabled:e.z.boolean(),values:e.z.record(e.z.any()),initialValues:e.z.record(e.z.any()),errors:e.z.record(e.z.any()),onChange:e.z.function().args(e.z.object({target:e.z.object({name:e.z.string(),value:e.z.any()})})).returns(e.z.void()),resetForm:e.z.function().returns(e.z.void())}),P=t=>{const r=f.unstable_useContentManagerContext(),{form:o}=r,u=t?g.merge(t):g;return _.default.useMemo(()=>({...r,form:u.passthrough().parse(o)}),[r,o,u])},R=()=>S.useMutation({mutationFn:async t=>q.api.validateCustomField(t)}),T=e.z.object({setSubmitting:e.z.function().args(e.z.boolean()).returns(e.z.void())}),Q=({disabled:t,placeholder:r,required:o,hint:u,value:z,onChange:c,label:b,name:i,rawError:l})=>{const{id:y,model:v,form:d}=P(T),m=R(),{toggleNotification:j}=f.useNotification(),x=async h=>{try{d.setSubmitting(!0);const s=await m.mutateAsync({model:v,field:i,documentId:y,value:h.target.value});c({target:{value:s.value,name:i}})}catch(s){j({type:"danger",message:s instanceof Error?s.message:s.toString()})}finally{d.setSubmitting(!1)}};return n.jsxs(a.Field.Root,{name:i,hint:m.isPending?"Validating...":u,required:o,error:l?.defaultMessage,children:[n.jsx(a.Field.Label,{children:C.capitalize(b)}),n.jsx(a.TextInput,{name:i,value:z,onChange:c,onBlur:x,placeholder:r,disabled:t,hasError:!!l,"aria-describedby":`${i}-hint`,"aria-required":o}),n.jsx(a.Field.Hint,{}),n.jsx(a.Field.Error,{})]})},V=t=>n.jsx(p.QueryProvider,{children:n.jsx(Q,{...t})});exports.default=V;
|
package/dist/{_chunks/TenantCustomField-Cc17Wct3.mjs → admin/TenantCustomField-CS8x0CkO.mjs}
RENAMED
|
@@ -4,8 +4,8 @@ import { unstable_useContentManagerContext as x, useNotification as j } from "@s
|
|
|
4
4
|
import { z as t } from "zod";
|
|
5
5
|
import M from "react";
|
|
6
6
|
import { useMutation as P } from "@tanstack/react-query";
|
|
7
|
-
import { a as T } from "./index-
|
|
8
|
-
import { Q as V } from "./QueryProvider-
|
|
7
|
+
import { a as T } from "./index-Doprxev-.mjs";
|
|
8
|
+
import { Q as V } from "./QueryProvider-oO97LaUB.mjs";
|
|
9
9
|
import { capitalize as z } from "remeda";
|
|
10
10
|
const f = t.object({
|
|
11
11
|
modified: t.boolean(),
|
|
@@ -25,35 +25,35 @@ const f = t.object({
|
|
|
25
25
|
}),
|
|
26
26
|
[r, n, s]
|
|
27
27
|
);
|
|
28
|
-
},
|
|
28
|
+
}, E = () => P({
|
|
29
29
|
mutationFn: async (e) => T.validateCustomField(e)
|
|
30
|
-
}),
|
|
30
|
+
}), I = t.object({
|
|
31
31
|
setSubmitting: t.function().args(t.boolean()).returns(t.void())
|
|
32
|
-
}),
|
|
32
|
+
}), N = ({
|
|
33
33
|
disabled: e,
|
|
34
34
|
placeholder: r,
|
|
35
35
|
required: n,
|
|
36
36
|
hint: s,
|
|
37
37
|
value: g,
|
|
38
|
-
onChange:
|
|
38
|
+
onChange: l,
|
|
39
39
|
label: b,
|
|
40
|
-
name:
|
|
41
|
-
rawError:
|
|
40
|
+
name: a,
|
|
41
|
+
rawError: c
|
|
42
42
|
}) => {
|
|
43
|
-
const { id: p, model:
|
|
43
|
+
const { id: p, model: h, form: m } = B(I), d = E(), { toggleNotification: v } = j(), y = async (C) => {
|
|
44
44
|
try {
|
|
45
45
|
m.setSubmitting(!0);
|
|
46
|
-
const
|
|
47
|
-
model:
|
|
48
|
-
field:
|
|
46
|
+
const i = await d.mutateAsync({
|
|
47
|
+
model: h,
|
|
48
|
+
field: a,
|
|
49
49
|
documentId: p,
|
|
50
50
|
value: C.target.value
|
|
51
51
|
});
|
|
52
|
-
|
|
53
|
-
} catch (
|
|
54
|
-
|
|
52
|
+
l({ target: { value: i.value, name: a } });
|
|
53
|
+
} catch (i) {
|
|
54
|
+
v({
|
|
55
55
|
type: "danger",
|
|
56
|
-
message:
|
|
56
|
+
message: i instanceof Error ? i.message : i.toString()
|
|
57
57
|
});
|
|
58
58
|
} finally {
|
|
59
59
|
m.setSubmitting(!1);
|
|
@@ -62,23 +62,23 @@ const f = t.object({
|
|
|
62
62
|
return /* @__PURE__ */ F(
|
|
63
63
|
u.Root,
|
|
64
64
|
{
|
|
65
|
-
name:
|
|
65
|
+
name: a,
|
|
66
66
|
hint: d.isPending ? "Validating..." : s,
|
|
67
67
|
required: n,
|
|
68
|
-
error:
|
|
68
|
+
error: c?.defaultMessage,
|
|
69
69
|
children: [
|
|
70
70
|
/* @__PURE__ */ o(u.Label, { children: z(b) }),
|
|
71
71
|
/* @__PURE__ */ o(
|
|
72
72
|
S,
|
|
73
73
|
{
|
|
74
|
-
name:
|
|
74
|
+
name: a,
|
|
75
75
|
value: g,
|
|
76
|
-
onChange:
|
|
77
|
-
onBlur:
|
|
76
|
+
onChange: l,
|
|
77
|
+
onBlur: y,
|
|
78
78
|
placeholder: r,
|
|
79
79
|
disabled: e,
|
|
80
|
-
|
|
81
|
-
"aria-describedby": `${
|
|
80
|
+
hasError: !!c,
|
|
81
|
+
"aria-describedby": `${a}-hint`,
|
|
82
82
|
"aria-required": n
|
|
83
83
|
}
|
|
84
84
|
),
|
|
@@ -87,7 +87,7 @@ const f = t.object({
|
|
|
87
87
|
]
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
|
-
}, w = (e) => /* @__PURE__ */ o(V, { children: /* @__PURE__ */ o(
|
|
90
|
+
}, w = (e) => /* @__PURE__ */ o(V, { children: /* @__PURE__ */ o(N, { ...e }) });
|
|
91
91
|
export {
|
|
92
92
|
w as default
|
|
93
93
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var B=Object.defineProperty;var G=(n,o,i)=>o in n?B(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i;var L=(n,o,i)=>G(n,typeof o!="symbol"?o+"":o,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),p=require("@strapi/strapi/admin"),v=require("react"),M=require("react-router-dom"),N=require("remeda"),h=require("./index-oNXgzV7S.js"),j=require("./useGetMessage-DS88gOrN.js"),R=require("./useTenants-vVkOIEvT.js"),q=require("@strapi/icons"),w=require("@tanstack/react-query"),I=require("./index-Cci_046h.js"),H=n=>n&&n.__esModule?n:{default:n},P=H(v),O=({isEditing:n,isSaving:o,onCancel:i})=>{const s=j.useGetMessage();return e.jsx(t.Flex,{justifyContent:"flex-start",gap:2,direction:"column",height:"100%",width:"100%",children:e.jsxs(t.Box,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0,width:"100%",children:[e.jsx(t.Typography,{variant:"sigma",textTransform:"uppercase",textColor:"neutral600",tag:"h2",marginBottom:4,children:s("domain.edit.actions.entry")}),e.jsxs(t.Flex,{direction:"column",gap:2,children:[e.jsx(R.CheckPermissions,{permissions:n?h.permissions.admin.edit:h.permissions.admin.create,children:e.jsx(t.Button,{type:"submit",loading:o,width:"100%",children:s(n?"domain.edit.actions.update":"domain.edit.actions.create")})}),e.jsx(t.Button,{variant:"secondary",onClick:i,width:"100%",children:s("common.cancel")})]})]})})},A=({isEditing:n,tenantName:o})=>{const i=j.useGetMessage(),s=n?o||i("domain.edit.title.edit",{values:{name:h.modelId}}):i("domain.edit.title.create");return e.jsx(p.Layouts.Header,{title:typeof s=="string"?s:String(s),navigationAction:e.jsx(t.Link,{tag:M.NavLink,startIcon:e.jsx(q.ArrowLeft,{}),to:`/settings/${h.pluginId}/${h.modelRoute}`,children:i("common.back")})})},$=({disabled:n=!1,error:o})=>{const i=j.useGetMessage(),s=p.useStrapiApp("CustomMediaInput",a=>a.fields?.media||{});return s?e.jsxs(t.Field.Root,{name:"logo",hint:i("domain.edit.form.logo.hint"),error:o,children:[e.jsx(s,{label:"Logo",name:"logo",disabled:n,attribute:{allowedTypes:["images"],multiple:!1}}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}):null},C={all:["roles"],lists:()=>[...C.all,"list"]},J=()=>w.useQuery({queryKey:C.lists(),queryFn:()=>I.api.getRoles(),staleTime:600*1e3}),W=({value:n,onChange:o,disabled:i=!1,error:s,onLoadMore:a,onSearch:l})=>{const{data:d=[],isLoading:u}=J(),x=j.useGetMessage(),f=()=>{o({target:{name:"role",value:""}})},F=g=>{o({target:{name:"role",value:g}})},b=v.useCallback(g=>{const S=g.target.value;l&&l(S)},[l]),k=v.useCallback(()=>{a&&!u&&a()},[a,u]);return e.jsxs(t.Field.Root,{name:"role",hint:x("domain.edit.form.role.hint"),error:s,children:[e.jsx(t.Field.Label,{children:x("domain.edit.form.role.label")}),e.jsx(t.Combobox,{loading:u,hasMoreItems:!u,name:"role",disabled:i,value:n,onChange:F,placeholder:x("domain.edit.form.role.placeholder"),onInputChange:b,onLoadMore:k,children:d.map(g=>e.jsx(t.ComboboxOption,{value:g.id.toString(),children:g.name},g.id))}),n&&d.length>0&&e.jsxs(t.Flex,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderColor:"neutral200",background:"neutral0",justifyContent:"space-between",children:[e.jsx(t.Typography,{textColor:"neutral800",fontWeight:"bold",children:d.find(g=>g.id.toString()===n)?.name}),i?null:e.jsx(t.Box,{children:e.jsx(t.IconButton,{onClick:f,label:x("domain.edit.form.role.remove"),variant:"ghost",size:"S",children:e.jsx(q.Cross,{})})})]}),e.jsx(t.Field.Hint,{})]})},D={all:["tokens"],lists:()=>[...D.all,"list"]},_=()=>w.useQuery({queryKey:D.lists(),queryFn:()=>I.api.getTokens(),staleTime:600*1e3}),K=({value:n=[],onChange:o,disabled:i=!1,error:s})=>{const{data:a=[]}=_(),l=j.useGetMessage(),d=u=>{const x=u.map(f=>Number(f));o({target:{name:"tokens",value:x}})};return e.jsxs(t.Field.Root,{name:"tokens",hint:l("domain.edit.form.tokens.hint"),error:s,children:[e.jsx(t.Field.Label,{children:l("domain.edit.form.tokens.label")}),e.jsx(t.MultiSelect,{withTags:!0,name:"tokens",disabled:i,value:n.map(u=>u.toString()),onChange:d,placeholder:l("domain.edit.form.tokens.placeholder"),children:a.map(u=>e.jsx(t.MultiSelectOption,{value:u.id.toString(),children:u.name},u.id.toString()))}),e.jsx(t.Field.Hint,{})]})},T=n=>{if(typeof n=="string")return n;if(n&&typeof n=="object"&&"defaultMessage"in n){const o=n.defaultMessage;return typeof o=="string"?o:void 0}},V=({values:n,onChange:o,disabled:i,errors:s})=>{const a=j.useGetMessage(),l=d=>{o({target:{name:"customFields",value:d}})};return e.jsx(t.Box,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0,width:"100%",children:e.jsxs(t.Flex,{direction:"column",alignItems:"stretch",gap:6,children:[e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsxs(t.Field.Root,{name:"name",required:!0,hint:a("domain.edit.form.name.hint"),error:T(s.name),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.name.label")}),e.jsx(t.TextInput,{disabled:i,name:"name",value:n.name,onChange:o,placeholder:a("domain.edit.form.name.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsxs(t.Field.Root,{name:"code",required:!0,hint:a("domain.edit.form.code.hint"),error:T(s.code),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.code.label")}),e.jsx(t.TextInput,{disabled:i,name:"code",value:n.code,onChange:o,placeholder:a("domain.edit.form.code.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})})]}),e.jsx($,{value:n.logo,onChange:o,disabled:i,error:s.logo?.toString()}),e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(W,{value:n.role,onChange:o,disabled:i,error:s.role?.toString()})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(K,{value:n.tokens||[],onChange:o,disabled:i,error:s.tokens?.toString()})})]}),e.jsxs(t.Field.Root,{name:"damRootDirectory",hint:a("domain.edit.form.damRootDirectory.hint"),error:T(s.damRootDirectory),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.damRootDirectory.label")}),e.jsx(t.TextInput,{disabled:i,name:"damRootDirectory",value:n.damRootDirectory,onChange:o,placeholder:a("domain.edit.form.damRootDirectory.placeholder")}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}),e.jsxs(t.Field.Root,{name:"customFields",hint:a("domain.edit.form.customFields.hint"),error:T(s.customFields),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.customFields.label")}),e.jsx(t.JSONInput,{value:n.customFields,onChange:l,minHeight:"200px"}),e.jsx(t.Field.Hint,{})]})]})})},Q=({message:n="Loading..."})=>e.jsx(t.Box,{padding:8,textAlign:"center",children:e.jsx(t.Loader,{children:n})}),z=()=>w.useMutation({mutationFn:n=>I.api.validateTenant(n),onError:n=>{console.error("Tenant validation failed:",n)}});class U{constructor(o){L(this,"name");this.inner=o,this.name="ValidationError"}}const X=()=>{const n=M.useNavigate(),{id:o}=M.useParams(),i=o!=="new",s=i?parseInt(o):void 0,{toggleNotification:a}=p.useNotification(),l=j.useGetMessage(),{data:d,isLoading:u}=R.useTenant(s),x=z(),f=R.useCreateTenant(),F=R.useUpdateTenant(),b=P.default.useMemo(()=>({name:d?.name||"",code:d?.code||"",role:d?.role?.id?.toString()||"",tokens:d?.tokens?.map(r=>r.id),damRootDirectory:d?.damRootDirectory||"",customFields:JSON.stringify(d?.customFields||{},null,2),logo:d?.logo||null}),[d]),k=d?.code==="strapi-super-admin",g=async r=>{try{let m={};try{m=JSON.parse(r.customFields||"{}")}catch{a({type:"danger",message:l("domain.edit.notifications.invalidJson")});return}if(i&&s){const c={...r,role:r.role?parseInt(r.role):void 0,tokens:r.tokens||[],customFields:m,logo:r.logo||null};await F.mutateAsync({id:s,data:c}),a({type:"success",message:l("domain.edit.notifications.updated")})}else{const c={...r,role:r.role?parseInt(r.role):void 0,tokens:r.tokens||[],customFields:m,logo:r.logo||null},y=await f.mutateAsync(c);a({type:"success",message:l("domain.edit.notifications.created")}),n(`/settings/${h.pluginId}/${h.modelRoute}/${y.id}`)}}catch(m){a({type:"danger",message:m instanceof Error?m.message:l("domain.edit.notifications.saveError")})}},S=async r=>{const m={};if(r.customFields)try{JSON.parse(r.customFields)}catch{m.customFields=l("domain.edit.validation.invalidJson")}if(r.name||r.code)try{const c={excludeId:s};r.name&&(c.name=r.name),r.code&&(c.code=r.code);const y=await x.mutateAsync(c);y.name&&(m.name=y.name||"Name is not available"),y.code&&(m.code=y.code||"Code is not available")}catch(c){a({type:"danger",message:c instanceof Error?c.message:c?.toString()})}if(!N.isEmpty(m))throw new U(Object.keys(m).map(c=>({path:c,message:m[c]})));return r},E=f.isPending||F.isPending;return u?e.jsx(Q,{message:l("domain.edit.loading")}):e.jsxs(e.Fragment,{children:[e.jsx(p.Page.Title,{children:i?l("domain.edit.title.edit",{values:{name:d?.name||h.modelId}}):l("domain.edit.title.create")}),e.jsx(p.Page.Main,{children:e.jsx(p.Form,{onSubmit:g,initialValues:b,validate:S,method:"POST",width:"auto",height:"auto",children:({values:r,onChange:m,errors:c})=>e.jsxs(e.Fragment,{children:[e.jsx(A,{isEditing:i,tenantName:d?.name}),e.jsx(p.Layouts.Content,{children:e.jsxs(t.Grid.Root,{gap:4,children:[e.jsx(t.Grid.Item,{col:9,children:e.jsx(V,{values:r,onChange:m,disabled:k,errors:c})}),e.jsx(t.Grid.Item,{col:3,children:e.jsx(O,{isEditing:i,isSaving:E,onCancel:()=>n(`/settings/${h.pluginId}/${h.modelRoute}`)})})]})})]})})})]})};exports.default=X;
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var V = (t, n, o) => n in t ? K(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
|
|
3
|
+
var E = (t, n, o) => V(t, typeof n != "symbol" ? n + "" : n, o);
|
|
4
|
+
import { jsx as e, jsxs as m, Fragment as D } from "react/jsx-runtime";
|
|
5
|
+
import { Flex as R, Box as f, Typography as O, Button as N, Link as G, Field as d, Combobox as z, ComboboxOption as Q, IconButton as U, MultiSelect as X, MultiSelectOption as Y, TextInput as x, JSONInput as Z, Loader as _, Grid as C } from "@strapi/design-system";
|
|
6
|
+
import { Layouts as P, useStrapiApp as ee, useNotification as te, Page as H, Form as ne } from "@strapi/strapi/admin";
|
|
7
|
+
import oe, { useCallback as q } from "react";
|
|
8
|
+
import { NavLink as ie, useNavigate as ae, useParams as re } from "react-router-dom";
|
|
9
|
+
import { isEmpty as de } from "remeda";
|
|
10
|
+
import { b as A, c as $, p as L, m as M } from "./index-7tHbI_K_.mjs";
|
|
11
|
+
import { u as y } from "./useGetMessage-CTdHvgbI.mjs";
|
|
12
|
+
import { C as se, b as le, c as ce, d as me } from "./useTenants-Da8khjOe.mjs";
|
|
13
|
+
import { ArrowLeft as ue, Cross as ge } from "@strapi/icons";
|
|
14
|
+
import { useQuery as j, useMutation as he } from "@tanstack/react-query";
|
|
15
|
+
import { a as I } from "./index-Doprxev-.mjs";
|
|
16
|
+
const pe = ({
|
|
17
|
+
isEditing: t,
|
|
18
|
+
isSaving: n,
|
|
19
|
+
onCancel: o
|
|
20
|
+
}) => {
|
|
21
|
+
const i = y();
|
|
22
|
+
return /* @__PURE__ */ e(R, { justifyContent: "flex-start", gap: 2, direction: "column", height: "100%", width: "100%", children: /* @__PURE__ */ m(f, { background: "neutral0", padding: 8, shadow: "filterShadow", hasRadius: !0, width: "100%", children: [
|
|
23
|
+
/* @__PURE__ */ e(
|
|
24
|
+
O,
|
|
25
|
+
{
|
|
26
|
+
variant: "sigma",
|
|
27
|
+
textTransform: "uppercase",
|
|
28
|
+
textColor: "neutral600",
|
|
29
|
+
tag: "h2",
|
|
30
|
+
marginBottom: 4,
|
|
31
|
+
children: i("domain.edit.actions.entry")
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
/* @__PURE__ */ m(R, { direction: "column", gap: 2, children: [
|
|
35
|
+
/* @__PURE__ */ e(
|
|
36
|
+
se,
|
|
37
|
+
{
|
|
38
|
+
permissions: t ? A.admin.edit : A.admin.create,
|
|
39
|
+
children: /* @__PURE__ */ e(N, { type: "submit", loading: n, width: "100%", children: i(t ? "domain.edit.actions.update" : "domain.edit.actions.create") })
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ e(N, { variant: "secondary", onClick: o, width: "100%", children: i("common.cancel") })
|
|
43
|
+
] })
|
|
44
|
+
] }) });
|
|
45
|
+
}, fe = ({ isEditing: t, tenantName: n }) => {
|
|
46
|
+
const o = y(), i = t ? n || o("domain.edit.title.edit", {
|
|
47
|
+
values: { name: $ }
|
|
48
|
+
}) : o("domain.edit.title.create");
|
|
49
|
+
return /* @__PURE__ */ e(
|
|
50
|
+
P.Header,
|
|
51
|
+
{
|
|
52
|
+
title: typeof i == "string" ? i : String(i),
|
|
53
|
+
navigationAction: /* @__PURE__ */ e(G, { tag: ie, startIcon: /* @__PURE__ */ e(ue, {}), to: `/settings/${L}/${M}`, children: o("common.back") })
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}, ye = ({ disabled: t = !1, error: n }) => {
|
|
57
|
+
const o = y(), i = ee(
|
|
58
|
+
"CustomMediaInput",
|
|
59
|
+
(a) => a.fields?.media || {}
|
|
60
|
+
);
|
|
61
|
+
return i ? /* @__PURE__ */ m(
|
|
62
|
+
d.Root,
|
|
63
|
+
{
|
|
64
|
+
name: "logo",
|
|
65
|
+
hint: o("domain.edit.form.logo.hint"),
|
|
66
|
+
error: n,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ e(
|
|
69
|
+
i,
|
|
70
|
+
{
|
|
71
|
+
label: "Logo",
|
|
72
|
+
name: "logo",
|
|
73
|
+
disabled: t,
|
|
74
|
+
attribute: {
|
|
75
|
+
allowedTypes: ["images"],
|
|
76
|
+
multiple: !1
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ e(d.Hint, {}),
|
|
81
|
+
/* @__PURE__ */ e(d.Error, {})
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
) : null;
|
|
85
|
+
}, J = {
|
|
86
|
+
all: ["roles"],
|
|
87
|
+
lists: () => [...J.all, "list"]
|
|
88
|
+
}, be = () => j({
|
|
89
|
+
queryKey: J.lists(),
|
|
90
|
+
queryFn: () => I.getRoles(),
|
|
91
|
+
staleTime: 600 * 1e3
|
|
92
|
+
// 10 minutes - roles don't change often
|
|
93
|
+
}), Te = ({
|
|
94
|
+
value: t,
|
|
95
|
+
onChange: n,
|
|
96
|
+
disabled: o = !1,
|
|
97
|
+
error: i,
|
|
98
|
+
onLoadMore: a,
|
|
99
|
+
onSearch: l
|
|
100
|
+
}) => {
|
|
101
|
+
const { data: s = [], isLoading: g } = be(), p = y(), b = () => {
|
|
102
|
+
n({ target: { name: "role", value: "" } });
|
|
103
|
+
}, k = (h) => {
|
|
104
|
+
n({ target: { name: "role", value: h } });
|
|
105
|
+
}, S = q(
|
|
106
|
+
(h) => {
|
|
107
|
+
const F = h.target.value;
|
|
108
|
+
l && l(F);
|
|
109
|
+
},
|
|
110
|
+
[l]
|
|
111
|
+
), w = q(() => {
|
|
112
|
+
a && !g && a();
|
|
113
|
+
}, [a, g]);
|
|
114
|
+
return /* @__PURE__ */ m(
|
|
115
|
+
d.Root,
|
|
116
|
+
{
|
|
117
|
+
name: "role",
|
|
118
|
+
hint: p("domain.edit.form.role.hint"),
|
|
119
|
+
error: i,
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ e(d.Label, { children: p("domain.edit.form.role.label") }),
|
|
122
|
+
/* @__PURE__ */ e(
|
|
123
|
+
z,
|
|
124
|
+
{
|
|
125
|
+
loading: g,
|
|
126
|
+
hasMoreItems: !g,
|
|
127
|
+
name: "role",
|
|
128
|
+
disabled: o,
|
|
129
|
+
value: t,
|
|
130
|
+
onChange: k,
|
|
131
|
+
placeholder: p("domain.edit.form.role.placeholder"),
|
|
132
|
+
onInputChange: S,
|
|
133
|
+
onLoadMore: w,
|
|
134
|
+
children: s.map((h) => /* @__PURE__ */ e(Q, { value: h.id.toString(), children: h.name }, h.id))
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
t && s.length > 0 && /* @__PURE__ */ m(
|
|
138
|
+
R,
|
|
139
|
+
{
|
|
140
|
+
paddingTop: 2,
|
|
141
|
+
paddingBottom: 2,
|
|
142
|
+
paddingLeft: 4,
|
|
143
|
+
paddingRight: 4,
|
|
144
|
+
hasRadius: !0,
|
|
145
|
+
borderColor: "neutral200",
|
|
146
|
+
background: "neutral0",
|
|
147
|
+
justifyContent: "space-between",
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ e(O, { textColor: "neutral800", fontWeight: "bold", children: s.find((h) => h.id.toString() === t)?.name }),
|
|
150
|
+
o ? null : /* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(
|
|
151
|
+
U,
|
|
152
|
+
{
|
|
153
|
+
onClick: b,
|
|
154
|
+
label: p("domain.edit.form.role.remove"),
|
|
155
|
+
variant: "ghost",
|
|
156
|
+
size: "S",
|
|
157
|
+
children: /* @__PURE__ */ e(ge, {})
|
|
158
|
+
}
|
|
159
|
+
) })
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ e(d.Hint, {})
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}, W = {
|
|
168
|
+
all: ["tokens"],
|
|
169
|
+
lists: () => [...W.all, "list"]
|
|
170
|
+
}, Re = () => j({
|
|
171
|
+
queryKey: W.lists(),
|
|
172
|
+
queryFn: () => I.getTokens(),
|
|
173
|
+
staleTime: 600 * 1e3
|
|
174
|
+
}), ke = ({
|
|
175
|
+
value: t = [],
|
|
176
|
+
onChange: n,
|
|
177
|
+
disabled: o = !1,
|
|
178
|
+
error: i
|
|
179
|
+
}) => {
|
|
180
|
+
const { data: a = [] } = Re(), l = y(), s = (g) => {
|
|
181
|
+
const p = g.map((b) => Number(b));
|
|
182
|
+
n({ target: { name: "tokens", value: p } });
|
|
183
|
+
};
|
|
184
|
+
return /* @__PURE__ */ m(
|
|
185
|
+
d.Root,
|
|
186
|
+
{
|
|
187
|
+
name: "tokens",
|
|
188
|
+
hint: l("domain.edit.form.tokens.hint"),
|
|
189
|
+
error: i,
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ e(d.Label, { children: l("domain.edit.form.tokens.label") }),
|
|
192
|
+
/* @__PURE__ */ e(
|
|
193
|
+
X,
|
|
194
|
+
{
|
|
195
|
+
withTags: !0,
|
|
196
|
+
name: "tokens",
|
|
197
|
+
disabled: o,
|
|
198
|
+
value: t.map((g) => g.toString()),
|
|
199
|
+
onChange: s,
|
|
200
|
+
placeholder: l("domain.edit.form.tokens.placeholder"),
|
|
201
|
+
children: a.map((g) => /* @__PURE__ */ e(Y, { value: g.id.toString(), children: g.name }, g.id.toString()))
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
/* @__PURE__ */ e(d.Hint, {})
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}, v = (t) => {
|
|
209
|
+
if (typeof t == "string") return t;
|
|
210
|
+
if (t && typeof t == "object" && "defaultMessage" in t) {
|
|
211
|
+
const n = t.defaultMessage;
|
|
212
|
+
return typeof n == "string" ? n : void 0;
|
|
213
|
+
}
|
|
214
|
+
}, ve = ({
|
|
215
|
+
values: t,
|
|
216
|
+
onChange: n,
|
|
217
|
+
disabled: o,
|
|
218
|
+
errors: i
|
|
219
|
+
}) => {
|
|
220
|
+
const a = y(), l = (s) => {
|
|
221
|
+
n({ target: { name: "customFields", value: s } });
|
|
222
|
+
};
|
|
223
|
+
return /* @__PURE__ */ e(f, { background: "neutral0", padding: 8, shadow: "filterShadow", hasRadius: !0, width: "100%", children: /* @__PURE__ */ m(R, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
224
|
+
/* @__PURE__ */ m(R, { gap: 4, wrap: "wrap", children: [
|
|
225
|
+
/* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ m(
|
|
226
|
+
d.Root,
|
|
227
|
+
{
|
|
228
|
+
name: "name",
|
|
229
|
+
required: !0,
|
|
230
|
+
hint: a("domain.edit.form.name.hint"),
|
|
231
|
+
error: v(i.name),
|
|
232
|
+
children: [
|
|
233
|
+
/* @__PURE__ */ e(d.Label, { children: a("domain.edit.form.name.label") }),
|
|
234
|
+
/* @__PURE__ */ e(
|
|
235
|
+
x,
|
|
236
|
+
{
|
|
237
|
+
disabled: o,
|
|
238
|
+
name: "name",
|
|
239
|
+
value: t.name,
|
|
240
|
+
onChange: n,
|
|
241
|
+
placeholder: a("domain.edit.form.name.placeholder"),
|
|
242
|
+
required: !0
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
/* @__PURE__ */ e(d.Hint, {}),
|
|
246
|
+
/* @__PURE__ */ e(d.Error, {})
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
) }),
|
|
250
|
+
/* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ m(
|
|
251
|
+
d.Root,
|
|
252
|
+
{
|
|
253
|
+
name: "code",
|
|
254
|
+
required: !0,
|
|
255
|
+
hint: a("domain.edit.form.code.hint"),
|
|
256
|
+
error: v(i.code),
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ e(d.Label, { children: a("domain.edit.form.code.label") }),
|
|
259
|
+
/* @__PURE__ */ e(
|
|
260
|
+
x,
|
|
261
|
+
{
|
|
262
|
+
disabled: o,
|
|
263
|
+
name: "code",
|
|
264
|
+
value: t.code,
|
|
265
|
+
onChange: n,
|
|
266
|
+
placeholder: a("domain.edit.form.code.placeholder"),
|
|
267
|
+
required: !0
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ e(d.Hint, {}),
|
|
271
|
+
/* @__PURE__ */ e(d.Error, {})
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
) })
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ e(
|
|
277
|
+
ye,
|
|
278
|
+
{
|
|
279
|
+
value: t.logo,
|
|
280
|
+
onChange: n,
|
|
281
|
+
disabled: o,
|
|
282
|
+
error: i.logo?.toString()
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
/* @__PURE__ */ m(R, { gap: 4, wrap: "wrap", children: [
|
|
286
|
+
/* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ e(
|
|
287
|
+
Te,
|
|
288
|
+
{
|
|
289
|
+
value: t.role,
|
|
290
|
+
onChange: n,
|
|
291
|
+
disabled: o,
|
|
292
|
+
error: i.role?.toString()
|
|
293
|
+
}
|
|
294
|
+
) }),
|
|
295
|
+
/* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ e(
|
|
296
|
+
ke,
|
|
297
|
+
{
|
|
298
|
+
value: t.tokens || [],
|
|
299
|
+
onChange: n,
|
|
300
|
+
disabled: o,
|
|
301
|
+
error: i.tokens?.toString()
|
|
302
|
+
}
|
|
303
|
+
) })
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ m(
|
|
306
|
+
d.Root,
|
|
307
|
+
{
|
|
308
|
+
name: "damRootDirectory",
|
|
309
|
+
hint: a("domain.edit.form.damRootDirectory.hint"),
|
|
310
|
+
error: v(i.damRootDirectory),
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ e(d.Label, { children: a("domain.edit.form.damRootDirectory.label") }),
|
|
313
|
+
/* @__PURE__ */ e(
|
|
314
|
+
x,
|
|
315
|
+
{
|
|
316
|
+
disabled: o,
|
|
317
|
+
name: "damRootDirectory",
|
|
318
|
+
value: t.damRootDirectory,
|
|
319
|
+
onChange: n,
|
|
320
|
+
placeholder: a("domain.edit.form.damRootDirectory.placeholder")
|
|
321
|
+
}
|
|
322
|
+
),
|
|
323
|
+
/* @__PURE__ */ e(d.Hint, {}),
|
|
324
|
+
/* @__PURE__ */ e(d.Error, {})
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
/* @__PURE__ */ m(
|
|
329
|
+
d.Root,
|
|
330
|
+
{
|
|
331
|
+
name: "customFields",
|
|
332
|
+
hint: a("domain.edit.form.customFields.hint"),
|
|
333
|
+
error: v(i.customFields),
|
|
334
|
+
children: [
|
|
335
|
+
/* @__PURE__ */ e(d.Label, { children: a("domain.edit.form.customFields.label") }),
|
|
336
|
+
/* @__PURE__ */ e(
|
|
337
|
+
Z,
|
|
338
|
+
{
|
|
339
|
+
value: t.customFields,
|
|
340
|
+
onChange: l,
|
|
341
|
+
minHeight: "200px"
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
/* @__PURE__ */ e(d.Hint, {})
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
] }) });
|
|
349
|
+
}, Se = ({
|
|
350
|
+
message: t = "Loading..."
|
|
351
|
+
}) => /* @__PURE__ */ e(f, { padding: 8, textAlign: "center", children: /* @__PURE__ */ e(_, { children: t }) }), we = () => he({
|
|
352
|
+
mutationFn: (t) => I.validateTenant(t),
|
|
353
|
+
onError: (t) => {
|
|
354
|
+
console.error("Tenant validation failed:", t);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
class Fe {
|
|
358
|
+
constructor(n) {
|
|
359
|
+
E(this, "name");
|
|
360
|
+
this.inner = n, this.name = "ValidationError";
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const $e = () => {
|
|
364
|
+
const t = ae(), { id: n } = re(), o = n !== "new", i = o ? parseInt(n) : void 0, { toggleNotification: a } = te(), l = y(), { data: s, isLoading: g } = le(i), p = we(), b = ce(), k = me(), S = oe.useMemo(
|
|
365
|
+
() => ({
|
|
366
|
+
name: s?.name || "",
|
|
367
|
+
code: s?.code || "",
|
|
368
|
+
role: s?.role?.id?.toString() || "",
|
|
369
|
+
tokens: s?.tokens?.map((r) => r.id),
|
|
370
|
+
damRootDirectory: s?.damRootDirectory || "",
|
|
371
|
+
customFields: JSON.stringify(s?.customFields || {}, null, 2),
|
|
372
|
+
logo: s?.logo || null
|
|
373
|
+
}),
|
|
374
|
+
[s]
|
|
375
|
+
), w = s?.code === "strapi-super-admin", h = async (r) => {
|
|
376
|
+
try {
|
|
377
|
+
let u = {};
|
|
378
|
+
try {
|
|
379
|
+
u = JSON.parse(r.customFields || "{}");
|
|
380
|
+
} catch {
|
|
381
|
+
a({
|
|
382
|
+
type: "danger",
|
|
383
|
+
message: l("domain.edit.notifications.invalidJson")
|
|
384
|
+
});
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (o && i) {
|
|
388
|
+
const c = {
|
|
389
|
+
...r,
|
|
390
|
+
role: r.role ? parseInt(r.role) : void 0,
|
|
391
|
+
tokens: r.tokens || [],
|
|
392
|
+
customFields: u,
|
|
393
|
+
logo: r.logo || null
|
|
394
|
+
};
|
|
395
|
+
await k.mutateAsync({ id: i, data: c }), a({
|
|
396
|
+
type: "success",
|
|
397
|
+
message: l("domain.edit.notifications.updated")
|
|
398
|
+
});
|
|
399
|
+
} else {
|
|
400
|
+
const c = {
|
|
401
|
+
...r,
|
|
402
|
+
role: r.role ? parseInt(r.role) : void 0,
|
|
403
|
+
tokens: r.tokens || [],
|
|
404
|
+
customFields: u,
|
|
405
|
+
logo: r.logo || null
|
|
406
|
+
}, T = await b.mutateAsync(c);
|
|
407
|
+
a({
|
|
408
|
+
type: "success",
|
|
409
|
+
message: l("domain.edit.notifications.created")
|
|
410
|
+
}), t(`/settings/${L}/${M}/${T.id}`);
|
|
411
|
+
}
|
|
412
|
+
} catch (u) {
|
|
413
|
+
a({
|
|
414
|
+
type: "danger",
|
|
415
|
+
message: u instanceof Error ? u.message : l("domain.edit.notifications.saveError")
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}, F = async (r) => {
|
|
419
|
+
const u = {};
|
|
420
|
+
if (r.customFields)
|
|
421
|
+
try {
|
|
422
|
+
JSON.parse(r.customFields);
|
|
423
|
+
} catch {
|
|
424
|
+
u.customFields = l("domain.edit.validation.invalidJson");
|
|
425
|
+
}
|
|
426
|
+
if (r.name || r.code)
|
|
427
|
+
try {
|
|
428
|
+
const c = {
|
|
429
|
+
excludeId: i
|
|
430
|
+
};
|
|
431
|
+
r.name && (c.name = r.name), r.code && (c.code = r.code);
|
|
432
|
+
const T = await p.mutateAsync(c);
|
|
433
|
+
T.name && (u.name = T.name || "Name is not available"), T.code && (u.code = T.code || "Code is not available");
|
|
434
|
+
} catch (c) {
|
|
435
|
+
a({
|
|
436
|
+
type: "danger",
|
|
437
|
+
message: c instanceof Error ? c.message : c?.toString()
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
if (!de(u))
|
|
441
|
+
throw new Fe(
|
|
442
|
+
Object.keys(u).map((c) => ({
|
|
443
|
+
path: c,
|
|
444
|
+
message: u[c]
|
|
445
|
+
}))
|
|
446
|
+
);
|
|
447
|
+
return r;
|
|
448
|
+
}, B = b.isPending || k.isPending;
|
|
449
|
+
return g ? /* @__PURE__ */ e(Se, { message: l("domain.edit.loading") }) : /* @__PURE__ */ m(D, { children: [
|
|
450
|
+
/* @__PURE__ */ e(H.Title, { children: o ? l("domain.edit.title.edit", {
|
|
451
|
+
values: { name: s?.name || $ }
|
|
452
|
+
}) : l("domain.edit.title.create") }),
|
|
453
|
+
/* @__PURE__ */ e(H.Main, { children: /* @__PURE__ */ e(
|
|
454
|
+
ne,
|
|
455
|
+
{
|
|
456
|
+
onSubmit: h,
|
|
457
|
+
initialValues: S,
|
|
458
|
+
validate: F,
|
|
459
|
+
method: "POST",
|
|
460
|
+
width: "auto",
|
|
461
|
+
height: "auto",
|
|
462
|
+
children: ({ values: r, onChange: u, errors: c }) => /* @__PURE__ */ m(D, { children: [
|
|
463
|
+
/* @__PURE__ */ e(fe, { isEditing: o, tenantName: s?.name }),
|
|
464
|
+
/* @__PURE__ */ e(P.Content, { children: /* @__PURE__ */ m(C.Root, { gap: 4, children: [
|
|
465
|
+
/* @__PURE__ */ e(C.Item, { col: 9, children: /* @__PURE__ */ e(
|
|
466
|
+
ve,
|
|
467
|
+
{
|
|
468
|
+
values: r,
|
|
469
|
+
onChange: u,
|
|
470
|
+
disabled: w,
|
|
471
|
+
errors: c
|
|
472
|
+
}
|
|
473
|
+
) }),
|
|
474
|
+
/* @__PURE__ */ e(C.Item, { col: 3, children: /* @__PURE__ */ e(
|
|
475
|
+
pe,
|
|
476
|
+
{
|
|
477
|
+
isEditing: o,
|
|
478
|
+
isSaving: B,
|
|
479
|
+
onCancel: () => t(`/settings/${L}/${M}`)
|
|
480
|
+
}
|
|
481
|
+
) })
|
|
482
|
+
] }) })
|
|
483
|
+
] })
|
|
484
|
+
}
|
|
485
|
+
) })
|
|
486
|
+
] });
|
|
487
|
+
};
|
|
488
|
+
export {
|
|
489
|
+
$e as default
|
|
490
|
+
};
|