1import{al as j,r as o,j as e,A as b,O as m}from"./index-C5MtA4Vx.js";import{P as y}from"./plus-zBnSVI6U.js";import{C as v}from"./circle-check-CrQbSfxK.js";import{S as N}from"./save-BsvA-dh8.js";import{T as S}from"./trash-2-BVZnySht.js";function z(){const{redirects:p}=j.useLoaderData(),[a,i]=o.useState(p),[l,d]=o.useState(!1),[c,x]=o.useState(!1),u=()=>i([...a,{from:"",to:"",type:"301"}]),n=(t,s,r)=>i(a.map((h,g)=>g===t?{...h,[s]:r}:h)),f=t=>i(a.filter((s,r)=>r!==t)),w=async()=>{if(!m)return alert("Sanity project ID not set in .env");d(!0);try{await m.patch("siteSettings").setIfMissing({_type:"siteSettings",_id:"siteSettings"}).set({redirects:a.filter(t=>t.from&&t.to).map((t,s)=>({_type:"object",_key:`r${s}`,...t}))}).commit({autoGenerateArrayKeys:!0}),x(!0),setTimeout(()=>x(!1),3e3)}finally{d(!1)}};return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Redirects"}),e.jsx("p",{className:"text-white/50 text-sm mt-1",children:"301 and 302 URL redirects â like Yoast"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:u,className:"flex items-center gap-2 px-5 py-2.5 bg-orange-500 hover:bg-orange-600 text-white text-sm font-medium rounded-lg transition-colors",children:[e.jsx(y,{size:15}),"Add Redirect"]}),e.jsxs("button",{onClick:w,disabled:l,className:"flex items-center gap-2 px-4 py-2.5 bg-white/10 hover:bg-white/15 text-white text-sm font-medium rounded-lg transition-colors",children:[c?e.jsx(v,{size:14,className:"text-green-400"}):e.jsx(N,{size:14}),c?"Saved!":l?"Savingâ¦":"Save All"]})]})]}),e.jsx("div",{className:"bg-[#161b22] rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left text-white/40 text-xs font-medium px-5 py-3.5 uppercase tracking-wider",children:"From (old path)"}),e.jsx("th",{className:"w-8"}),e.jsx("th",{className:"text-left text-white/40 text-xs font-medium px-4 py-3.5 uppercase tracking-wider",children:"To (new URL)"}),e.jsx("th",{className:"text-left text-white/40 text-xs font-medium px-4 py-3.5 uppercase tracking-wider w-36",children:"Type"}),e.jsx("th",{className:"w-12"})]})}),e.jsxs("tbody",{children:[a.map((t,s)=>e.jsxs("tr",{className:"border-b border-white/5 last:border-0",children:[e.jsx("td",{className:"px-5 py-3",children:e.jsx("input",{value:t.from,onChange:r=>n(s,"from",r.target.value),placeholder:"/old-page",className:"w-full bg-white/5 border border-white/10 rounded px-3 py-2 text-sm text-white font-mono placeholder-white/30 focus:outline-none focus:border-orange-500/50"})}),e.jsx("td",{className:"py-3 text-white/30",children:e.jsx(b,{size:14})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("input",{value:t.to,onChange:r=>n(s,"to",r.target.value),placeholder:"/new-page or https://â¦",className:"w-full bg-white/5 border border-white/10 rounded px-3 py-2 text-sm text-white font-mono placeholder-white/30 focus:outline-none focus:border-orange-500/50"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("select",{"admin-select":!0,value:t.type,onChange:r=>n(s,"type",r.target.value),className:"w-full bg-white/5 border border-white/10 rounded px-3 py-2 text-sm text-white focus:outline-none",children:[e.jsx("option",{value:"301",children:"301 â Permanent"}),e.jsx("option",{value:"302",children:"302 â Temporary"})]})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("button",{onClick:()=>f(s),className:"p-1.5 text-white/30 hover:text-red-400 hover:bg-red-400/10 rounded transition-colors",children:e.jsx(S,{size:14})})})]},s)),a.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-5 py-10 text-center text-white/30 text-sm",children:'No redirects yet â click "Add Redirect" to get started'})})]})]})}),a.length>0&&e.jsx("p",{className:"text-white/30 text-xs mt-3",children:"Redirects are applied server-side via the Sanity-powered request handler. Changes take effect on next server restart."})]})}
1export{z 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.