PageSourceSearch

https://southernfm.com.au/assets/ResourcesTab-DYv5h_tV.js

js southernfm.com.au collected 2026-10-02 07:51:18 UTC 9,019 bytes, 16 lines download raw bytes

1import{q as A,r as a,j as e,h as z,B as u,ac as W,W as X,s as m,ab as o}from"./index-BvsqCpEz.js";import{u as Y}from"./use-auth-4OwtEfAA.js";import{I as M}from"./input-BedoGODD.js";import{L as h}from"./label-Csx6IcxK.js";import{T as J}from"./textarea-BuFyI3QF.js";import{v as K,u as Q}from"./upload-rules-DzRXK9g4.js";import{p as ee}from"./prepare-image-upload-Bby_BZou.js";import{F as se,o as re,P as te,T as ae,A as ie,a as oe,b as le,c as ne,d as ce,e as de,f as ue,g as me}from"./MemberDashboard-Cs5Sf23a.js";import{S as pe}from"./save-Db8rM-xy.js";import{D as fe}from"./download-0HDG1NIG.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"./check-B97Uezjq.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 xe=A("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const he=A("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ge=A("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),P=["svg","png","jpg","jpeg","gif","webp"],je=p=>{const l=(p||"").toLowerCase();return P.includes(l)?he:["zip","rar"].includes(l)?xe:["pdf","doc","docx"].includes(l)?X:ge},ve=p=>P.includes((p||"").toLowerCase()),qe=()=>{const{hasPermission:p}=Y(),l=p("manage_resources"),[R,H]=a.useState([]),[V,S]=a.useState(!0),[T,g]=a.useState(!1),[n,I]=a.useState(null),[j,v]=a.useState("Marketing"),[x,y]=a.useState(""),[N,b]=a.useState(""),[c,w]=a.useState(null),[_,d]=a.useState(!1),k=a.useRef(null),[f,C]=a.useState(null),F=async()=>{S(!0);const{data:s}=await m.from("resources").select("*").order("category",{ascending:!0}).order("sort_order",{ascending:!0,nullsFirst:!1}).order("title",{ascending:!0});H(s??[]),S(!1)};a.useEffect(()=>{F()},[]);const L=a.useMemo(()=>{const s=new Map;for(const t of R)s.has(t.category)||s.set(t.category,[]),s.get(t.category).push(t);return Array.from(s.entries())},[R]),D=()=>{v("Marketing"),y(""),b(""),w(null),k.current&&(k.current.value=""),g(!1),I(null)},B=s=>{I(s.id),g(!0),v(s.category),y(s.title),b(s.description??""),w(null)},O=async()=>{if(!x.trim()){o.error("Title is required");return}if(!n&&!c){o.error("Choose a file to upload");return}d(!0);let s,t,r;if(c){const i=K("resource-files",c);if(i){o.error("Upload rejected",{description:i}),d(!1);return}const E=c.name.split(".").pop()||"",q=`${crypto.randomUUID()}.${E}`,$=await ee(c),{error:U}=await m.storage.from("resource-files").upload(q,$,{upsert:!0});if(U){o.error("Upload failed",{description:Q("resource-files",U,c)}),d(!1);return}const{data:G}=m.storage.from("resource-files").getPublicUrl(q);s=G.publicUrl,t=c.name,r=E.toLowerCase()}if(n){const{error:i}=await m.from("resources").update({category:j.trim()||"Marketing",title:x.trim(),description:N.trim()||null,...s?{file_url:s,file_name:t,file_type:r}:{}}).eq("id",n);if(i){o.error("Failed to save",{description:i.message}),d(!1);return}o.success("Resource updated")}else{const{error:i}=await m.from("resources").insert({category:j.trim()||"Marketing",title:x.trim(),description:N.trim()||null,file_url:s,file_name:t,file_type:r});if(i){o.error("Failed to add resource",{description:i.message}),d(!1);return}o.success("Resource added")}d(!1),D(),F()},Z=async s=>{const{error:t}=await m.from("resources").delete().eq("id",s.id);if(t){o.error("Failed to delete",{description:t.message});return}o.success("Resource deleted"),F()};return V?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(z,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):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(se,{className:"h-6 w-6 text-primary"})," Resources"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Downloadable assets for members and presenters."})]}),l&&!T&&e.jsxs(u,{onClick:()=>g(!0),children:[e.jsx(re,{className:"h-4 w-4 mr-2"})," Add Resource"]})]}),l&&T&&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:n?"Edit Resource":"New Resource"}),e.jsx(u,{variant:"ghost",size:"icon",onClick:D,children:e.jsx(W,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{children:"Category"}),e.jsx(M,{value:j,onChange:s=>v(s.target.value),placeholder:"Marketing",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{children:"Title"}),e.jsx(M,{value:x,onChange:s=>y(s.target.value),placeholder:"88.3 Logo (Colour)",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(h,{children:"Description (optional)"}),e.jsx(J,{value:N,onChange:s=>b(s.target.value),rows:2,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{children:n?"Replace file (optional)":"File"}),e.jsx(M,{ref:k,type:"file",onChange:s=>{var t;return w(((t=s.target.files)==null?void 0:t[0])??null)},className:"mt-1"}),n&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Leave empty to keep the current file."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u,{variant:"ghost",onClick:D,children:"Cancel"}),e.jsxs(u,{onClick:O,disabled:_,children:[_?e.jsx(z,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(pe,{className:"h-4 w-4 mr-2"}),n?"Save Changes":"Add Resource"]})]})]}),L.length===0?e.jsx("div",{className:"bg-card border border-dashed border-border rounded-2xl p-10 text-center text-sm text-muted-foreground",children:"No resources yet."}):L.map(([s,t])=>e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-sm font-bold uppercase tracking-wider text-muted-foreground mb-3",children:s}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(r=>{const i=je(r.file_type);return e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[ve(r.file_type)?e.jsx("div",{className:"h-12 w-12 rounded-lg bg-muted flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:r.file_url,alt:"",className:"max-h-full max-w-full object-contain"})}):e.jsx("div",{className:"h-12 w-12 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(i,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm truncate",children:r.title}),r.file_type&&e.jsx("p",{className:"text-[11px] text-muted-foreground uppercase",children:r.file_type})]})]}),r.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r.description}),e.jsxs("div",{className:"mt-auto flex items-center justify-between gap-2 pt-1",children:[e.jsxs("a",{href:r.file_url,download:r.file_name,className:"inline-flex items-center gap-1.5 text-sm font-medium text-primary hover:underline",children:[e.jsx(fe,{className:"h-3.5 w-3.5"})," Download"]}),l&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>B(r),children:e.jsx(te,{className:"h-3.5 w-3.5"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>C(r),children:e.jsx(ae,{className:"h-3.5 w-3.5"})})]})]})]},r.id)})})]},s)),e.jsx(ie,{open:!!f,onOpenChange:s=>!s&&C(null),children:e.jsxs(oe,{children:[e.jsxs(le,{children:[e.jsx(ne,{children:"Delete resource"}),e.jsxs(ce,{children:['Delete "',f==null?void 0:f.title,`"? This can't be und
16one.`]})]}),e.jsxs(de,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(me,{onClick:()=>{const s=f;C(null),s&&Z(s)},children:"Delete"})]})]})})]})};export{qe 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.