PageSourceSearch

https://bsdxr.com/assets/AdminSettings-DLlLAOjN.js

js bsdxr.com collected 2026-10-09 23:16:24 UTC 12,621 bytes, 6 lines download raw bytes

1import{r as p,j as e}from"./react-vendor-pCX_OoB9.js";import{c as R,a1 as A,a as G,b as C,s as f}from"./index-CvanvASE.js";import{c as q,D as E,d as M}from"./Admin-D9mYboEK.js";import{A as L,a as S}from"./arrow-up-DRcyrYtS.js";import"./pdf-CWGzimER.js";import"./radix-DPgQtnKV.js";import"./charts-POWNPXyX.js";import"./search-D7volUV5.js";import"./quote-D-Gc74zt.js";import"./calculator-BKj-pbEH.js";import"./package-D7nlerUR.js";import"./external-link-BrCjjuhk.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const D=R("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),U=[{key:"hero_tagline",label:"Hero Tagline"},{key:"hero_intro",label:"Hero Intro Text"},{key:"logo_url",label:"Logo URL"},{key:"footer_tagline",label:"Footer Tagline"},{key:"footer_address",label:"Footer Address"},{key:"footer_email",label:"Footer Email"},{key:"footer_phone",label:"Footer Phone"},{key:"footer_links_json",label:'Footer Links (JSON: [{"label":"Docs","url":"https://..."}])'},{key:"ga_measurement_id",label:"Google Analytics Measurement ID (e.g. G-XXXXXXXXXX)"},{key:"admin_notification_email",label:"Admin Notification Email (case study download alerts, etc.)"}],F=[{key:"social_twitter",label:"Twitter / X URL"},{key:"social_linkedin",label:"LinkedIn URL"},{key:"social_instagram",label:"Instagram URL"},{key:"social_youtube",label:"YouTube URL"},{key:"social_facebook",label:"Facebook URL"},{key:"social_github",label:"GitHub URL"}];function Y(){const y=A(),[i,c]=p.useState({}),[m,v]=p.useState(null),[x,l]=p.useState(null),{data:u}=G({queryKey:["site_settings_raw"],queryFn:async()=>{const{data:t,error:a}=await f.from("site_settings").select("*");if(a)throw a;return t}});p.useEffect(()=>{if(u&&Array.isArray(u)){const t={};u.forEach(a=>{t[a.key]=a.value||""}),c(t)}},[u]);const _=C({mutationFn:async()=>{const t=[{key:"logo_url"},{key:"logo_light_url"}],a=[{key:"custom_head_code"},{key:"custom_body_code"}],d=[...U,...F,...t,...a];for(const{key:g}of d)i[g]!==void 0&&await f.from("site_settings").upsert({key:g,value:i[g]||""},{onConflict:"key"})},onSuccess:()=>{y.invalidateQueries({queryKey:["site_settings_raw"]}),y.invalidateQueries({queryKey:["site_settings"]})}}),j=async(t,a,d)=>{if(!t)return;const g=t.name.split(".").pop(),N=`${d}.${g}`,{error:k}=await f.storage.from("media").upload(N,t,{upsert:!0});if(k){alert(k.message);return}const{data:s}=f.storage.from("media").getPublicUrl(N),r=s.publicUrl;c(o=>({...o,[a]:r})),await f.from("site_settings").upsert({key:a,value:r},{onConflict:"key"}),y.invalidateQueries({queryKey:["site_settings_raw"]}),y.invalidateQueries({queryKey:["site_settings"]})},b="w-full bg-background border border-border px-3 py-2 text-sm text-foreground focus:outline-none focus:border-foreground transition-colors",h="block text-xs uppercase tracking-widest text-muted-foreground mb-1";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-xl font-heading font-bold",children:"Site Settings"}),U.map(({key:t,label:a})=>e.jsxs("div",{children:[e.jsx("label",{className:h,children:a}),t==="hero_intro"||t==="footer_links_json"?e.jsx("textarea",{rows:t==="footer_links_json"?5:3,value:i[t]||"",onChange:d=>c({...i,[t]:d.target.value}),className:`${b} resize-none ${t==="footer_links_json"?"font-mono text-xs":""}`}):e.jsx("input",{type:"text",value:i[t]||"",onChange:d=>c({...i,[t]:d.target.value}),className:b}),t==="footer_links_json"&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1",children:["JSON array, e.g. [","{",'"label":"Docs","url":"https://..."',"}","]. Use full URLs for external, paths like /about for internal."]}),t==="ga_measurement_id"&&e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Enter your GA4 Measurement ID. Find it in Google Analytics → Admin → Data Streams → your stream."})]},t)),e.jsxs("div",{className:"border-t border-border pt-6 mt-6",children:[e.jsx("h3",{className:"text-sm font-heading font-bold uppercase tracking-widest mb-4",children:"Social Media Links"}),e.jsx("p",{className:"text-[10px] text-muted-foreground mb-4",children:"Leave blank to hide from footer."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:F.map(({key:t,label:a})=>e.jsxs("div",{children:[e.jsx("label",{className:h,children:a}),e.jsx("input",{type:"url",value:i[t]||"",onChange:d=>c({...i,[t]:d.target.value}),className:b,placeholder:"https://..."})]},t))})]}),e.jsxs("div",{className:"border-t border-border pt-6 mt-6",children:[e.jsx("h3",{className:"text-sm font-heading font-bold uppercase tracking-widest mb-4",children:"Logos"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Dark Mode Logo"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:t=>{var a;return v(((a=t.target.files)==null?void 0:a[0])||null)},className:"text-sm text-muted-foreground"}),e.jsx("button",{onClick:()=>m&&j(m,"logo_url","logo-dark"),disabled:!m,className:"border border-border px-3 py-1 text-xs uppercase tracking-widest hover:border-foreground transition-colors disabled:opacity-50 shrink-0",children:"Upload"})]}),i.logo_url&&e.jsx("img",{loading:"lazy",decoding:"async",src:i.logo_url,alt:"Dark Logo",className:"mt-2 h-12 border border-border p-1 bg-background"})]}),e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Light Mode Logo"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:t=>{var a;return l(((a=t.target.files)==null?void 0:a[0])||null)},className:"text-sm text-muted-foreground"}),e.jsx("button",{onClick:()=>x&&j(x,"logo_light_url","logo-light"),disabled:!x,className:"border border-border px-3 py-1 text-xs uppercase tracking-widest hover:border-foreground transition-colors disabled:opacity-50 shrink-0",children:"Upload"})]}),i.logo_light_url&&e.jsx("img",{loading:"lazy",decoding:"async",src:i.logo_light_url,alt:"Light Logo",className:"mt-2 h-12 border border-border p-1 bg-white"})]})]})]}),e.jsx(K,{}),e.jsxs("div",{className:"border-t border-border pt-6 mt-6",children:[e.jsx("h3",{className:"text-sm font-heading font-bold uppercase tracking-widest mb-2",children:"Custom Code"}),e.jsx("p",{className:"text-[10px] text-muted-foreground mb-4",children:"Pasted HTML/JS is injected on every page. Use for analytics, chat widgets, pixels, etc. Be careful — bad code can break the site."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Head Code (injected into <head>)"}),e.jsx("textarea",{rows:6,value:i.custom_head_code||"",onChange:t=>c({...i,custom_head_code:t.target.value}),className:`${b} resize-y font-mono text-xs`,placeholder:"<!-- e.g. tracking pixels, meta tags, analytics scripts -->"})]}),e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Body Code (injected at end of <body>
6)"}),e.jsx("textarea",{rows:6,value:i.custom_body_code||"",onChange:t=>c({...i,custom_body_code:t.target.value}),className:`${b} resize-y font-mono text-xs`,placeholder:"<!-- e.g. chat widgets, late-loading scripts -->"})]})]})]}),e.jsx("button",{onClick:()=>_.mutate(),disabled:_.isPending,className:"border border-foreground px-6 py-2 text-sm uppercase tracking-widest glitch-btn hover:bg-foreground hover:text-background transition-colors disabled:opacity-50",children:_.isPending?"Saving...":"Save Settings"})]})}function K(){const y=A(),i="w-full bg-background border border-border px-2 py-1 text-xs text-foreground focus:outline-none focus:border-foreground transition-colors",{data:c}=G({queryKey:["site_settings","admin_nav_config"],queryFn:async()=>{const{data:s}=await f.from("site_settings").select("value").eq("key","admin_nav_config").maybeSingle();return(s==null?void 0:s.value)??null}}),m=p.useMemo(()=>q(c),[c]),[v,x]=p.useState(m.items),[l,u]=p.useState(m.groups),[_,j]=p.useState("");p.useEffect(()=>{x(m.items),u(m.groups)},[m]);const b=(s,r)=>{const o=[...v],n=s+r;n<0||n>=o.length||([o[s],o[n]]=[o[n],o[s]],x(o))},h=(s,r)=>{x(v.map(o=>o.to===s?{...o,group:r}:o))},t=()=>{const s=_.trim();!s||l.includes(s)||(u([...l,s]),j(""))},a=(s,r)=>{const o=[...l],n=s+r;n<0||n>=o.length||([o[s],o[n]]=[o[n],o[s]],u(o))},d=s=>{if(v.some(r=>r.group===s)){alert(`Cannot remove "${s}" — it still contains items. Move them first.`);return}u(l.filter(r=>r!==s))},g=C({mutationFn:async()=>{const s=n=>{const w=l.indexOf(n);return w===-1?9999:w},r=[...v].sort((n,w)=>s(n.group)-s(w.group)),o={groups:l,order:r.map(n=>({to:n.to,group:n.group}))};await f.from("site_settings").upsert({key:"admin_nav_config",value:JSON.stringify(o)},{onConflict:"key"})},onSuccess:()=>{y.invalidateQueries({queryKey:["site_settings","admin_nav_config"]})}}),N=C({mutationFn:async()=>{await f.from("site_settings").delete().eq("key","admin_nav_config")},onSuccess:()=>{x(E),u(M),y.invalidateQueries({queryKey:["site_settings","admin_nav_config"]})}}),k=l.map(s=>({group:s,items:v.map((r,o)=>({...r,_idx:o})).filter(r=>r.group===s)}));return e.jsxs("div",{className:"border-t border-border pt-6 mt-6",children:[e.jsx("h3",{className:"text-sm font-heading font-bold uppercase tracking-widest mb-2",children:"Admin Navigation Order"}),e.jsx("p",{className:"text-[10px] text-muted-foreground mb-4",children:"Reorder items, change which group they belong to, and add new groups. Use ↑/↓ to move within / across groups."}),e.jsxs("div",{className:"mb-6 border border-border p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-muted-foreground mb-2",children:"Groups"}),e.jsx("div",{className:"space-y-1 mb-3",children:l.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"flex-1 font-mono",children:s}),e.jsx("button",{onClick:()=>a(r,-1),className:"border border-border p-1 hover:border-foreground",disabled:r===0,children:e.jsx(L,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>a(r,1),className:"border border-border p-1 hover:border-foreground",disabled:r===l.length-1,children:e.jsx(S,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>d(s),className:"border border-border px-2 py-1 text-[10px] uppercase tracking-widest hover:border-foreground",children:"Remove"})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:_,onChange:s=>j(s.target.value),placeholder:"New group name",className:i}),e.jsx("button",{onClick:t,className:"border border-border px-3 py-1 text-[10px] uppercase tracking-widest hover:border-foreground shrink-0",children:"Add Group"})]})]}),e.jsx("div",{className:"space-y-4",children:k.map(({group:s,items:r})=>e.jsxs("div",{className:"border border-border p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-brand mb-2",children:s}),r.length===0&&e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Empty"}),e.jsx("div",{className:"space-y-1",children:r.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"flex-1 truncate",children:[e.jsx("span",{className:"font-mono text-muted-foreground",children:o.to||"/"}),e.jsx("span",{className:"ml-2",children:o.label})]}),e.jsx("select",{value:o.group,onChange:n=>h(o.to,n.target.value),className:"bg-background border border-border px-2 py-1 text-xs",children:l.map(n=>e.jsx("option",{value:n,children:n},n))}),e.jsx("button",{onClick:()=>b(o._idx,-1),className:"border border-border p-1 hover:border-foreground",children:e.jsx(L,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>b(o._idx,1),className:"border border-border p-1 hover:border-foreground",children:e.jsx(S,{className:"w-3 h-3"})})]},o.to))})]},s))}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{onClick:()=>g.mutate(),disabled:g.isPending,className:"border border-foreground px-4 py-2 text-xs uppercase tracking-widest hover:bg-foreground hover:text-background transition-colors disabled:opacity-50",children:g.isPending?"Saving...":"Save Navigation"}),e.jsxs("button",{onClick:()=>{confirm("Reset navigation to defaults?")&&N.mutate()},disabled:N.isPending,className:"border border-border px-4 py-2 text-xs uppercase tracking-widest hover:border-foreground transition-colors disabled:opacity-50 flex items-center gap-2",children:[e.jsx(D,{className:"w-3 h-3"})," Reset"]})]})]})}export{Y 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.