@sensinum/strapi-plugin-multi-domain 5.3.1 → 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/admin/{About-DaHQ_Yhm.mjs → About-DfCon-RP.mjs} +3 -3
- package/dist/admin/{About-Cqb0Poxw.js → About-DfcPwQ3q.js} +1 -1
- package/dist/admin/{Settings-CyMoV2x8.mjs → Settings-Dj3h2ayB.mjs} +2 -2
- package/dist/admin/{Settings-CDBzsWbm.js → Settings-tt-Wetcr.js} +1 -1
- package/dist/admin/{TenantCustomField-BVJXtOh1.js → TenantCustomField-Bf6uUoKE.js} +1 -1
- package/dist/admin/{TenantCustomField-ZM7ZfiGu.mjs → TenantCustomField-CS8x0CkO.mjs} +1 -1
- package/dist/admin/{TenantEdit-GAMHwYkP.js → TenantEdit-BT3-tB_B.js} +1 -1
- package/dist/admin/{TenantEdit-DBJoQv4w.mjs → TenantEdit-BY_7PPAr.mjs} +4 -4
- package/dist/admin/{TenantList-D8hgcBHM.js → TenantList-DrfJNPpi.js} +1 -1
- package/dist/admin/{TenantList-C6xsvthy.mjs → TenantList-dIxGcZPl.mjs} +4 -4
- package/dist/admin/{index-CQxsvheX.mjs → index-7tHbI_K_.mjs} +64 -63
- package/dist/admin/{index-eSOlzCRc.js → index-Cci_046h.js} +1 -1
- package/dist/admin/{index-CwsztY3K.mjs → index-Doprxev-.mjs} +1 -1
- package/dist/admin/index-oNXgzV7S.js +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{useGetMessage-Ck4TSmSw.mjs → useGetMessage-CTdHvgbI.mjs} +1 -1
- package/dist/admin/useGetMessage-DS88gOrN.js +1 -0
- package/dist/admin/{useSettings-CkTWZxdH.js → useSettings-C7vR1hfw.js} +1 -1
- package/dist/admin/{useSettings-DY1d6P_T.mjs → useSettings-bLTyn7Pl.mjs} +1 -1
- package/dist/admin/{useTenants-sy0FweCJ.mjs → useTenants-Da8khjOe.mjs} +2 -2
- package/dist/admin/{useTenants-Ck1OOTGx.js → useTenants-vVkOIEvT.js} +1 -1
- package/dist/server/index.js +4 -3
- package/dist/server/index.mjs +3332 -3282
- package/package.json +1 -1
- package/dist/admin/index-BwgjJmHR.js +0 -1
- package/dist/admin/useGetMessage-gI6hxpcF.js +0 -1
|
@@ -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-
|
|
5
|
+
import { p, m as d } from "./index-7tHbI_K_.mjs";
|
|
6
6
|
import { Q as h } from "./QueryProvider-oO97LaUB.mjs";
|
|
7
|
-
const c = r.lazy(() => import("./TenantList-
|
|
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"),f=require("@strapi/strapi/admin"),e=require("zod"),F=require("react"),S=require("@tanstack/react-query"),q=require("./index-
|
|
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;
|
|
@@ -4,7 +4,7 @@ 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-
|
|
7
|
+
import { a as T } from "./index-Doprxev-.mjs";
|
|
8
8
|
import { Q as V } from "./QueryProvider-oO97LaUB.mjs";
|
|
9
9
|
import { capitalize as z } from "remeda";
|
|
10
10
|
const f = t.object({
|
|
@@ -1 +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-
|
|
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;
|
|
@@ -7,12 +7,12 @@ import { Layouts as P, useStrapiApp as ee, useNotification as te, Page as H, For
|
|
|
7
7
|
import oe, { useCallback as q } from "react";
|
|
8
8
|
import { NavLink as ie, useNavigate as ae, useParams as re } from "react-router-dom";
|
|
9
9
|
import { isEmpty as de } from "remeda";
|
|
10
|
-
import { b as A, c as $, p as L, m as M } from "./index-
|
|
11
|
-
import { u as y } from "./useGetMessage-
|
|
12
|
-
import { C as se, b as le, c as ce, d as me } from "./useTenants-
|
|
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
13
|
import { ArrowLeft as ue, Cross as ge } from "@strapi/icons";
|
|
14
14
|
import { useQuery as j, useMutation as he } from "@tanstack/react-query";
|
|
15
|
-
import { a as I } from "./index-
|
|
15
|
+
import { a as I } from "./index-Doprxev-.mjs";
|
|
16
16
|
const pe = ({
|
|
17
17
|
isEditing: t,
|
|
18
18
|
isSaving: n,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),m=require("@strapi/icons"),a=require("@strapi/strapi/admin"),k=require("react"),q=require("react-router-dom"),x=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),m=require("@strapi/icons"),a=require("@strapi/strapi/admin"),k=require("react"),q=require("react-router-dom"),x=require("./index-oNXgzV7S.js"),p=require("./useTenants-vVkOIEvT.js"),W=require("styled-components"),P=require("./useGetMessage-DS88gOrN.js"),G=require("./useSettings-C7vR1hfw.js"),A=n=>n&&n.__esModule?n:{default:n},H=A(k),O=A(W),Q=({isOpen:n,onClose:i,onConfirm:l,target:r})=>e.jsx(t.Dialog.Root,{open:n,onOpenChange:i,children:e.jsxs(t.Dialog.Content,{children:[e.jsx(t.Dialog.Header,{children:"Confirmation"}),e.jsx(t.Dialog.Body,{icon:e.jsx(m.Trash,{}),children:e.jsx(t.Dialog.Description,{textAlign:"center",children:e.jsxs(t.Flex,{gap:2,direction:"column",children:[e.jsx(m.WarningCircle,{fill:"danger600",width:"24",height:"24"}),"Are you sure you want to delete this ",r,"?",e.jsx("br",{}),"All your modifications will be lost"]})})}),e.jsxs(t.Dialog.Footer,{children:[e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:i,variant:"tertiary",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Cancel"})})}),e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:l,variant:"danger",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Confirm"})})})]})]})}),U=({isDisplayed:n,direction:i})=>n?i==="asc"?e.jsx(m.ArrowUp,{}):e.jsx(m.ArrowDown,{}):null,D=({label:n,field:i,sort:l,onSort:r})=>{const[c,h]=l.split(":");return e.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>r(i)(h==="asc"?"desc":"asc"),children:[e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:n}),e.jsx("span",{style:{marginLeft:4},children:e.jsx(U,{isDisplayed:i===c,direction:h})})]})},J=O.default(t.Tr)(()=>({cursor:"pointer"})),K=({tenant:n,selectedTenants:i,handleSelectTenant:l,onDeleteTenant:r,isDeletePending:c=!1})=>{const h=q.useNavigate(),s=P.useGetMessage(),y=u=>()=>h(`/settings/${x.pluginId}/${x.modelRoute}/${u.id}`);return e.jsxs(J,{onClick:y(n),children:[e.jsx(t.Td,{children:e.jsx(t.Checkbox,{checked:i.includes(n.id),onCheckedChange:u=>l(n.id,u)})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:n.id})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:n.name})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{textColor:"neutral800",children:n.code})}),e.jsx(t.Td,{children:n.role?e.jsx(t.Badge,{textColor:"neutral800",backgroundColor:"neutral100",children:n.role.name}):e.jsx(t.Typography,{textColor:"neutral600",children:"-"})}),e.jsx(t.Td,{children:e.jsxs(t.Flex,{gap:1,children:[e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.edit,children:e.jsx(t.IconButton,{onClick:y(n),label:s("common.edit"),children:e.jsx(m.Pencil,{})})}),e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.delete,children:e.jsx(t.IconButton,{onClick:r(n),label:s("common.delete"),disabled:c,children:e.jsx(m.Trash,{})})})]})})]})},V=()=>{const n=q.useNavigate(),{toggleNotification:i}=a.useNotification(),[l,r]=k.useState([]),[c,h]=k.useState(),s=P.useGetMessage(),y=p.useDeleteTenant(),{data:u,isLoading:w}=G.useSettings(),[{query:j},L]=a.useQueryParams({sort:"name:asc",_q:"",page:1,pageSize:10}),{sort:f,_q:M,page:R,pageSize:_}={...j,sort:j.sort||"name:asc",_q:j._q||"",page:j.page||1,pageSize:j.pageSize||10},{data:v,isLoading:B,error:T}=p.useTenants({sort:f,search:M,page:R,pageSize:_}),g=v?.results||[],C=v?.pagination||{pageCount:1,total:0};H.default.useEffect(()=>{T&&i({type:"danger",message:T instanceof Error?T.message:"An error occurred while fetching tenants"})},[T,i]);const I=o=>{r(o===!0?g.map(d=>d.id):[])},z=(o,d)=>{r(d?b=>[...b,o]:b=>b.filter(N=>N!==o))},S=o=>d=>{L({...j,sort:`${o}:${d}`})},$=o=>async d=>{d.stopPropagation(),h(o)},E=async()=>{if(c)try{await y.mutateAsync(c.id),i({type:"success",message:s("domain.notifications.deleted",{values:{name:c.name}})}),h(void 0),r(o=>o.filter(d=>d!==c.id))}catch{i({type:"danger",message:s("domain.notifications.deleteError")})}},F=()=>{h(void 0)};return B||w?e.jsx(a.Page.Main,{children:e.jsx(a.Layouts.Content,{children:e.jsx(t.Loader,{children:s("domain.list.loading")})})}):e.jsxs(e.Fragment,{children:[e.jsx(a.Page.Title,{children:"Tenants"}),e.jsxs(a.Page.Main,{children:[e.jsx(a.Layouts.Header,{title:s("domain.list.title"),subtitle:s("domain.list.subtitle",{values:{count:g.length}})}),e.jsx(a.Layouts.Action,{startActions:e.jsx(e.Fragment,{children:e.jsx(a.SearchInput,{label:s("domain.list.search",{defaultMessage:"Search domains"})})}),endActions:e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.create,children:e.jsx(t.Button,{startIcon:e.jsx(m.Plus,{}),onClick:()=>{if(!u?.features?.unlimited&&u?.features?.domains!=null&&u?.features?.domains<=C.total)return i({type:"warning",message:s("domain.list.limitReached",{values:{limit:u?.features.domains||0}})});n(`/settings/${x.pluginId}/${x.modelRoute}/new`)},children:s("common.create")})})}),e.jsx(a.Layouts.Content,{children:g.length===0?e.jsx(t.EmptyStateLayout,{icon:e.jsx(m.Search,{}),content:s("domain.list.emptyState",{defaultMessage:"No domains found matching your search criteria"})}):e.jsxs(e.Fragment,{children:[e.jsxs(t.Table,{colCount:6,rowCount:g.length+1,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:e.jsx(t.Checkbox,{checked:l.length>0&&l.length<g.length?"indeterminate":l.length===g.length&&g.length>0,onCheckedChange:I})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.id"),field:"id",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.name"),field:"name",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.code"),field:"code",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s("domain.list.table.headers.role")})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s("domain.list.table.headers.actions")})})]})}),e.jsx(t.Tbody,{children:g.map(o=>e.jsx(K,{tenant:o,selectedTenants:l,handleSelectTenant:z,onDeleteTenant:$},o.id))})]}),e.jsx(t.Box,{paddingTop:4,children:e.jsxs(a.Pagination.Root,{pageCount:C.pageCount,total:C.total,children:[e.jsx(a.Pagination.PageSize,{}),e.jsx(a.Pagination.Links,{})]})})]})})]}),e.jsx(Q,{isOpen:!!c,onClose:F,onConfirm:E,target:c?.name||x.modelId})]})};exports.default=V;
|
|
@@ -4,11 +4,11 @@ import { WarningCircle as se, Trash as W, ArrowUp as ce, ArrowDown as de, Pencil
|
|
|
4
4
|
import { useNotification as ue, useQueryParams as pe, Page as D, Layouts as b, SearchInput as fe, Pagination as w } from "@strapi/strapi/admin";
|
|
5
5
|
import Ce, { useState as $ } from "react";
|
|
6
6
|
import { useNavigate as N } from "react-router-dom";
|
|
7
|
-
import { b as M, p as _, m as H, c as ye } from "./index-
|
|
8
|
-
import { C as z, u as Se, a as Te } from "./useTenants-
|
|
7
|
+
import { b as M, p as _, m as H, c as ye } from "./index-7tHbI_K_.mjs";
|
|
8
|
+
import { C as z, u as Se, a as Te } from "./useTenants-Da8khjOe.mjs";
|
|
9
9
|
import be from "styled-components";
|
|
10
|
-
import { u as j } from "./useGetMessage-
|
|
11
|
-
import { u as ve } from "./useSettings-
|
|
10
|
+
import { u as j } from "./useGetMessage-CTdHvgbI.mjs";
|
|
11
|
+
import { u as ve } from "./useSettings-bLTyn7Pl.mjs";
|
|
12
12
|
const ke = ({
|
|
13
13
|
isOpen: t,
|
|
14
14
|
onClose: i,
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { toSnakeCase as W, funnel as V } from "remeda";
|
|
2
2
|
import { z as J } from "zod";
|
|
3
3
|
import { jsx as o, jsxs as m } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
5
|
-
import X, { useRef as Y, useEffect as Z, useState as x } from "react";
|
|
4
|
+
import G, { useRef as K, useEffect as X, useState as x } from "react";
|
|
6
5
|
import { CookiesProvider as R, useCookies as D } from "react-cookie";
|
|
7
|
-
import {
|
|
6
|
+
import { useParams as Y } from "react-router-dom";
|
|
7
|
+
import { getFetchClient as Z } from "@strapi/strapi/admin";
|
|
8
|
+
import { Avatar as k, Modal as h, Box as L, Field as P, Searchbar as ee, EmptyStateLayout as te, Table as ne, Thead as oe, Tr as M, Th as C, Typography as S, Tbody as ie, Td as T, Checkbox as ae, Button as I, DesignSystemProvider as re, lightTheme as se, darkTheme as ce } from "@strapi/design-system";
|
|
8
9
|
import { createRoot as le } from "react-dom/client";
|
|
9
10
|
import { Search as de } from "@strapi/icons";
|
|
10
11
|
import { QueryClient as ue, QueryClientProvider as me } from "@tanstack/react-query";
|
|
11
|
-
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.3.
|
|
12
|
+
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.3.2", ge = "https://www.sensinum.com/contact", fe = "hello@sensinum.com", ye = { name: "multi-domain" }, Fe = {
|
|
12
13
|
name: he,
|
|
13
14
|
version: pe,
|
|
14
15
|
homepage: ge,
|
|
15
16
|
email: fe
|
|
16
|
-
},
|
|
17
|
-
W(
|
|
17
|
+
}, a = J.literal("multi-domain").parse(ye.name);
|
|
18
|
+
W(a);
|
|
18
19
|
const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
19
20
|
read: "read",
|
|
20
21
|
change: "change",
|
|
21
22
|
create: "create",
|
|
22
23
|
delete: "delete"
|
|
23
|
-
}, b = (e) => `plugin::${
|
|
24
|
+
}, b = (e) => `plugin::${a}.${H[e]}`, N = {
|
|
24
25
|
admin: {
|
|
25
26
|
access: Object.keys(H).map((e) => ({
|
|
26
27
|
action: b(e),
|
|
@@ -34,14 +35,14 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
34
35
|
const t = `/admin/content-manager/collection-types/${e}/create`, n = document.querySelector(`a[href*="${t}"]`);
|
|
35
36
|
n && (n.style.display = "none");
|
|
36
37
|
}, Se = () => {
|
|
37
|
-
const [{ [p]: e }] = D([p]), t = U(e), { slug: n } =
|
|
38
|
-
return
|
|
39
|
-
(t || !e) && Ce(n);
|
|
38
|
+
const [{ [p]: e }] = D([p]), t = U(e), { slug: n } = Y();
|
|
39
|
+
return G.useEffect(() => {
|
|
40
|
+
n && (t || !e) && Ce(n);
|
|
40
41
|
}, [t, e, n]), null;
|
|
41
42
|
}, Te = () => /* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(Se, {}) }), ve = ({ setPlugin: e }) => {
|
|
42
|
-
const t =
|
|
43
|
-
return
|
|
44
|
-
t.current(
|
|
43
|
+
const t = K(e);
|
|
44
|
+
return X(() => {
|
|
45
|
+
t.current(a);
|
|
45
46
|
}, []), null;
|
|
46
47
|
}, B = {
|
|
47
48
|
en: () => import("./en-Cf69p5po.mjs")
|
|
@@ -49,19 +50,19 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
49
50
|
if (!e)
|
|
50
51
|
throw new TypeError("Prefix can't be empty");
|
|
51
52
|
return Object.keys(t).reduce(
|
|
52
|
-
(n,
|
|
53
|
+
(n, i) => (n[`${e}.${i}`] = t[i], n),
|
|
53
54
|
{}
|
|
54
55
|
);
|
|
55
|
-
}, A = (e, t = "") => Object.keys(e).reduce((n,
|
|
56
|
+
}, A = (e, t = "") => Object.keys(e).reduce((n, i) => {
|
|
56
57
|
const r = t.length ? `${t}.` : "";
|
|
57
|
-
return typeof e[
|
|
58
|
+
return typeof e[i] == "object" && e[i] !== null && !Array.isArray(e[i]) ? Object.assign(n, A(e[i], r + i)) : n[r + i] = e[i], n;
|
|
58
59
|
}, {}), Ee = ({ onClose: e, userData: t }) => {
|
|
59
|
-
const [{ [p]: n },
|
|
60
|
+
const [{ [p]: n }, i] = D([p]), [r, d] = x(""), [c, u] = x(n || null), l = (t[E] || []).filter(
|
|
60
61
|
(s) => s.name.toLowerCase().includes(r.toLowerCase())
|
|
61
62
|
), y = (s) => {
|
|
62
63
|
u(c?.id === s.id ? null : s);
|
|
63
64
|
}, Q = () => {
|
|
64
|
-
c && (
|
|
65
|
+
c && (i(p, JSON.stringify(c), {
|
|
65
66
|
path: "/",
|
|
66
67
|
maxAge: 3600 * 24 * 30,
|
|
67
68
|
// 30 days
|
|
@@ -71,8 +72,8 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
71
72
|
return console.log("Avatar", k), /* @__PURE__ */ o(h.Root, { defaultOpen: !0, onOpenChange: e, children: /* @__PURE__ */ m(h.Content, { children: [
|
|
72
73
|
/* @__PURE__ */ o(h.Header, { children: /* @__PURE__ */ o(h.Title, { children: "Select Domain" }) }),
|
|
73
74
|
/* @__PURE__ */ m(h.Body, { children: [
|
|
74
|
-
/* @__PURE__ */ o(L, { paddingBottom: 4, children: /* @__PURE__ */ m(
|
|
75
|
-
/* @__PURE__ */ o(
|
|
75
|
+
/* @__PURE__ */ o(L, { paddingBottom: 4, children: /* @__PURE__ */ m(P.Root, { name: "tenant-search", children: [
|
|
76
|
+
/* @__PURE__ */ o(P.Label, { children: "Search domains" }),
|
|
76
77
|
/* @__PURE__ */ o(
|
|
77
78
|
ee,
|
|
78
79
|
{
|
|
@@ -94,14 +95,14 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
94
95
|
content: "No domains found matching your search criteria"
|
|
95
96
|
}
|
|
96
97
|
) : /* @__PURE__ */ o(L, { maxHeight: "400px", overflow: "auto", children: /* @__PURE__ */ m(ne, { colCount: 2, rowCount: l.length + 1, children: [
|
|
97
|
-
/* @__PURE__ */ o(oe, { children: /* @__PURE__ */ m(
|
|
98
|
+
/* @__PURE__ */ o(oe, { children: /* @__PURE__ */ m(M, { children: [
|
|
98
99
|
/* @__PURE__ */ o(C, { width: "60px", children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Select" }) }),
|
|
99
100
|
/* @__PURE__ */ o(C, { width: "40px", children: null }),
|
|
100
101
|
/* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Domain name" }) })
|
|
101
102
|
] }) }),
|
|
102
|
-
/* @__PURE__ */ o(
|
|
103
|
+
/* @__PURE__ */ o(ie, { children: l.map((s) => /* @__PURE__ */ m(M, { children: [
|
|
103
104
|
/* @__PURE__ */ o(T, { width: "60px", children: /* @__PURE__ */ o(
|
|
104
|
-
|
|
105
|
+
ae,
|
|
105
106
|
{
|
|
106
107
|
checked: c?.id === s.id,
|
|
107
108
|
onCheckedChange: () => y(s),
|
|
@@ -125,19 +126,19 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
125
126
|
refetchOnWindowFocus: !1
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
}), $e = (e, t, n,
|
|
129
|
+
}), $e = (e, t, n, i) => {
|
|
129
130
|
const r = le(e), d = () => {
|
|
130
131
|
document.body.removeAttribute("style"), r.unmount(), setTimeout(() => {
|
|
131
132
|
document.body.style.pointerEvents = "auto";
|
|
132
133
|
}, 0);
|
|
133
134
|
};
|
|
134
135
|
return t.remove(), r.render(
|
|
135
|
-
/* @__PURE__ */ o(re, { theme:
|
|
136
|
+
/* @__PURE__ */ o(re, { theme: i === "light" ? se : ce, children: /* @__PURE__ */ o(me, { client: Ae, children: /* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(Ee, { onClose: d, userData: n }) }) }) })
|
|
136
137
|
);
|
|
137
|
-
}, w = (e, t) => new Promise((n,
|
|
138
|
+
}, w = (e, t) => new Promise((n, i) => {
|
|
138
139
|
const c = (u = 0) => {
|
|
139
140
|
if (u > 50) {
|
|
140
|
-
|
|
141
|
+
i(new Error("Button not found after 50 attempts"));
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
144
|
const l = (t || document).querySelector(e);
|
|
@@ -155,8 +156,8 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
155
156
|
const n = t.split("=").at(1);
|
|
156
157
|
if (!n)
|
|
157
158
|
return null;
|
|
158
|
-
const
|
|
159
|
-
return JSON.parse(
|
|
159
|
+
const i = decodeURIComponent(n);
|
|
160
|
+
return JSON.parse(i);
|
|
160
161
|
}
|
|
161
162
|
} catch (e) {
|
|
162
163
|
console.error("Error parsing tenant cookie:", e);
|
|
@@ -165,8 +166,8 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
165
166
|
}, xe = (e) => {
|
|
166
167
|
const t = e.firstChild, n = t?.lastChild?.cloneNode(!0);
|
|
167
168
|
if (t && n instanceof HTMLElement) {
|
|
168
|
-
const
|
|
169
|
-
|
|
169
|
+
const i = n.firstChild;
|
|
170
|
+
i && n.replaceChildren(i);
|
|
170
171
|
const r = n.querySelector("span");
|
|
171
172
|
if (r) {
|
|
172
173
|
const d = j();
|
|
@@ -176,7 +177,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
176
177
|
}
|
|
177
178
|
}, $ = async () => {
|
|
178
179
|
try {
|
|
179
|
-
const e =
|
|
180
|
+
const e = Z(), {
|
|
180
181
|
data: { data: t }
|
|
181
182
|
} = await e.get("/admin/users/me");
|
|
182
183
|
return t;
|
|
@@ -186,9 +187,9 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
186
187
|
}, F = async () => {
|
|
187
188
|
const e = await $(), t = document.createElement("div");
|
|
188
189
|
document.body.appendChild(t);
|
|
189
|
-
const n = await w('nav button[aria-haspopup="menu"]'),
|
|
190
|
+
const n = await w('nav button[aria-haspopup="menu"]'), i = "aria-expanded";
|
|
190
191
|
new MutationObserver(async (d) => {
|
|
191
|
-
if (d.some((c) => c.attributeName ===
|
|
192
|
+
if (d.some((c) => c.attributeName === i) && n.getAttribute(i) === "true") {
|
|
192
193
|
const c = await w("[data-radix-menu-content]");
|
|
193
194
|
if (!(c instanceof HTMLElement))
|
|
194
195
|
return;
|
|
@@ -218,8 +219,8 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
218
219
|
const e = j(), t = document.querySelector('[data-strapi-header="true"]');
|
|
219
220
|
if (!e || U(e)) {
|
|
220
221
|
const n = t?.querySelectorAll("button");
|
|
221
|
-
n && n.forEach((
|
|
222
|
-
|
|
222
|
+
n && n.forEach((i) => {
|
|
223
|
+
i.style.display = "none";
|
|
223
224
|
});
|
|
224
225
|
}
|
|
225
226
|
}, O = V(Le, {
|
|
@@ -239,55 +240,55 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
242
|
document.body.removeAttribute(f);
|
|
242
|
-
},
|
|
243
|
+
}, Pe = async () => {
|
|
243
244
|
_() || !await $() || (document.body.setAttribute(f, "true"), await Promise.all([F(), z()]));
|
|
244
|
-
},
|
|
245
|
+
}, _e = {
|
|
245
246
|
register(e) {
|
|
246
247
|
e.registerPlugin({
|
|
247
|
-
id:
|
|
248
|
+
id: a,
|
|
248
249
|
initializer: ve,
|
|
249
250
|
isReady: !1,
|
|
250
|
-
name:
|
|
251
|
+
name: a
|
|
251
252
|
}), e.customFields.register({
|
|
252
253
|
name: `unique-by-${g}`,
|
|
253
|
-
pluginId:
|
|
254
|
+
pluginId: a,
|
|
254
255
|
type: "string",
|
|
255
256
|
intlLabel: {
|
|
256
|
-
id: `${
|
|
257
|
+
id: `${a}.custom-fields.unique-by-domain.label`,
|
|
257
258
|
defaultMessage: "Unique by domain"
|
|
258
259
|
},
|
|
259
260
|
intlDescription: {
|
|
260
|
-
id: `${
|
|
261
|
+
id: `${a}.custom-fields.unique-by-tenant.description`,
|
|
261
262
|
defaultMessage: "Ensures the value is unique within the domain."
|
|
262
263
|
},
|
|
263
264
|
components: {
|
|
264
|
-
Input: () => import("./TenantCustomField-
|
|
265
|
+
Input: () => import("./TenantCustomField-CS8x0CkO.mjs")
|
|
265
266
|
}
|
|
266
267
|
}), e.router.addSettingsLink({
|
|
267
|
-
id: `${
|
|
268
|
+
id: `${a}.settings`,
|
|
268
269
|
intlLabel: {
|
|
269
|
-
id: `${
|
|
270
|
+
id: `${a}.settings.label`,
|
|
270
271
|
defaultMessage: "Multi-Domain Settings"
|
|
271
272
|
},
|
|
272
273
|
links: [
|
|
273
274
|
{
|
|
274
|
-
id: `${
|
|
275
|
+
id: `${a}.settings.about`,
|
|
275
276
|
intlLabel: {
|
|
276
|
-
id: `${
|
|
277
|
+
id: `${a}.settings.about.label`,
|
|
277
278
|
defaultMessage: "About"
|
|
278
279
|
},
|
|
279
|
-
to: `/settings/${
|
|
280
|
-
Component: () => import("./About-
|
|
280
|
+
to: `/settings/${a}/about`,
|
|
281
|
+
Component: () => import("./About-DfCon-RP.mjs"),
|
|
281
282
|
permissions: N.admin.access
|
|
282
283
|
},
|
|
283
284
|
{
|
|
284
|
-
id: `${
|
|
285
|
+
id: `${a}.settings.general`,
|
|
285
286
|
intlLabel: {
|
|
286
|
-
id: `${
|
|
287
|
+
id: `${a}.settings.general.label`,
|
|
287
288
|
defaultMessage: "General Settings"
|
|
288
289
|
},
|
|
289
|
-
to: `/settings/${
|
|
290
|
-
Component: () => import("./Settings-
|
|
290
|
+
to: `/settings/${a}/${be}`,
|
|
291
|
+
Component: () => import("./Settings-Dj3h2ayB.mjs"),
|
|
291
292
|
permissions: N.admin.access
|
|
292
293
|
}
|
|
293
294
|
]
|
|
@@ -295,11 +296,11 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
295
296
|
},
|
|
296
297
|
async registerTrads({ locales: e }) {
|
|
297
298
|
return Promise.all(
|
|
298
|
-
e.map(async (t) => t in B ? B[t]().then(({ default:
|
|
299
|
-
data: q(
|
|
299
|
+
e.map(async (t) => t in B ? B[t]().then(({ default: i }) => ({
|
|
300
|
+
data: q(a, A(i)),
|
|
300
301
|
locale: t
|
|
301
302
|
})) : {
|
|
302
|
-
data: q(
|
|
303
|
+
data: q(a, A({})),
|
|
303
304
|
locale: t
|
|
304
305
|
})
|
|
305
306
|
);
|
|
@@ -313,19 +314,19 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
313
314
|
window.addEventListener("popstate", async () => {
|
|
314
315
|
t !== window.location.pathname && (t = window.location.pathname, await v());
|
|
315
316
|
});
|
|
316
|
-
const n = history.pushState,
|
|
317
|
+
const n = history.pushState, i = history.replaceState;
|
|
317
318
|
history.pushState = function(...r) {
|
|
318
319
|
n.apply(history, r), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
319
320
|
}, history.replaceState = function(...r) {
|
|
320
|
-
|
|
321
|
-
}, await
|
|
321
|
+
i.apply(history, r), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
322
|
+
}, await Pe();
|
|
322
323
|
}
|
|
323
324
|
};
|
|
324
325
|
export {
|
|
325
|
-
|
|
326
|
+
Fe as a,
|
|
326
327
|
N as b,
|
|
327
328
|
g as c,
|
|
328
|
-
|
|
329
|
+
_e as d,
|
|
329
330
|
be as m,
|
|
330
|
-
|
|
331
|
+
a as p
|
|
331
332
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var f=(o,t,n)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var m=(o,t,n)=>f(o,typeof t!="symbol"?t+"":t,n);const z=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-
|
|
1
|
+
"use strict";var g=Object.defineProperty;var f=(o,t,n)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var m=(o,t,n)=>f(o,typeof t!="symbol"?t+"":t,n);const z=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-oNXgzV7S.js"),b=o=>o&&o.__esModule?o:{default:o},a=b(e);e.z.object({name:e.z.string().min(1,"Name is required").max(255,"Name must be less than 255 characters"),code:e.z.string().min(1,"Code is required").max(100,"Code must be less than 100 characters").regex(/^[a-z0-9-]+$/,"Code must contain only lowercase letters, numbers, and hyphens")});e.z.object({isValid:e.z.boolean(),message:e.z.string().optional(),field:e.z.enum(["name","code"]).optional()});const s=a.default.union([a.default.string(),a.default.number()]).transform(o=>{const t=parseInt(o.toString(),10);if(isNaN(t)||t<=0)throw new a.default.ZodError([{message:"ID must be a positive integer",code:"custom",path:["id"]}]);return t}),y=e.z.object({id:s,documentId:e.z.string().min(1,"Document ID is required"),action:e.z.string().min(1,"Action is required"),actionParameters:e.z.record(e.z.any()).optional(),subject:e.z.string().min(1,"Subject is required").nullable().optional(),properties:e.z.record(e.z.any()).optional(),conditions:e.z.array(e.z.record(e.z.any())).optional()});e.z.object({sort:e.z.string().optional(),search:e.z.string().optional(),page:e.z.coerce.number().int().positive().optional(),pageSize:e.z.coerce.number().int().positive().optional()});const w=e.z.object({name:e.z.string().min(1,"Name is required"),code:e.z.string().min(1,"Code is required"),description:e.z.string().optional()}),c=w.merge(e.z.object({id:s,documentId:e.z.string().min(1,"Document ID is required")}));c.merge(e.z.object({permissions:y.array()}));const p=e.z.object({id:s,name:e.z.string().min(1,"Name is required")}),$=a.default.object({id:a.default.number(),name:a.default.string(),url:a.default.string(),width:a.default.number(),height:a.default.number(),ext:a.default.string(),size:a.default.number()}).passthrough(),h=a.default.object({name:a.default.string().min(1,"Name is required"),code:a.default.string().min(1,"Code is required"),customFields:a.default.record(a.default.any()).optional().nullable(),damRootDirectory:a.default.string().optional().nullable(),logo:$.optional().nullable()}),d=h.extend({id:s,documentId:a.default.string()});d.extend({role:c.optional().nullable()});const I=h.extend({role:s.optional().nullable(),tokens:a.default.array(s).optional().nullable()}),C=d.omit({id:!0,documentId:!0}).extend({role:s.optional().nullable(),tokens:a.default.array(s).optional().nullable()}),S=a.default.object({page:a.default.number(),pageCount:a.default.number(),pageSize:a.default.number(),total:a.default.number()}),j=e.z.object({results:e.z.array(d),pagination:S}),u=d.extend({role:c.optional().nullable(),tokens:e.z.array(p).optional().nullable()});class q{constructor(){m(this,"fetchClient",z.getFetchClient())}async validateTenant(t){try{const n=await this.fetchClient.post(`/${r.pluginId}/validate`,t);return console.log("response.data",n.data),n.data}catch(n){throw n instanceof e.z.ZodError?new Error(`Validation error: ${n.errors.map(i=>i.message).join(", ")}`):n}}async getTenants(t){try{const n=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}`,{params:t});return j.parse(n.data)}catch{throw new Error("Failed to fetch tenants")}}async getTenant(t){try{const n=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}/${t}`);return u.parseAsync(n.data)}catch{throw new Error("Failed to fetch tenant")}}async createTenant(t){try{const n=I.parse(t),i=await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}`,n);return u.parseAsync(i.data)}catch(n){throw console.log("error",n),n instanceof e.z.ZodError?new Error(`Validation error: ${n.errors.map(i=>i.message).join(", ")}`):n}}async updateTenant(t,n){try{const i=C.parse(n),l=await this.fetchClient.put(`/${r.pluginId}/${r.modelRoute}/${t}`,i);return u.parseAsync(l.data)}catch(i){throw i instanceof e.z.ZodError?new Error(`Validation error: ${i.errors.map(l=>l.message).join(", ")}`):new Error("Failed to update domain")}}async deleteTenant(t){try{await this.fetchClient.del(`/${r.pluginId}/${r.modelRoute}/${t}`)}catch{throw new Error("Failed to delete tenant")}}async getRoles(){try{const t=await this.fetchClient.get("/admin/roles");return e.z.array(c).parse(t.data.data)}catch{throw new Error("Failed to fetch roles")}}async getTokens(){try{const t=await this.fetchClient.get("/admin/api-tokens");return e.z.array(p).parse(t.data.data)}catch{throw new Error("Failed to fetch roles")}}async validateCustomField({model:t,documentId:n,field:i,value:l}){return(await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}/${t}/validate`,{documentId:n,field:i,value:l})).data}async getSettings(){return(await this.fetchClient.get(`/${r.pluginId}/license`)).data}}const E=new q;exports.api=E;
|
|
@@ -3,7 +3,7 @@ var y = (o, t, n) => t in o ? b(o, t, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var h = (o, t, n) => y(o, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { getFetchClient as w } from "@strapi/strapi/admin";
|
|
5
5
|
import r, { z as e } from "zod";
|
|
6
|
-
import { p as i, m as c } from "./index-
|
|
6
|
+
import { p as i, m as c } from "./index-7tHbI_K_.mjs";
|
|
7
7
|
e.object({
|
|
8
8
|
name: e.string().min(1, "Name is required").max(255, "Name must be less than 255 characters"),
|
|
9
9
|
code: e.string().min(1, "Code is required").max(100, "Code must be less than 100 characters").regex(/^[a-z0-9-]+$/, "Code must contain only lowercase letters, numbers, and hyphens")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const $=require("remeda"),D=require("zod"),o=require("react/jsx-runtime"),f=require("react"),w=require("react-cookie"),_=require("react-router-dom"),H=require("@strapi/strapi/admin"),i=require("@strapi/design-system"),U=require("react-dom/client"),F=require("@strapi/icons"),M=require("@tanstack/react-query"),z=e=>e&&e.__esModule?e:{default:e},Q=z(f),W="@sensinum/strapi-plugin-multi-domain",J="5.3.2",V="https://www.sensinum.com/contact",G="hello@sensinum.com",K={name:"multi-domain"},X={name:W,version:J,homepage:V,email:G},r=D.z.literal("multi-domain").parse(K.name);$.toSnakeCase(r);const h="domain",T="domain",P=`${h}s`,p="domain",k={read:"read",change:"change",create:"create",delete:"delete"},x=e=>`plugin::${r}.${k[e]}`,j={admin:{access:Object.keys(k).map(e=>({action:x(e),subject:null})),create:[{action:x("create"),subject:null}],edit:[{action:x("change"),subject:null}],delete:[{action:x("delete"),subject:null}]}},g=`data-${h}-initialized`,Y="strapi-super-admin",L=e=>e?.code===Y,Z=e=>{const t=`/admin/content-manager/collection-types/${e}/create`,n=document.querySelector(`a[href*="${t}"]`);n&&(n.style.display="none")},ee=()=>{const[{[p]:e}]=w.useCookies([p]),t=L(e),{slug:n}=_.useParams();return Q.default.useEffect(()=>{n&&(t||!e)&&Z(n)},[t,e,n]),null},te=()=>o.jsx(w.CookiesProvider,{children:o.jsx(ee,{})}),ne=({setPlugin:e})=>{const t=f.useRef(e);return f.useEffect(()=>{t.current(r)},[]),null},E={en:()=>Promise.resolve().then(()=>require("./en-hAVH8fH0.js"))},A=(e,t)=>{if(!e)throw new TypeError("Prefix can't be empty");return Object.keys(t).reduce((n,a)=>(n[`${e}.${a}`]=t[a],n),{})},S=(e,t="")=>Object.keys(e).reduce((n,a)=>{const s=t.length?`${t}.`:"";return typeof e[a]=="object"&&e[a]!==null&&!Array.isArray(e[a])?Object.assign(n,S(e[a],s+a)):n[s+a]=e[a],n},{}),oe=({onClose:e,userData:t})=>{const[{[p]:n},a]=w.useCookies([p]),[s,u]=f.useState(""),[l,m]=f.useState(n||null),d=(t[T]||[]).filter(c=>c.name.toLowerCase().includes(s.toLowerCase())),y=c=>{m(l?.id===c.id?null:c)},O=()=>{l&&(a(p,JSON.stringify(l),{path:"/",maxAge:3600*24*30,domain:window.location.hostname}),window.location.reload())};return console.log("Avatar",i.Avatar),o.jsx(i.Modal.Root,{defaultOpen:!0,onOpenChange:e,children:o.jsxs(i.Modal.Content,{children:[o.jsx(i.Modal.Header,{children:o.jsx(i.Modal.Title,{children:"Select Domain"})}),o.jsxs(i.Modal.Body,{children:[o.jsx(i.Box,{paddingBottom:4,children:o.jsxs(i.Field.Root,{name:"tenant-search",children:[o.jsx(i.Field.Label,{children:"Search domains"}),o.jsx(i.Searchbar,{name:"tenant-search",onClear:()=>u(""),value:s,onChange:c=>u(c.target.value),placeholder:"Search domains...",size:"S",clearLabel:"Clear search",children:"Search domains"})]})}),d.length===0?o.jsx(i.EmptyStateLayout,{icon:o.jsx(F.Search,{}),content:"No domains found matching your search criteria"}):o.jsx(i.Box,{maxHeight:"400px",overflow:"auto",children:o.jsxs(i.Table,{colCount:2,rowCount:d.length+1,children:[o.jsx(i.Thead,{children:o.jsxs(i.Tr,{children:[o.jsx(i.Th,{width:"60px",children:o.jsx(i.Typography,{variant:"sigma",textColor:"neutral600",children:"Select"})}),o.jsx(i.Th,{width:"40px",children:null}),o.jsx(i.Th,{children:o.jsx(i.Typography,{variant:"sigma",textColor:"neutral600",children:"Domain name"})})]})}),o.jsx(i.Tbody,{children:d.map(c=>o.jsxs(i.Tr,{children:[o.jsx(i.Td,{width:"60px",children:o.jsx(i.Checkbox,{checked:l?.id===c.id,onCheckedChange:()=>y(c),name:`tenant-${c.id}`})}),o.jsx(i.Td,{width:"40px",children:c.logo?.url&&o.jsx(i.Avatar.Item,{src:c.logo.url,alt:c.name,preview:!1,fallback:c.name[0]})}),o.jsx(i.Td,{children:o.jsx(i.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:c.name})})]},c.id))})]})})]}),o.jsxs(i.Modal.Footer,{children:[o.jsx(i.Modal.Close,{children:o.jsx(i.Button,{onClick:e,variant:"tertiary",children:"Cancel"})}),o.jsx(i.Button,{onClick:O,disabled:!l,children:"Select domain"})]})]})})},ie=new M.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}}),ae=(e,t,n,a)=>{const s=U.createRoot(e),u=()=>{document.body.removeAttribute("style"),s.unmount(),setTimeout(()=>{document.body.style.pointerEvents="auto"},0)};return t.remove(),s.render(o.jsx(i.DesignSystemProvider,{theme:a==="light"?i.lightTheme:i.darkTheme,children:o.jsx(M.QueryClientProvider,{client:ie,children:o.jsx(w.CookiesProvider,{children:o.jsx(oe,{onClose:u,userData:n})})})}))},b=(e,t)=>new Promise((n,a)=>{const l=(m=0)=>{if(m>50){a(new Error("Button not found after 50 attempts"));return}const d=(t||document).querySelector(e);if(d){n(d);return}setTimeout(()=>l(m+1),250)};l()}),I=()=>{try{const t=document.cookie.split(";").find(n=>n.trim().startsWith(`${p}=`));if(t){const n=t.split("=").at(1);if(!n)return null;const a=decodeURIComponent(n);return JSON.parse(a)}}catch(e){console.error("Error parsing tenant cookie:",e)}return null},re=e=>{const t=e.firstChild,n=t?.lastChild?.cloneNode(!0);if(t&&n instanceof HTMLElement){const a=n.firstChild;a&&n.replaceChildren(a);const s=n.querySelector("span");if(s){const u=I();s.innerText=u?`${h.toUpperCase()}: ${u.name}`:`No ${h} selected`}n.style.paddingTop="1rem",t.appendChild(n)}},v=async()=>{try{const e=H.getFetchClient(),{data:{data:t}}=await e.get("/admin/users/me");return t}catch{return null}},R=async()=>{const e=await v(),t=document.createElement("div");document.body.appendChild(t);const n=await b('nav button[aria-haspopup="menu"]'),a="aria-expanded";new MutationObserver(async u=>{if(u.some(l=>l.attributeName===a)&&n.getAttribute(a)==="true"){const l=await b("[data-radix-menu-content]");if(!(l instanceof HTMLElement))return;re(l);const m=await b('[role="menuitem"]',l),d=m.cloneNode(!0);if(e?.[T]&&e?.[T].length>1){if(!(d instanceof HTMLElement))return;d.querySelector("span").innerText=`Select ${h}`,d.addEventListener("mouseenter",function(){this.setAttribute("data-highlighted","true")}),d.addEventListener("mouseleave",function(){this.removeAttribute("data-highlighted")}),d.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),ae(t,l,e,localStorage.getItem("STRAPI_THEME")||"dark")}),m.insertAdjacentElement("afterend",d)}}}).observe(n,{attributes:!0})},B=()=>window.location.pathname==="/admin/auth/login",se=()=>window.location.pathname.startsWith("/admin/plugins/upload"),ce=()=>{const e=I(),t=document.querySelector('[data-strapi-header="true"]');if(!e||L(e)){const n=t?.querySelectorAll("button");n&&n.forEach(a=>{a.style.display="none"})}},q=$.funnel(ce,{minQuietPeriodMs:250}),N=async()=>{const e=await b('nav ul > li a[href="/admin/plugins/upload"]');e&&e.addEventListener("click",()=>{q.call()}),se()&&q.call()},C=async()=>{if(B()){document.body.removeAttribute(g);return}if(await v()){document.querySelector(`[${g}]`)||(await Promise.all([R(),N()]),document.body.setAttribute(g,"true"));return}document.body.removeAttribute(g)},le=async()=>{B()||!await v()||(document.body.setAttribute(g,"true"),await Promise.all([R(),N()]))},de={register(e){e.registerPlugin({id:r,initializer:ne,isReady:!1,name:r}),e.customFields.register({name:`unique-by-${h}`,pluginId:r,type:"string",intlLabel:{id:`${r}.custom-fields.unique-by-domain.label`,defaultMessage:"Unique by domain"},intlDescription:{id:`${r}.custom-fields.unique-by-tenant.description`,defaultMessage:"Ensures the value is unique within the domain."},components:{Input:()=>Promise.resolve().then(()=>require("./TenantCustomField-Bf6uUoKE.js"))}}),e.router.addSettingsLink({id:`${r}.settings`,intlLabel:{id:`${r}.settings.label`,defaultMessage:"Multi-Domain Settings"},links:[{id:`${r}.settings.about`,intlLabel:{id:`${r}.settings.about.label`,defaultMessage:"About"},to:`/settings/${r}/about`,Component:()=>Promise.resolve().then(()=>require("./About-DfcPwQ3q.js")),permissions:j.admin.access},{id:`${r}.settings.general`,intlLabel:{id:`${r}.settings.general.label`,defaultMessage:"General Settings"},to:`/settings/${r}/${P}`,Component:()=>Promise.resolve().then(()=>require("./Settings-tt-Wetcr.js")),permissions:j.admin.access}]})},async registerTrads({locales:e}){return Promise.all(e.map(async t=>t in E?E[t]().then(({default:a})=>({data:A(r,S(a)),locale:t})):{data:A(r,S({})),locale:t}))},async bootstrap(e){e.getPlugin("content-manager").injectComponent("listView","actions",{name:"display-create-button",Component:te});let t=window.location.pathname;window.addEventListener("popstate",async()=>{t!==window.location.pathname&&(t=window.location.pathname,await C())});const n=history.pushState,a=history.replaceState;history.pushState=function(...s){n.apply(history,s),t!==window.location.pathname&&(t=window.location.pathname,C())},history.replaceState=function(...s){a.apply(history,s),t!==window.location.pathname&&(t=window.location.pathname,C())},await le()}};exports.modelId=h;exports.modelRoute=P;exports.packageJson=X;exports.permissions=j;exports.plugin=de;exports.pluginId=r;
|
package/dist/admin/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-oNXgzV7S.js");exports.default=e.plugin;
|
package/dist/admin/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react-intl"),u=require("./index-oNXgzV7S.js"),c=()=>{const{formatMessage:e}=r.useIntl();return(s,{defaultMessage:t,values:n}={})=>e({id:`${u.pluginId}.${s}`,defaultMessage:t},n)};exports.useGetMessage=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@tanstack/react-query"),t=require("./index-
|
|
1
|
+
"use strict";const e=require("@tanstack/react-query"),t=require("./index-Cci_046h.js"),s=()=>e.useQuery({queryKey:["multi-domain-settings"],queryFn:()=>t.api.getSettings(),staleTime:120*1e3});exports.useSettings=s;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as l, Fragment as f } from "react/jsx-runtime";
|
|
2
2
|
import { useFetchClient as q } from "@strapi/strapi/admin";
|
|
3
3
|
import { useQuery as i, useQueryClient as o, useMutation as u } from "@tanstack/react-query";
|
|
4
|
-
import { a as s } from "./index-
|
|
5
|
-
import { m as F } from "./index-
|
|
4
|
+
import { a as s } from "./index-Doprxev-.mjs";
|
|
5
|
+
import { m as F } from "./index-7tHbI_K_.mjs";
|
|
6
6
|
const T = () => {
|
|
7
7
|
const e = q();
|
|
8
8
|
return i({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),d=require("@strapi/strapi/admin"),s=require("@tanstack/react-query"),u=require("./index-
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),d=require("@strapi/strapi/admin"),s=require("@tanstack/react-query"),u=require("./index-Cci_046h.js"),m=require("./index-oNXgzV7S.js"),q=()=>{const e=d.useFetchClient();return s.useQuery({queryKey:["permissions"],queryFn:async()=>{const{data:t}=await e.get("/admin/users/me/permissions");return t.data},staleTime:1e3*60*5,refetchOnWindowFocus:!1,retry:!1})},T=({permissions:e,children:t,NotAllowed:r=()=>null})=>{const{isLoading:o,data:l}=q();if(o)return null;const c=a=>e?l?.some(y=>y.action===a):!0;return e&&!e.every(a=>c(a.action))?i.jsx(r,{}):t?i.jsx(i.Fragment,{children:t}):null},n={all:[m.modelRoute],lists:()=>[...n.all,"list"],list:e=>[...n.lists(),{filters:e}],details:()=>[...n.all,"detail"],detail:e=>[...n.details(),e]},F=e=>s.useQuery({queryKey:[...n.lists(),JSON.stringify(e||{})],queryFn:()=>u.api.getTenants(e),staleTime:120*1e3}),Q=e=>s.useQuery({queryKey:n.detail(e),queryFn:()=>u.api.getTenant(e),enabled:!!e,staleTime:120*1e3}),C=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:t=>u.api.createTenant(t),onSuccess:async()=>{await e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to create tenant:",t)}})},f=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:({id:t,data:r})=>u.api.updateTenant(t,r),onSuccess:t=>{e.setQueryData(n.detail(t.id),t),e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to update domain:",t)}})},K=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:t=>u.api.deleteTenant(t),onSuccess:(t,r)=>{e.removeQueries({queryKey:n.detail(r)}),e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to delete tenant:",t)}})};exports.CheckPermissions=T;exports.useCreateTenant=C;exports.useDeleteTenant=K;exports.useTenant=Q;exports.useTenants=F;exports.useUpdateTenant=f;
|