PageSourceSearch

https://hantavirusmap.com/assets/x9k2-console.sponsors-qhqt6X3F.js

js hantavirusmap.com collected 2026-10-02 23:20:30 UTC 8,232 bytes, 1 lines download raw bytes

1import{r as o,s as p,j as e,aA as E,_ as D,aB as A,aC as L}from"./main-BZn_dPrE.js";const b={name:"",tagline:"",website_url:"",logo_url:"",tier:"banner",sort_order:0,enabled:!0,starts_at:null,ends_at:null,notes:""};function P(){const[d,x]=o.useState(null),[s,a]=o.useState(b),[m,n]=o.useState(null),[g,h]=o.useState(null),[N,j]=o.useState(!1),[f,y]=o.useState(null),u=()=>E().then(x).catch(t=>n(String(t)));o.useEffect(()=>{u(),p.from("app_settings").select("value").eq("key","sponsors_enabled").maybeSingle().then(({data:t})=>{y(["true","1","yes","on"].includes((t?.value??"").toString().trim().toLowerCase()))})},[]);const _=async()=>{n(null),h(null);try{const t={...s,tagline:s.tagline||null,website_url:s.website_url||null,logo_url:s.logo_url||null,starts_at:s.starts_at||null,ends_at:s.ends_at||null,notes:s.notes||null};await A({data:t}),a(b),h("Saved"),u()}catch(t){n(t instanceof Error?t.message:String(t))}},v=async t=>{if(confirm("Delete this sponsor?"))try{await L({data:{id:t}}),u()}catch(r){n(r instanceof Error?r.message:String(r))}},w=async t=>{n(null),j(!0);try{const r=t.name.split(".").pop()??"png",c=`${Date.now()}-${Math.random().toString(36).slice(2,8)}.${r}`,{error:i}=await p.storage.from("sponsors").upload(c,t,{contentType:t.type,upsert:!1});if(i)throw i;const{data:k}=p.storage.from("sponsors").getPublicUrl(c);a(C=>({...C,logo_url:k.publicUrl}))}catch(r){n(r instanceof Error?r.message:String(r))}finally{j(!1)}},S=async t=>{y(t);try{const{updateAdminSetting:r}=await D(async()=>{const{updateAdminSetting:c}=await import("./main-BZn_dPrE.js").then(i=>i.bW);return{updateAdminSetting:c}},[]);await r({data:{key:"sponsors_enabled",value:t?"true":"false"}})}catch(r){n(r instanceof Error?r.message:String(r))}};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Sponsors"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Site-wide enabled"}),e.jsx("input",{type:"checkbox",checked:!!f,onChange:t=>S(t.target.checked),disabled:f===null})]})]}),e.jsxs("section",{className:"rounded-lg border border-border bg-card p-4 space-y-3",children:[e.jsx("h2",{className:"text-sm font-medium",children:s.id?"Edit sponsor":"Add sponsor"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(l,{label:"Name *",children:e.jsx("input",{value:s.name,onChange:t=>a({...s,name:t.target.value}),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})}),e.jsx(l,{label:"Tier",children:e.jsxs("select",{value:s.tier,onChange:t=>a({...s,tier:t.target.value}),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm",children:[e.jsx("option",{value:"premier",children:"Premier (footer site-wide)"}),e.jsx("option",{value:"banner",children:"Banner (/sponsors only)"})]})}),e.jsx(l,{label:"Tagline",children:e.jsx("input",{value:s.tagline??"",onChange:t=>a({...s,tagline:t.target.value}),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})}),e.jsx(l,{label:"Website URL",children:e.jsx("input",{value:s.website_url??"",onChange:t=>a({...s,website_url:t.target.value}),placeholder:"https://…",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})}),e.jsx(l,{label:"Logo URL",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:s.logo_url??"",onChange:t=>a({...s,logo_url:t.target.value}),placeholder:"https://… or upload →",className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-sm"}),e.jsxs("label",{className:"cursor-pointer rounded border border-border bg-background px-2 py-1.5 text-xs hover:bg-muted",children:[N?"…":"Upload",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:t=>{const r=t.target.files?.[0];r&&w(r)}})]})]})}),e.jsx(l,{label:"Sort order",children:e.jsx("input",{type:"number",value:s.sort_order,onChange:t=>a({...s,sort_order:Number(t.target.value)||0}),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})}),e.jsx(l,{label:"Starts (optional)",children:e.jsx("input",{type:"datetime-local",value:s.starts_at?s.starts_at.slice(0,16):"",onCh
1ange:t=>a({...s,starts_at:t.target.value?new Date(t.target.value).toISOString():null}),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})}),e.jsx(l,{label:"Ends (optional)",children:e.jsx("input",{type:"datetime-local",value:s.ends_at?s.ends_at.slice(0,16):"",onChange:t=>a({...s,ends_at:t.target.value?new Date(t.target.value).toISOString():null}),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})}),e.jsx(l,{label:"Internal notes",full:!0,children:e.jsx("textarea",{value:s.notes??"",onChange:t=>a({...s,notes:t.target.value}),rows:2,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-sm"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("label",{className:"text-xs flex items-center gap-1",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:t=>a({...s,enabled:t.target.checked})}),"enabled"]}),s.logo_url&&e.jsx("img",{src:s.logo_url,alt:"",className:"ml-3 h-8 w-auto rounded border border-border bg-white p-1"}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[s.id&&e.jsx("button",{onClick:()=>a(b),className:"rounded border border-border px-3 py-1.5 text-xs hover:bg-muted",children:"Cancel"}),e.jsx("button",{onClick:_,disabled:!s.name,className:"rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50",children:s.id?"Save":"Add sponsor"})]})]}),g&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:g}),m&&e.jsx("p",{className:"text-[11px] text-destructive",children:m})]}),e.jsx("section",{className:"rounded-lg border border-border bg-card",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-xs text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left",children:"Sponsor"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Tier"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Order"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Window"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[(d??[]).map(t=>e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[t.logo_url&&e.jsx("img",{src:t.logo_url,alt:"",className:"h-6 w-auto rounded border border-border bg-white p-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.name}),t.tagline&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.tagline})]})]})}),e.jsx("td",{className:"px-3 py-2 text-xs",children:t.tier}),e.jsx("td",{className:"px-3 py-2 text-xs",children:t.sort_order}),e.jsx("td",{className:"px-3 py-2 text-xs",children:t.enabled?e.jsx("span",{className:"text-emerald-600",children:"enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"disabled"})}),e.jsxs("td",{className:"px-3 py-2 text-[11px] text-muted-foreground",children:[t.starts_at?new Date(t.starts_at).toLocaleDateString():"—"," →"," ",t.ends_at?new Date(t.ends_at).toLocaleDateString():"—"]}),e.jsxs("td",{className:"px-3 py-2 text-right",children:[e.jsx("button",{onClick:()=>a({...t}),className:"rounded border border-border px-2 py-1 text-xs hover:bg-muted",children:"Edit"}),e.jsx("button",{onClick:()=>v(t.id),className:"ml-2 rounded border border-border px-2 py-1 text-xs text-destructive hover:bg-muted",children:"Delete"})]})]},t.id)),d&&d.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"No sponsors yet."})})]})]})})]})}function l({label:d,children:x,full:s}){return e.jsxs("label",{className:`block text-xs ${s?"sm:col-span-2":""}`,children:[e.jsx("span",{className:"text-muted-foreground",children:d}),e.jsx("div",{className:"mt-1",children:x})]})}export{P 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.