PageSourceSearch

https://rakontur.com/assets/_admin.admin.timeline-links-IZytWYTd.js

js rakontur.com collected 2026-09-24 22:04:29 UTC 14,142 bytes, 1 lines download raw bytes

1import{q as ae,v as re,w as ne,r as l,j as e,T as ce,C as se,x as he,y as xe,z as ue,A as pe,B as je,D as ge,E as fe,F as ye,G as ve,H as Se}from"./index-DTiY3O-B.js";import{a as Z}from"./useQuery-CYwuTSBS.js";import{t as m}from"./index-Cc1G-sUm.js";import{B as y}from"./button-BglpFu9j.js";import{I as h}from"./input-CSBqAUuc.js";import{S as oe}from"./switch-BNnXowpu.js";import{B as Ne}from"./badge-BjynsbRs.js";import{S as z,a as E,b as $,c as O,d as a,e as J,f as Y}from"./select-DH1mbsd5.js";import{A as be,a as Ce,b as ke,c as _e,d as Te,e as we,f as Fe,g as Ae,h as De}from"./alert-dialog-CFkTrB2u.js";import{S as Le,a as Pe,b as ze,c as Ee,d as $e,e as Oe}from"./sheet-CoqTYgnc.js";import{L as n}from"./label-Dt_XaYjy.js";import{T as Ie}from"./textarea-d1YV1x73.js";import{p as Re}from"./press-clippings-C9X9X4kj.js";import{R as ie}from"./refresh-cw-BdKb2wr-.js";import{P as Ve}from"./plus-BqW0QRbi.js";import{E as qe}from"./external-link-BauWp5T2.js";import{P as Be}from"./pencil-DlQ1fp0P.js";import{T as Ue}from"./trash-2-B1gNEomG.js";import{c as Qe}from"./createLucideIcon-ClmxC8cr.js";import{A as Ke,a as We}from"./arrow-up-LyqbvcGI.js";import"./index-U0-XPCwl.js";import"./index-LHNt3CwB.js";import"./utils-BQHNewu7.js";import"./index-CX6Bza9E.js";import"./index-Dqa5LGsd.js";import"./index-pq4NgQ4v.js";import"./index-CvpCf7DC.js";import"./index-DPPSNpWs.js";import"./chevron-down-DPIblOKu.js";import"./check-DYqwORxb.js";import"./index-gQARJxF_.js";import"./index-FHVa78tn.js";import"./x-CofEKXuZ.js";const Ge=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],He=Qe("arrow-up-down",Ge);ae({method:"POST"}).middleware([re]).handler(ne("24e7f130275c100e8f3ae2be34fbc4263063f1885f8227ae5b8b5939af490b9b"));const Me=ae({method:"POST"}).middleware([re]).handler(ne("3eada7218c1311117d8f9b97befea02b23e39dd0b94b6343985e0243485c4659")),ee="__none__",Je=r=>!r||r.legacy_source!=="press_clippings_static"||!r.legacy_id?null:Re.find(i=>i.id===r.legacy_id)?.images[0]??null;function Ye({open:r,onOpenChange:x,row:i,films:c,otherProjects:I,onSaved:R}){const[V,C]=l.useState("news"),[u,k]=l.useState(ee),[q,_]=l.useState(""),[B,v]=l.useState(""),[U,S]=l.useState(""),[T,Q]=l.useState(""),[w,K]=l.useState(""),[o,W]=l.useState(""),[G,F]=l.useState(!0),[p,H]=l.useState(""),[M,j]=l.useState(!1);l.useEffect(()=>{if(!r)return;C(i?.category??"news");const t=i?.film_id?`film:${i.film_id}`:i?.project_slug?`project:${i.project_slug}`:ee;k(t),_(i?.title??""),v(i?.date??""),S(i?.outlet??""),Q(i?.url??""),K(i?.description??""),W(i?.image_url??""),F(i?.timeline_visible??!0),H(i?.sort_order!=null?String(i.sort_order):"")},[r,i]);const g=Je(i),N=o.trim()||g,f=async t=>{t.preventDefault(),j(!0);try{const b=u.startsWith("film:")?u.slice(5):null,A=u.startsWith("project:")?u.slice(8):null;await he({data:{id:i?.id,category:V,film_id:b,project_slug:A,title:q.trim(),date:B||null,outlet:U.trim()||null,url:T.trim()||null,description:w.trim()||null,image_url:o.trim()||null,timeline_visible:G,sort_order:p?parseInt(p,10):null,extra:i?.extra&&typeof i.extra=="object"&&!Array.isArray(i.extra)?i.extra:{}}}),m.success(i?"Saved":"Created"),R()}catch(b){const A=b instanceof Error?b.message:"Failed to save";m.error(A)}finally{j(!1)}};return e.jsx(Le,{open:r,onOpenChange:x,children:e.jsxs(Pe,{className:"w-full sm:max-w-lg overflow-y-auto",children:[e.jsxs(ze,{children:[e.jsx(Ee,{children:i?"Edit timeline link":"New timeline link"}),e.jsx($e,{children:"Timeline visibility controls homepage inclusion. Project is optional — leave blank for a general homepage item."})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4 mt-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Category *"}),e.jsxs(z,{value:V,onValueChange:t=>C(t),children:[e.jsx(E,{children:e.jsx($,{})}),e.jsx(O,{children:ce.map(t=>e.jsx(a,{value:t,children:se[t]},t))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Project (optional)"}),e.jsxs(z,{value:u,onValueChange:k,children:[e.jsx(E,{children:e.jsx($,{})}),e.jsxs(O,{children:[e.jsx(a,{value:ee,children:"None / general"}),c.length>0&&e.jsxs(J,{children:[e.jsx(Y,{children:"Films"}),c.map(t=>e.jsxs(a,{value:`film:${t.id}`,children:[t.title,t.year?` (${t.year})`:""]},t.id))]}),I.length>0&&e.jsxs(J,{children:[e.jsx(Y,{children:"Other Projects"}),I.map(t=>e.jsx(a,{value:`project:${t.slug}`,children:t.title},t.slug))]})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"title",children:"Title *"}),e.jsx(h,{id:"title",required:!0,maxLength:300,value:q,onChange:t=>_(t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"date",children:"Date"}),e.jsx(h,{id:"date",type:"date",value:B,onChange:t=>v(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"outlet",children:"Outlet / Source"}),e.jsx(h,{id:"outlet",maxLength:200,value:U,onChange:t=>S(t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"url",children:"URL"}),e.jsx(h,{id:"url",type:"url",maxLength:1e3,value:T,onChange:t=>Q(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"desc",children:"Description / Summary"}),e.jsx(Ie,{id:"desc",rows:4,maxLength:8e3,value:w,onChange:t=>K(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"img",children:"Image URL"}),e.jsx(h,{id:"img",type:"url",maxLength:1e3,value:o,onChange:t=>W(t.target.value),placeholder:g?"(legacy image preserved — override here)":""}),N&&e.jsxs("div",{className:"mt-2 border border-zinc-800 rounded overflow-hidden bg-zinc-950 max-w-xs",children:[e.jsx("img",{src:N,alt:"",className:"w-full h-auto"}),!o.trim()&&g&&e.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-zinc-500",children:"legacy bundled image"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"sort",children:"Sort order"}),e.jsx(h,{id:"sort",type:"number",value:p,onChange:t=>H(t.target.value)})]}),e.jsxs("div",{className:"flex items-center justify-between border border-zinc-800 rounded px-3 py-2",children:[e.jsx(n,{htmlFor:"vis",className:"text-sm",children:"Timeline visibility"}),e.jsx(oe,{id:"vis",checked:G,onCheckedChange:F})]})]}),e.jsxs(Oe,{className:"pt-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsx(y,{type:"submit",disabled:M,children:M?"Saving…":i?"Save changes":"Create"})]})]})]})})}const P="__all__",le="__none__";function Ds(){const r=xe(),[x,i]=l.useState(P),[c,I]=l.useState(P),[R,V]=l.useState("all"),[C,u]=l.useState(""),[k,q]=l.useState(""),[_,B]=l.useState(""),[v,U]=l.useState("date"),[S,T]=l.useState("desc"),[Q,w]=l.useState(null),[K,o]=l.useState(!1),W=c.startsWith("film:")?c.slice(5):null,G=c.startsWith("project:")?c.slice(8):null,F={category:x===P?null:x,film_id:W,project_slug:G,no_project:c===le,visibility:R,date_from:C||null,date_to:k||null,search:_.trim()||null,sort:v,dir:S},p=Z({queryKey:["admin-timeline-links",F],queryFn:()=>ye({data:F})}),H=Z({queryKey:["admin-timeline-films"],queryFn:()=>ve()}
1),M=Z({queryKey:["admin-timeline-other-projects"],queryFn:()=>Se()}),j=p.data?.rows??[],g=H.data?.films??[],N=M.data?.projects??[],f=()=>{r.invalidateQueries({queryKey:["admin-timeline-links"]})},t=s=>{v===s?T(S==="asc"?"desc":"asc"):(U(s),T(s==="date"?"desc":"asc"))},b=async(s,d)=>{try{await ge({data:{id:s.id,visible:d}}),f()}catch(L){m.error(L instanceof Error?L.message:"Failed")}},A=async s=>{try{await fe({data:{id:s.id}}),m.success("Deleted"),f()}catch(d){m.error(d instanceof Error?d.message:"Failed")}},de=async()=>{try{const[s,d,L]=await Promise.all([ue(),pe(),je()]);m.success(`Synced press clippings — static: ${s.inserted}/${s.total}, film: ${d.inserted}/${d.total}, other: ${L.inserted}/${L.total}`),f()}catch(s){m.error(s instanceof Error?s.message:"Sync failed")}},[X,te]=l.useState(!1),me=async()=>{te(!0);try{const s=await Me({data:{}});m.success(`Backfilled article images — scanned ${s.scanned} · updated ${s.updated} · skipped ${s.skipped.length} · failed ${s.failures.length}`),f()}catch(s){m.error(s instanceof Error?s.message:"Backfill failed")}finally{te(!1)}},D=({col:s})=>v!==s?e.jsx(He,{className:"inline h-3 w-3 ml-1 text-zinc-600"}):S==="asc"?e.jsx(Ke,{className:"inline h-3 w-3 ml-1 text-primary"}):e.jsx(We,{className:"inline h-3 w-3 ml-1 text-primary"});return e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Timeline Links"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Single source of truth for everything on the homepage timeline."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:de,children:[e.jsx(ie,{className:"h-3.5 w-3.5 mr-1.5"}),"Sync legacy press clippings"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:me,disabled:X,children:[e.jsx(ie,{className:`h-3.5 w-3.5 mr-1.5 ${X?"animate-spin":""}`}),X?"Backfilling…":"Backfill article images"]}),e.jsxs(y,{size:"sm",onClick:()=>{w(null),o(!0)},children:[e.jsx(Ve,{className:"h-3.5 w-3.5 mr-1.5"}),"New link"]})]})]}),e.jsxs("section",{className:"mb-4 grid grid-cols-1 md:grid-cols-6 gap-3",children:[e.jsxs(z,{value:x,onValueChange:i,children:[e.jsx(E,{children:e.jsx($,{placeholder:"Category"})}),e.jsxs(O,{children:[e.jsx(a,{value:P,children:"All categories"}),ce.map(s=>e.jsx(a,{value:s,children:se[s]},s))]})]}),e.jsxs(z,{value:c,onValueChange:I,children:[e.jsx(E,{children:e.jsx($,{placeholder:"Project"})}),e.jsxs(O,{children:[e.jsx(a,{value:P,children:"All projects"}),e.jsx(a,{value:le,children:"No project / general"}),g.length>0&&e.jsxs(J,{children:[e.jsx(Y,{children:"Films"}),g.map(s=>e.jsx(a,{value:`film:${s.id}`,children:s.title},s.id))]}),N.length>0&&e.jsxs(J,{children:[e.jsx(Y,{children:"Other Projects"}),N.map(s=>e.jsx(a,{value:`project:${s.slug}`,children:s.title},s.slug))]})]})]}),e.jsxs(z,{value:R,onValueChange:s=>V(s),children:[e.jsx(E,{children:e.jsx($,{})}),e.jsxs(O,{children:[e.jsx(a,{value:"all",children:"All visibility"}),e.jsx(a,{value:"on",children:"Visible only"}),e.jsx(a,{value:"off",children:"Hidden only"})]})]}),e.jsx(h,{type:"date",value:C,onChange:s=>u(s.target.value),placeholder:"From"}),e.jsx(h,{type:"date",value:k,onChange:s=>q(s.target.value),placeholder:"To"}),e.jsx(h,{placeholder:"Search title / outlet / description…",value:_,onChange:s=>B(s.target.value)})]}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:p.isLoading?"Loading…":`${j.length} item${j.length===1?"":"s"}`}),e.jsx("div",{className:"border border-zinc-800 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-zinc-950 text-xs uppercase tracking-wider text-zinc-400",children:e.jsxs("tr",{children:[e.jsxs("th",{className:"text-left px-3 py-2 cursor-pointer select-none",onClick:()=>t("category"),children:["Category ",e.jsx(D,{col:"category"})]}),e.jsxs("th",{className:"text-left px-3 py-2 cursor-pointer select-none",onClick:()=>t("date"),children:["Date ",e.jsx(D,{col:"date"})]}),e.jsxs("th",{className:"text-left px-3 py-2 cursor-pointer select-none",onClick:()=>t("title"),children:["Title ",e.jsx(D,{col:"title"})]}),e.jsxs("th",{className:"text-left px-3 py-2 cursor-pointer select-none",onClick:()=>t("outlet"),children:["Outlet / Source ",e.jsx(D,{col:"outlet"})]}),e.jsxs("th",{className:"text-left px-3 py-2 cursor-pointer select-none",onClick:()=>t("film"),children:["Project ",e.jsx(D,{col:"film"})]}),e.jsx("th",{className:"text-center px-3 py-2",children:"Visible"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsxs("tbody",{children:[j.map(s=>e.jsxs("tr",{className:"border-t border-zinc-900 hover:bg-zinc-950/50",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx(Ne,{variant:"outline",className:"text-[10px] uppercase tracking-wider",children:se[s.category]})}),e.jsx("td",{className:"px-3 py-2 text-zinc-400 whitespace-nowrap",children:s.date??"—"}),e.jsxs("td",{className:"px-3 py-2 max-w-md",children:[e.jsx("div",{className:"line-clamp-2",children:s.title}),s.url&&e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"text-[10px] uppercase tracking-wider text-zinc-500 hover:text-primary inline-flex items-center gap-1 mt-0.5",children:["Link ",e.jsx(qe,{className:"h-3 w-3"})]})]}),e.jsx("td",{className:"px-3 py-2 text-zinc-400",children:s.outlet??"—"}),e.jsx("td",{className:"px-3 py-2 text-zinc-400",children:s.film_title??s.project_title??e.jsx("span",{className:"text-zinc-600",children:"— general —"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx(oe,{checked:s.timeline_visible,onCheckedChange:d=>b(s,d)})}),e.jsxs("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{w(s),o(!0)},children:e.jsx(Be,{className:"h-3.5 w-3.5"})}),e.jsxs(be,{children:[e.jsx(Ce,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"sm",className:"text-zinc-400 hover:text-destructive",children:e.jsx(Ue,{className:"h-3.5 w-3.5"})})}),e.jsxs(ke,{children:[e.jsxs(_e,{children:[e.jsx(Te,{children:"Delete timeline link?"}),e.jsxs(we,{children:['This will remove "',s.title,'" from the database. This action cannot be undone.']})]}),e.jsxs(Fe,{children:[e.jsx(Ae,{children:"Cancel"}),e.jsx(De,{onClick:()=>A(s),children:"Delete"})]})]})]})]})]},s.id)),!p.isLoading&&j.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:"No matching timeline links."})})]})]})}),e.jsx(Ye,{open:K,onOpenChange:o,row:Q,films:g,otherProjects:N,onSaved:()=>{o(!1),f()}})]})}export{Ds 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.