PageSourceSearch

https://www.workplacegiving.org/assets/admin.navigation-DhYBa8s1.js

js workplacegiving.org collected 2026-10-04 16:52:45 UTC 12,567 bytes, 1 lines download raw bytes

1import{E as q,G as M,H as te,u as se,r as f,s as ae,j as e,d as G,e as y,f as I,ag as w}from"./index-BkoEeZ6u.js";import{u as P,T as S}from"./trash-2-CBI2stTX.js";import{u as K,a as k,D as R,c as T,S as U,v as A,b as H,s as Q,K as $,P as B,d as O,C as V,G as z}from"./sortable.esm-B20NP7gZ.js";import{r as ne}from"./auth-middleware-B8E0MhAJ.js";import{L as N}from"./loader-circle-B8oJkSfE.js";import{S as J}from"./save-D9hDuUMz.js";import{P as C}from"./plus-DSWPhfTH.js";const W=te({type:"function"}).middleware([ne]),X=q({method:"GET"}).middleware([W]).handler(M("018e3319926f248cf084b737b5e28eb74fc022832e96ff7f82eff298bb3f4c93")),Y=q({method:"POST"}).middleware([W]).handler(M("90648cb722f685c63368f1ec8b0996d852aa33935ef3f0230777d2ef6a0fd43f")),L=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2);function Z(t){return t.map(s=>({...s,_id:L()}))}function ee(t){return t.map(({_id:s,...i})=>i)}function fe(){const t=se(),[s,i]=f.useState(!1);return f.useEffect(()=>{let l=!1;return ae.auth.getUser().then(({data:n,error:a})=>{if(!l){if(a||!n.user){t({to:"/login",replace:!0});return}i(!0)}}),()=>{l=!0}},[t]),s?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-[0.2em] text-blue-600 mb-2",children:"Site chrome"}),e.jsx("h1",{className:"text-3xl font-black text-slate-900 mb-2",children:"Navigation & Footer"}),e.jsx("p",{className:"text-slate-500",children:"Edit the top navigation and footer that appear on every public page."})]}),e.jsxs("div",{className:"space-y-10",children:[e.jsx(re,{}),e.jsx(oe,{})]})]}):e.jsxs("div",{className:"text-center py-12 text-slate-500",children:[e.jsx(N,{className:"w-5 h-5 animate-spin inline mr-2"})," Loading…"]})}function re(){const t=G(),s=y(X),i=y(Y),[l,n]=f.useState([]),[a,v]=f.useState(!1),u=I({queryKey:["admin","site_settings","nav"],queryFn:()=>s({data:{key:"nav"}})});f.useEffect(()=>{if(u.data&&!a){const r=u.data?.value??[];n(Z(r)),v(!0)}},[u.data,a]);const h=P({mutationFn:()=>i({data:{key:"nav",value:ee(l).map(r=>({label:r.label,to:r.to||void 0,children:r.children?.length?r.children:void 0,columns:r.columns?.length?r.columns:void 0}))}}),onSuccess:()=>{t.invalidateQueries({queryKey:["public-site-settings"]}),w.success("Navigation saved")},onError:r=>w.error(r.message)}),g=K(k(B,{activationConstraint:{distance:4}}),k($,{coordinateGetter:Q})),x=r=>{const{active:m,over:d}=r;!d||m.id===d.id||n(c=>{const b=c.findIndex(_=>_._id===m.id),p=c.findIndex(_=>_._id===d.id);return b<0||p<0?c:H(c,b,p)})},o=()=>n(r=>[...r,{_id:L(),label:"New menu",to:""}]);return e.jsxs("section",{className:"border border-slate-200 rounded-2xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-black text-slate-900",children:"Top Navigation"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Drag to reorder. Children render as a dropdown; columns render as a mega-menu."})]}),e.jsxs("button",{type:"button",onClick:()=>h.mutate(),disabled:h.isPending||!a,className:"px-4 py-2 bg-slate-900 text-white font-bold uppercase tracking-widest text-xs rounded-lg hover:bg-blue-600 disabled:opacity-60 inline-flex items-center gap-2",children:[h.isPending?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(J,{className:"w-4 h-4"}),"Save Nav"]})]}),u.isLoading&&e.jsxs("p",{className:"text-slate-500 text-sm",children:[e.jsx(N,{className:"w-4 h-4 animate-spin inline mr-1.5"}),"Loading…"]}),a&&e.jsx(R,{sensors:g,collisionDetection:T,onDragEnd:x,children:e.jsx(U,{items:l.map(r=>r._id),strategy:A,children:e.jsx("div",{className:"space-y-3",children:l.map((r,m)=>e.jsx(le,{group:r,onChange:d=>n(c=>c.map((b,p)=>p===m?{...d,_id:b._id}:b)),onRemove:()=>n(d=>d.filter((c,b)=>b!==m))},r._id))})})}),e.jsxs("button",{type:"button",onClick:o,className:"mt-3 px-3 py-1.5 border border-slate-200 bg-white rounded-lg text-xs font-semibold text-slate-700 hover:border-blue-400 hover:text-blue-600 inline-flex items-center gap-1.5",children:[e.jsx(C,{className:"w-3 h-3"})," Add menu item"]})]})}function le({group:t,onChange:s,onRemove:i}){const{attributes:l,listeners:n,setNodeRef:a,transform:v,transition:u,isDragging:h}=O({id:t._id}),g={transform:V.Transform.toString(v),transition:u,opacity:h?.6:1},x=t.columns?.length?"columns":t.children?.length?"children":"link";return e.jsxs("div",{ref:a,style:g,className:"border border-slate-200 rounded-xl bg-white overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between bg-slate-50 border-b border-slate-200 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"p-1 rounded hover:bg-white text-slate-400 hover:text-slate-700 cursor-grab active:cursor-grabbing",...l,...n,children:e.jsx(z,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-slate-600",children:t.label||"(unnamed)"})]}),e.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-red-50 text-red-600",children:e.jsx(S,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(F,{label:"Label",children:e.jsx("input",{value:t.label,onChange:o=>s({...t,label:o.target.value}),className:j})}),e.jsx(F,{label:"URL (optional)",children:e.jsx("input",{value:t.to??"",onChange:o=>s({...t,to:o.target.value}),placeholder:"/about",className:j})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-slate-500 mb-1.5",children:"Menu type"}),e.jsxs("div",{className:"flex gap-2 text-xs",children:[e.jsx(E,{active:x==="link",onClick:()=>s({label:t.label,to:t.to}),children:"Link only"}),e.jsx(E,{active:x==="children",onClick:()=>s({label:t.label,to:t.to,children:t.children?.length?t.children:[{label:"New link",to:"/"}]}),children:"Dropdown"}),e.jsx(E,{active:x==="columns",onClick:()=>s({label:t.label,columns:t.columns?.length?t.columns:[{heading:"Section",items:[{label:"New link",to:"/"}]}]}),children:"Mega-menu"})]})]}),x==="children"&&e.jsx(D,{items:t.children??[],onChange:o=>s({...t,children:o})}
1),x==="columns"&&e.jsx(ie,{columns:t.columns??[],onChange:o=>s({...t,columns:o})})]})]})}function D({items:t,onChange:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Dropdown links"}),t.map((i,l)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{value:i.label,placeholder:"Label",onChange:n=>{const a=[...t];a[l]={...i,label:n.target.value},s(a)},className:j}),e.jsx("input",{value:i.to,placeholder:"/path",onChange:n=>{const a=[...t];a[l]={...i,to:n.target.value},s(a)},className:`${j} font-mono`}),e.jsx("button",{type:"button",onClick:()=>s(t.filter((n,a)=>a!==l)),className:"p-1.5 text-red-600 hover:bg-red-50 rounded",children:e.jsx(S,{className:"w-3.5 h-3.5"})})]},l)),e.jsxs("button",{type:"button",onClick:()=>s([...t,{label:"New link",to:"/"}]),className:"px-2.5 py-1 border border-slate-200 bg-white rounded text-xs font-semibold text-slate-700 hover:border-blue-400 hover:text-blue-600 inline-flex items-center gap-1.5",children:[e.jsx(C,{className:"w-3 h-3"})," Add link"]})]})}function ie({columns:t,onChange:s}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Mega-menu columns"}),t.map((i,l)=>e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:i.heading,placeholder:"Column heading",onChange:n=>{const a=[...t];a[l]={...i,heading:n.target.value},s(a)},className:j}),e.jsx("button",{type:"button",onClick:()=>s(t.filter((n,a)=>a!==l)),className:"p-1.5 text-red-600 hover:bg-red-100 rounded",children:e.jsx(S,{className:"w-3.5 h-3.5"})})]}),e.jsx(D,{items:i.items,onChange:n=>{const a=[...t];a[l]={...i,items:n},s(a)}})]},l)),e.jsxs("button",{type:"button",onClick:()=>s([...t,{heading:"New section",items:[{label:"Link",to:"/"}]}]),className:"px-2.5 py-1 border border-slate-200 bg-white rounded text-xs font-semibold text-slate-700 hover:border-blue-400 hover:text-blue-600 inline-flex items-center gap-1.5",children:[e.jsx(C,{className:"w-3 h-3"})," Add column"]})]})}function oe(){const t=G(),s=y(X),i=y(Y),[l,n]=f.useState([]),[a,v]=f.useState(!1),u=I({queryKey:["admin","site_settings","footer"],queryFn:()=>s({data:{key:"footer"}})});f.useEffect(()=>{if(u.data&&!a){const o=u.data?.value??[];n(Z(o)),v(!0)}},[u.data,a]);const h=P({mutationFn:()=>i({data:{key:"footer",value:ee(l)}}),onSuccess:()=>{t.invalidateQueries({queryKey:["public-site-settings"]}),w.success("Footer saved")},onError:o=>w.error(o.message)}),g=K(k(B,{activationConstraint:{distance:4}}),k($,{coordinateGetter:Q})),x=o=>{const{active:r,over:m}=o;!m||r.id===m.id||n(d=>{const c=d.findIndex(p=>p._id===r.id),b=d.findIndex(p=>p._id===m.id);return c<0||b<0?d:H(d,c,b)})};return e.jsxs("section",{className:"border border-slate-200 rounded-2xl p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-black text-slate-900",children:"Footer"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Footer columns shown at the bottom of every public page."})]}),e.jsxs("button",{type:"button",onClick:()=>h.mutate(),disabled:h.isPending||!a,className:"px-4 py-2 bg-slate-900 text-white font-bold uppercase tracking-widest text-xs rounded-lg hover:bg-blue-600 disabled:opacity-60 inline-flex items-center gap-2",children:[h.isPending?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(J,{className:"w-4 h-4"}),"Save Footer"]})]}),u.isLoading&&e.jsxs("p",{className:"text-slate-500 text-sm",children:[e.jsx(N,{className:"w-4 h-4 animate-spin inline mr-1.5"})," Loading…"]}),a&&e.jsx(R,{sensors:g,collisionDetection:T,onDragEnd:x,children:e.jsx(U,{items:l.map(o=>o._id),strategy:A,children:e.jsx("div",{className:"space-y-3",children:l.map((o,r)=>e.jsx(de,{col:o,onChange:m=>n(d=>d.map((c,b)=>b===r?{...m,_id:c._id}:c)),onRemove:()=>n(m=>m.filter((d,c)=>c!==r))},o._id))})})}),e.jsxs("button",{type:"button",onClick:()=>n(o=>[...o,{_id:L(),heading:"New column",links:[{label:"Link",to:"/"}]}]),className:"mt-3 px-3 py-1.5 border border-slate-200 bg-white rounded-lg text-xs font-semibold text-slate-700 hover:border-blue-400 hover:text-blue-600 inline-flex items-center gap-1.5",children:[e.jsx(C,{className:"w-3 h-3"})," Add column"]})]})}function de({col:t,onChange:s,onRemove:i}){const{attributes:l,listeners:n,setNodeRef:a,transform:v,transition:u,isDragging:h}=O({id:t._id}),g={transform:V.Transform.toString(v),transition:u,opacity:h?.6:1};return e.jsxs("div",{ref:a,style:g,className:"border border-slate-200 rounded-xl bg-white overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between bg-slate-50 border-b border-slate-200 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"p-1 rounded hover:bg-white text-slate-400 hover:text-slate-700 cursor-grab active:cursor-grabbing",...l,...n,children:e.jsx(z,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-slate-600",children:t.heading||"(unnamed)"})]}),e.jsx("button",{type:"button",onClick:i,className:"p-1 rounded hover:bg-red-50 text-red-600",children:e.jsx(S,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(F,{label:"Heading",children:e.jsx("input",{value:t.heading,onChange:x=>s({...t,heading:x.target.value}),className:j})}),e.jsx(D,{items:t.links,onChange:x=>s({...t,links:x})})]})]})}const j="w-full px-2.5 py-1.5 border border-slate-200 rounded-md bg-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500";function F({label:t,children:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-slate-500 mb-1",children:t}),s]})}function E({active:t,onClick:s,children:i}){return e.jsx("button",{type:"button",onClick:s,className:`px-2.5 py-1 rounded border text-xs font-semibold ${t?"bg-blue-600 text-white border-blue-600":"bg-white text-slate-700 border-slate-200 hover:border-blue-400"}`,children:i})}export{fe as component};

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.