PageSourceSearch

https://southernfm.com.au/assets/RedirectsTab-C1U6_sqV.js

js southernfm.com.au collected 2026-10-02 07:51:23 UTC 6,940 bytes, 1 lines download raw bytes

1import{r as a,j as e,A as B,B as l,ac as P,h as w,s as u,ab as n}from"./index-BvsqCpEz.js";import{u as W}from"./use-auth-4OwtEfAA.js";import{I as f}from"./input-BedoGODD.js";import{L as q}from"./label-Csx6IcxK.js";import{B as X}from"./badge-BI94o_1V.js";import{T as G,a as J,b as y,c as g,d as K,e as d}from"./table-jKqgeXLb.js";import{o as z,P as Q,T as Y,A as Z,a as ee,b as se,c as te,d as ae,e as re,f as ie,g as le}from"./MemberDashboard-Cs5Sf23a.js";import{C as ne}from"./check-B97Uezjq.js";import"./index-5yHiP4fM.js";import"./wind-DW6YfAyS.js";import"./arrow-left-DasGo8Zs.js";import"./calendar-BX6XEece.js";import"./user-DLmK3dAG.js";import"./format-Dogvratb.js";import"./download-0HDG1NIG.js";function p(v){let r=v.trim();return r&&(!r.startsWith("/")&&!/^https?:\/\//i.test(r)&&(r="/"+r),r)}const ye=()=>{const{isAdmin:v,hasPermission:r}=W(),o=v||r("tab_redirects"),[h,I]=a.useState([]),[C,A]=a.useState(!0),[T,j]=a.useState(!1),[_,D]=a.useState(""),[R,S]=a.useState(""),[c,i]=a.useState(null),[H,b]=a.useState(null),[k,L]=a.useState(""),[E,F]=a.use
1State(""),[m,N]=a.useState(null),x=async()=>{A(!0);const{data:s,error:t}=await u.from("redirects").select("*").order("from_path",{ascending:!0});t?n.error(t.message):I(s??[]),A(!1)};a.useEffect(()=>{x()},[]);const U=async s=>{s.preventDefault(),i("create");const{error:t}=await u.from("redirects").insert({from_path:p(_),to_path:p(R)});if(i(null),t){n.error(t.message);return}n.success("Redirect added"),D(""),S(""),j(!1),x()},$=async s=>{i(s.id);const{error:t}=await u.from("redirects").update({is_active:!s.is_active}).eq("id",s.id);i(null),t?n.error(t.message):x()},M=async s=>{i(s);const{error:t}=await u.from("redirects").update({from_path:p(k),to_path:p(E)}).eq("id",s);if(i(null),t){n.error(t.message);return}n.success("Redirect updated"),b(null),x()},O=async s=>{i(s.id);const{error:t}=await u.from("redirects").delete().eq("id",s.id);i(null),N(null),t?n.error(t.message):(n.success("Redirect deleted"),x())},V=h.filter(s=>s.is_active).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-display text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(B,{className:"h-6 w-6 text-primary"})," Redirects"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 max-w-2xl",children:[C?"Loading…":`${h.length} redirect${h.length===1?"":"s"} · ${V} active`," — ","map old or retired URLs to new ones. Destinations can be an internal path (",e.jsx("code",{children:"/program-guide"}),") or a full external URL."]})]}),o&&!T&&e.jsxs(l,{onClick:()=>j(!0),children:[e.jsx(z,{className:"h-4 w-4 mr-2"})," New Redirect"]})]}),T&&o&&e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-display font-bold text-foreground",children:"New Redirect"}),e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>j(!1),children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(q,{htmlFor:"redirect-from",children:"From path"}),e.jsx(f,{id:"redirect-from",required:!0,value:_,onChange:s=>D(s.target.value),placeholder:"/old-page",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(q,{htmlFor:"redirect-to",children:"To path or URL"}),e.jsx(f,{id:"redirect-to",required:!0,value:R,onChange:s=>S(s.target.value),placeholder:"/new-page or https://…",className:"mt-1"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(l,{type:"button",variant:"ghost",onClick:()=>j(!1),children:"Cancel"}),e.jsxs(l,{type:"submit",disabled:c==="create",children:[c==="create"?e.jsx(w,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(z,{className:"h-4 w-4 mr-2"}),"Add Redirect"]})]})]})]}),C?e.jsxs("div",{className:"flex items-center justify-center py-20 text-muted-foreground",children:[e.jsx(w,{className:"h-5 w-5 animate-spin mr-2"})," Loading redirects…"]}):h.length===0?e.jsx("div",{className:"bg-card border border-dashed border-border rounded-2xl py-12 text-center text-sm text-muted-foreground",children:"No redirects yet."}):e.jsx("div",{className:"bg-card border border-border rounded-2xl overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(G,{className:"min-w-[720px]",children:[e.jsx(J,{children:e.jsxs(y,{children:[e.jsx(g,{children:"From"}),e.jsx(g,{children:"To"}),e.jsx(g,{children:"Status"}),e.jsx(g,{className:"text-right",children:"Actions"})]})}),e.jsx(K,{children:h.map(s=>H===s.id?e.jsxs(y,{className:"bg-muted/20",children:[e.jsx(d,{children:e.jsx(f,{value:k,onChange:t=>L(t.target.value),className:"h-9"})}),e.jsx(d,{children:e.jsx(f,{value:E,onChange:t=>F(t.target.value),className:"h-9"})}),e.jsx(d,{className:"text-muted-foreground",children:"—"}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(l,{size:"icon",variant:"secondary",onClick:()=>M(s.id),disabled:c===s.id,title:"Save",children:c===s.id?e.jsx(w,{className:"h-4 w-4 animate-spin"}):e.jsx(ne,{className:"h-4 w-4"})}),e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>b(null),title:"Cancel",children:e.jsx(P,{className:"h-4 w-4"})})]})})]},s.id):e.jsxs(y,{children:[e.jsx(d,{className:"font-mono text-xs break-all",children:s.from_path}),e.jsx(d,{className:"font-mono text-xs text-muted-foreground break-all",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(B,{className:"h-3 w-3 shrink-0"}),s.to_path]})}),e.jsx(d,{children:e.jsx("button",{type:"button",onClick:()=>$(s),disabled:c===s.id||!o,className:"disabled:cursor-not-allowed",title:o?"Toggle active":void 0,children:e.jsx(X,{variant:s.is_active?"default":"secondary",children:s.is_active?"Active":"Disabled"})})}),e.jsx(d,{children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o&&e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>{b(s.id),L(s.from_path),F(s.to_path)},title:"Edit redirect",children:e.jsx(Q,{className:"h-4 w-4"})}),o&&e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>N(s),disabled:c===s.id,className:"text-destructive hover:text-destructive",title:"Delete redirect",children:e.jsx(Y,{className:"h-4 w-4"})})]})})]},s.id))})]})})}),e.jsx(Z,{open:!!m,onOpenChange:s=>!s&&N(null),children:e.jsxs(ee,{children:[e.jsxs(se,{children:[e.jsx(te,{children:"Delete redirect?"}),e.jsxs(ae,{children:["Visitors landing on ",e.jsx("strong",{children:m==null?void 0:m.from_path})," will no longer be forwarded. This can’t be undone."]})]}),e.jsxs(re,{children:[e.jsx(ie,{children:"Cancel"}),e.jsx(le,{onClick:()=>m&&O(m),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})};export{ye 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.