PageSourceSearch

https://thestreamlinefactory.com/assets/AdminNavigation-B2Bci_xC.js

js thestreamlinefactory.com collected 2026-09-24 14:20:12 UTC 6,203 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./react-vendor-C-_weJGF.js";import{b as $,u as z,c as d}from"./query-DA-B5yju.js";import{B as n,s as o,a as c}from"./index-DiEum5Ju.js";import{A as I}from"./AdminLayout-Byts1X3Z.js";import{I as x}from"./input-TSEJWV9X.js";import{F as S}from"./FormField-sjggNfPQ.js";import{C as T}from"./ConfirmDialog-D19QEs3y.js";import{u as B,a6 as q,d as H,X as O,a2 as P,g as V,a8 as G,a5 as X}from"./icons-BZJMmL1V.js";import"./radix-CMA3xQgM.js";import"./supabase-BppBjPB2.js";import"./motion-CfmjrLVm.js";import"./logo-BWhOaj1e.js";function le(){const l=$(),[t,b]=i.useState("header"),[F,h]=i.useState(!1),[g,j]=i.useState(""),[p,y]=i.useState(""),[f,v]=i.useState(null),[N,w]=i.useState(""),[C,k]=i.useState(""),[u,_]=i.useState(null),{data:m=[]}=z({queryKey:["admin-nav",t],queryFn:async()=>{const{data:s}=await o.from("navigation_items").select("*").eq("location",t).order("sort_order");return s||[]}}),L=d({mutationFn:async()=>{const{error:s}=await o.from("navigation_items").insert({label:g,url:p,location:t,sort_order:m.length});if(s)throw s},onSuccess:()=>{l.invalidateQueries({queryKey:["admin-nav",t]}),j(""),y(""),h(!1),c.success("Added!")},onError:()=>c.error("Failed to add")}),E=d({mutationFn:async()=>{if(!f)return;const{error:s}=await o.from("navigation_items").update({label:N,url:C}).eq("id",f);if(s)throw s},onSuccess:()=>{l.invalidateQueries({queryKey:["admin-nav",t]}),v(null),c.success("Updated!")},onError:()=>c.error("Failed to update")}),A=d({mutationFn:async s=>{const{error:a}=await o.from("navigation_items").delete().eq("id",s);if(a)throw a},onSuccess:()=>{l.invalidateQueries({queryKey:["admin-nav",t]}),c.success("Removed")}}),U=d({mutationFn:async({id:s,is_visible:a})=>{const{error:r}=await o.from("navigation_items").update({is_visible:!a}).eq("id",s);if(r)throw r},onSuccess:()=>l.invalidateQueries({queryKey:["admin-nav",t]})}),D=d({mutationFn:async s=>{for(const a of s)await o.from("navigation_items").update({sort_order:a.sort_order}).eq("id",a.id)},onSuccess:()=>l.invalidateQueries({queryKey:["admin-nav",t]})}),M=s=>{if(u===null||u===s)return;const a=[...m],[r]=a.splice(u,1);a.splice(s,0,r),D.mutate(a.map((K,R)=>({id:K.id,sort_order:R}))),_(null)},Q=s=>{v(s.id),w(s.label),k(s.url)};return e.jsxs(I,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold",children:"Navigation"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage header and footer menu links. Drag to reorder."})]}),e.jsxs(n,{onClick:()=>h(!0),children:[e.jsx(B,{className:"w-4 h-4 mr-1"})," Add Link"]})]}),e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsx("button",{onClick:()=>b("header"),className:`px-4 py-1.5 rounded-full text-sm transition-colors ${t==="header"?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground"}`,children:"Header Menu"}),e.jsx("button",{onClick:()=>b("footer"),className:`px-4 py-1.5 rounded-full text-sm transition-colors ${t==="footer"?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground"}`,children:"Footer Menu"})]}),F&&e.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 mb-4 space-y-3",children:[e.jsx("h3",{className:"font-display font-medium text-sm",children:"Add Navigation Link"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsx(S,{label:"Label",hint:"The text shown in the menu.",children:e.jsx(x,{value:g,onChange:s=>j(s.target.value),className:"bg-secondary",placeholder:"e.g. About Us"})}),e.jsx(S,{label:"URL",hint:"The page path or full URL. Use relative paths like /about for internal pages.",children:e.jsx(x,{value:p,onChange:s=>y(s.target.value),className:"bg-secondary",placeholder:"e.g. /about"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(n,{onClick:()=>L.mutate(),disabled:!g.trim()||!p.trim(),children:"Add"}),e.jsx(n,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"})]})]}),m.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground bg-card border border-border rounded-lg",children:e.jsxs("p",{children:["No ",t," links yet. Add your first navigation link."]})}):e.jsx("div",{className:"space-y-2",children:m.map((s,a)=>e.jsx("div",{draggable:!0,onDragStart:()=>_(a),onDragOver:r=>r.preventDefault(),onDrop:()=>M(a),className:`bg-card border border-border rounded-lg p-3 flex items-center justify-between cursor-move hover:border-border/80 transition-colors ${u===a?"opacity-50":""} ${s.is_visible?"":"opacity-60"}`,children:f===s.id?e.jsxs("div",{className:"flex items-center gap-2 flex-1 mr-2",children:[e.jsx(q,{className:"w-4 h-4 text-muted-foreground
1/40 shrink-0"}),e.jsx(x,{value:N,onChange:r=>w(r.target.value),className:"bg-secondary h-8 text-sm",placeholder:"Label"}),e.jsx(x,{value:C,onChange:r=>k(r.target.value),className:"bg-secondary h-8 text-sm",placeholder:"URL"}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>E.mutate(),children:e.jsx(H,{className:"w-4 h-4 text-primary"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>v(null),children:e.jsx(O,{className:"w-4 h-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:"w-4 h-4 text-muted-foreground/40"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:s.label}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:s.url}),!s.is_visible&&e.jsx("span",{className:"text-[11px] text-muted-foreground ml-2",children:"(hidden)"})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>Q(s),title:"Edit",children:e.jsx(P,{className:"w-4 h-4"})}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>U.mutate({id:s.id,is_visible:s.is_visible}),title:s.is_visible?"Hide":"Show",children:s.is_visible?e.jsx(V,{className:"w-4 h-4"}):e.jsx(G,{className:"w-4 h-4"})}),e.jsx(T,{title:"Remove this link?",description:`"${s.label}" will be removed from the ${t} menu.`,onConfirm:()=>A.mutate(s.id),trigger:e.jsx(n,{variant:"ghost",size:"sm",children:e.jsx(X,{className:"w-4 h-4 text-destructive"})})})]})]})},s.id))})]})}export{le 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.