PageSourceSearch

https://elfdegebod.com/assets/admin-tenants-BI0LwJe0.js

js elfdegebod.com collected 2026-10-07 16:42:01 UTC 6,217 bytes, 1 lines download raw bytes

1import{e as C,u as v,d as h,j as e,r as u}from"./vendor-query-Z3GGpY1C.js";import{d as k,a as g}from"./index-BcefymES.js";import"./vendor-radix-Dl5I7pIb.js";function A(t){if(!t)return{};try{const a=JSON.parse(t);return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}catch{return{}}}function x({msg:t}){return e.jsxs("div",{style:{maxWidth:640,margin:"4rem auto",padding:"0 1rem",fontFamily:"system-ui, sans-serif"},children:[e.jsx("h1",{style:{fontSize:22,fontWeight:500},children:"Tenant management"}),e.jsx("p",{style:{color:"#666"},children:t}),e.jsx("a",{href:"/admin",style:{color:"#185FA5"},children:"Go to /admin"})]})}function L(){var y;const t=C(),a=k(),p=v({queryKey:["/api/admin/me"],queryFn:()=>g("GET","/api/admin/me").then(n=>n.json()).catch(()=>null),enabled:!!a}),r=((y=p.data)==null?void 0:y.role)==="admin",o=v({queryKey:["/api/admin/tenants"],queryFn:()=>g("GET","/api/admin/tenants").then(n=>n.json()),enabled:!!a&&r}),l=()=>t.invalidateQueries({queryKey:["/api/admin/tenants"]}),d=h({mutationFn:n=>g("POST","/api/admin/tenants",n).then(s=>s.json()),onSuccess:l}),m=h({mutationFn:n=>g("POST",`/api/admin/tenants/${n.id}/domains`,{domain:n.domain}).then(s=>s.json()),onSuccess:l}),c=h({mutationFn:n=>g("PATCH",`/api/admin/tenants/${n.id}/site-config`,{brandTokens:n.brandTokens}).then(s=>s.json()),onSuccess:l});return a?p.isLoading?e.jsx(x,{msg:"Checking access…"}):r?e.jsxs("div",{style:{maxWidth:860,margin:"2.5rem auto",padding:"0 1rem",fontFamily:"system-ui, sans-serif",color:"#1a1a1a"},children:[e.jsx("h1",{style:{fontSize:22,fontWeight:500,marginBottom:4},children:"Tenant management"}),e.jsxs("p",{style:{color:"#666",marginTop:0},children:["One codebase, many restaurants. Each tenant resolves by domain and can set its own brand. Multi-tenant routing is ",o.data?"live":"loading"," — until ",e.jsx("code",{children:"MULTITENANT_ENABLED"})," is on, every host serves the default tenant."]}),e.jsx(z,{onCreate:(n,s)=>d.mutate({slug:n,name:s}),busy:d.isPending,error:d.error}),o.isLoading&&e.jsx("p",{children:"Loading tenants…"}),o.error&&e.jsx("p",{style:{color:"#A32D2D"},children:"Failed to load tenants. Are you the owner?"}),e.jsx("div",{style:{display:"grid",gap:16,marginTop:20},children:(o.data??[]).map(n=>e.jsx(F,{t:n,onAddDomain:s=>m.mutate({id:n.id,domain:s}),onSetBrand:s=>c.mutate({id:n.id,brandTokens:s}),savingBrand:c.isPending,savingDomain:m.isPending},n.id))})]}):e.jsx(x,{msg:"Owner only — this account is not a full admin."}):e.jsx(x,{msg:"Please log in at /admin first (owner login), then reload this page."})}function z({onCreate:t,busy:a,error:p}){const[r,o]=u.useState(""),[l,d]=u.useState(""),m=/^[a-z0-9-]{2,}$/.test(r)&&l.trim().length>0;return e.jsxs("div",{style:T,children:[e.jsx("div",{style:{fontWeight:500,marginBottom:8},children:"Add a tenant"}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("input",{style:f,placeholder:"slug (a-z0-9-)",value:r,onChange:c=>o(c.target.value.toLowerCase())}),e.jsx("input",{style:f,placeholder:"Display name",value:l,onChange:c=>d(c.target.value)}),e.jsx("button",{style:{...j,opacity:m&&!a?1:.5},disabled:!m||a,onClick:()=>{t(r.trim(),l.trim()),o(""),d("")},children:a?"Creating…":"Create"})]}),!!p&&e.jsx("div",{style:{color:"#A32D2D",fontSize:13,marginTop:6},children:"Create failed (slug already taken?)."})]})}function F({t,onAddDomain:a,onSetBrand:p,savingBrand:r,savingDomain:o}){var b;const l=u.useMemo(()=>{var i;return A((i=t.siteConfig)==null?void 0:i.brandTokens)},[(b=t.siteConfig)==null?void 0:b.brandTokens]),[d,m]=u.useState(l["--primary"]||"#0b131f"),[c,y]=u.useState(l["--hotel-green"]||"#0b131f"),[n,s]=u.useState("");return e.jsxs("div",{style:T,children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:8},children:e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500,fontSize:16},children:t.name}),e.jsxs("span",{style:{color:"#888",marginLeft:8},children:["#",t.id," · ",t.slug]}),t.isDefault&&e.jsx("span",{style:S,children:"default"})]})}),e.jsxs("div",{style:{marginTop:10,fontSize:14},children:[e.jsx("div",{style:{color:"#666",marginBottom:4},children:"Domains"}),t.domains.length===0&&e.jsx("div",{style:{color:"#aaa"},children:"none yet"}),t.domains.map(i=>e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("code",{children:i.domain}),i.isPrimary&&e.jsx("span",{style:{...S,background:"#E6F1FB",color:"#185FA5"},children:"primary"}),e.jsxs("span",{style:{color:"#aaa",fontSize:12},children:["TLS ",i.tlsStatus]})]},i.id)),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:6},children:[e.jsx("input",{style:f,placeholder:"add domain (lowercase)",value:n,onChange:i=>s(i.target.value.toLowerCase())}),e.jsx("button",{style:{...j,opacity:n&&!o?1:.5},disabled:!n||o,onClick:()=>{a(n.trim()),s("")},children:"Add"})]})]}),e.jsxs("div",{style:{marginTop:12,fontSize:14},children:[e.jsx("div",{style:{color:"#666",marginBottom:4},children:"Brand colors (applied as CSS variables on the tenant's site)"}),e.jsxs("div",{style:{display:"flex",gap:16,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("label",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("span",{style:{color:"#666"},children:"--primary"}),e.jsx("input",{type:"color",value:d,onChange:i=>m(i.target.value)}),e.jsx("code",{style:{fontSize:12},children:d})]}),e.jsxs("label",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("span",{style:{color:"#666"},children:"--hotel-green"}),e.jsx("input",{type:"color",value:c,onChange:i=>y(i.target.value)}),e.jsx("code",{style:{fontSize:12},children:c})]}),e.jsx("button",{style:{...j,opacity:r?.5:1},disabled:r,onClick:()=>p({"--primary":d,"--hotel-green":c}),children:r?"Saving…":"Save brand"})]})]})]})}const T={border:"1px solid #e3e3e0",borderRadius:12,padding:16,background:"#fff"},f={border:"1px solid #ccc",borderRadius:8,padding:"6px 10px",fontSize:14,minWidth:160},j={border:"none",borderRadius:8,padding:"7px 14px",fontSize:14,background:"#0b131f",color:"#fff",cursor:"pointer"},S={marginLeft:8,fontSize:11,padding:"2px 6px",borderRadius:6,background:"#EAF3DE",color:"#3B6D11"};export{L as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.