PageSourceSearch

https://scrollstop.com/assets/admin.case-studies._id-Kbey3OL1.js

js scrollstop.com collected 2026-09-25 20:39:48 UTC 12,339 bytes, 1 lines download raw bytes

1import{c as P,r as y,j as e,X as L,t as u,aG as $,aH as R,u as D,ae as E,aI as M,L as F,s as U}from"./index-dt5w-xvv.js";import{u as q}from"./useQuery-MBRo_HYG.js";import{u as w}from"./useMutation-D22cL2np.js";import{u as O}from"./createServerFn-CKvmrsJq.js";import{U as T,M as H,R as _}from"./MediaUpload-hPqDm2R8.js";import{L as V}from"./loader-circle-CJCuwc-z.js";import{s as A,P as I,S as Q}from"./SyndicationToggles-ClFKA00a.js";import{A as B}from"./arrow-left-BRzzuXmW.js";import{S as K}from"./save-MPIEh9-O.js";import{S as G}from"./send-aaIZqwn6.js";import"./quote-BkNWL9aG.js";import"./auth-middleware-B-zkoLch.js";const W=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],z=P("grip-vertical",W);function J({values:l,onChange:o,bucket:k="case-study-media"}){const x=y.useRef(null),[s,b]=y.useState(0),[m,v]=y.useState(!1),g=y.useRef(null),f=async a=>{const t=Array.from(a).filter(i=>i.type.startsWith("video/"));if(!t.length)return;const r=t.filter(i=>/\.(mov|m4v|qt)$/i.test(i.name)||i.type==="video/quicktime");r.length&&u.warning(`${r.length} QuickTime file${r.length>1?"s":""} detected — only Safari can play .MOV. Re-encode to .mp4 (H.264) so all browsers can display it.`,{duration:8e3}),b(i=>i+t.length);const n=[];for(const i of t)try{const h=await $(k,i);n.push(h)}catch(h){u.error(`${i.name}: ${h.message}`)}finally{b(h=>h-1)}n.length&&(o([...l,...n]),u.success(`Uploaded ${n.length} video${n.length>1?"s":""}`))},j=a=>o(l.filter((t,r)=>r!==a)),N=(a,t)=>{if(a===t)return;const r=[...l],[n]=r.splice(a,1);r.splice(t,0,n),o(r)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{onDragOver:a=>{a.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:a=>{a.preventDefault(),v(!1),a.dataTransfer.files?.length&&f(a.dataTransfer.files)},onClick:()=>x.current?.click(),className:`relative border-2 border-dashed rounded-card p-8 text-center cursor-pointer transition-colors ${m?"border-accent-cyan bg-accent-cyan/5":"border-white/15 hover:border-white/30 bg-white/5"}`,children:[e.jsx("input",{ref:x,type:"file",accept:"video/*",multiple:!0,className:"hidden",onChange:a=>{a.target.files?.length&&f(a.target.files),a.target.value=""}}),e.jsx("div",{className:"flex flex-col items-center gap-2 text-white/60",children:s>0?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-6 h-6 animate-spin text-accent-cyan"}),e.jsxs("p",{className:"text-sm font-bold",children:["Uploading ",s," file",s>1?"s":"","…"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"w-6 h-6"}),e.jsx("p",{className:"text-sm font-bold text-white",children:"Click to upload or drag & drop videos"}),e.jsx("p",{className:"text-xs text-white/40",children:"MP4 / MOV / WebM — upload as many as you like"})]})})]}),l.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:l.map((a,t)=>e.jsxs("div",{draggable:!0,onDragStart:()=>g.current=t,onDragOver:r=>r.preventDefault(),onDrop:()=>{g.current!==null&&N(g.current,t),g.current=null},className:"group relative aspect-[9/16] rounded-card overflow-hidden bg-white/5 border border-white/10",children:[e.jsx("video",{src:a,muted:!0,playsInline:!0,preload:"metadata",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity"}),e.jsx("button",{type:"button",onClick:()=>j(t),className:"absolute top-2 right-2 p-1.5 rounded-full bg-black/70 text-white opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500","aria-label":"Remove video",children:e.jsx(L,{className:"w-3.5 h-3.5"})}),e.jsx("div",{className:"absolute top-2 left-2 p-1.5 rounded-full bg-black/70 text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-grab",children:e.jsx(z,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-[10px] font-black uppercase tracking-widest text-white opacity-0 group-hover:opacity-100 transition-opacity truncate",children:["#",t+1]})]},`${a}-${t}`))})]})}const S={slug:"",client_name:"",sector:"",hero_title:"",hero_subtitle:"",hero_image:"",hero_video:"",logo:"",services_used:[],platforms:[],campaign_period:"",challenge:"",strategy:"",execution:"",results_summary:"",metrics:[],videos:[],featured:!1,published:!0,sort_order:100,syndicate_harbor:!1,syndicate_sniper:!1,syndicate_flare:!1};function oe(){const{id:l}=R.useParams(),o=l==="new",k=D(),x=E(),[s,b]=y.useState(S),{data:m,isLoading:v}=q({queryKey:["admin_case_study",l],enabled:!o,queryFn:async()=>{const{data:t,error:r}=await U.from("case_studies").select("*").eq("id",l).maybeSingle();if(r)throw r;return t}});y.useEffect(()=>{m&&b({...S,...m,hero_video:m.hero_video??"",metrics:m.metrics??[]})},[m]);const g=O(A),f=w({mutationFn:async()=>{const t={...s,hero_video:s.hero_video||null};await M(o?null:l,t)},onSuccess:async()=>
1{if(u.success("Saved"),x.invalidateQueries({queryKey:["admin_case_studies"]}),x.invalidateQueries({queryKey:["case_studies"]}),o){k({to:"/admin/case-studies"});return}(s.syndicate_harbor||s.syndicate_sniper||s.syndicate_flare)&&await N()},onError:t=>u.error(t.message)}),j=w({mutationFn:async()=>g({data:{id:l}}),onSuccess:t=>{const r=t?.results??[];if(!r.length){u.info("No projects toggled on for this case study.");return}for(const n of r){const i=I[n.project];n.status==="sent"?u.success(`Syndicated to ${i}`):n.status==="skipped"?u.info(`${i}: ${n.detail}`):u.error(`${i} failed: ${n.detail}`)}x.invalidateQueries({queryKey:["admin_case_study",l]})},onError:t=>u.error(t.message)}),N=()=>j.mutateAsync(),a=(t,r)=>b(n=>({...n,[t]:r}));return!o&&v?e.jsx("div",{className:"p-12 text-white/40",children:"Loading…"}):e.jsxs("div",{className:"p-12 max-w-5xl",children:[e.jsxs(F,{to:"/admin/case-studies",className:"inline-flex items-center gap-2 text-white/40 hover:text-white mb-8 text-xs font-black uppercase tracking-widest",children:[e.jsx(B,{className:"w-4 h-4"})," Back"]}),e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsx("h1",{className:"text-4xl font-black tracking-tighter",children:o?"New Case Study":s.client_name||"Edit"}),e.jsxs("button",{onClick:()=>f.mutate(),disabled:f.isPending,className:"inline-flex items-center gap-2 bg-accent-cyan text-brand-black font-black px-6 py-3 rounded-pill text-sm uppercase tracking-widest disabled:opacity-50",children:[e.jsx(K,{className:"w-4 h-4"})," ",f.isPending?"Saving…":"Save"]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(p,{title:"Basics",children:e.jsxs(C,{children:[e.jsx(c,{label:"Client Name",children:e.jsx("input",{className:d,value:s.client_name,onChange:t=>a("client_name",t.target.value)})}),e.jsx(c,{label:"Slug",children:e.jsx("input",{className:d,value:s.slug,onChange:t=>a("slug",t.target.value)})}),e.jsx(c,{label:"Sector",children:e.jsx("input",{className:d,value:s.sector,onChange:t=>a("sector",t.target.value)})}),e.jsx(c,{label:"Campaign Period",children:e.jsx("input",{className:d,value:s.campaign_period,onChange:t=>a("campaign_period",t.target.value)})})]})}),e.jsxs(p,{title:"Hero",children:[e.jsx(c,{label:"Hero Title",children:e.jsx("input",{className:d,value:s.hero_title,onChange:t=>a("hero_title",t.target.value)})}),e.jsx(c,{label:"Hero Subtitle",children:e.jsx("textarea",{className:d,rows:2,value:s.hero_subtitle,onChange:t=>a("hero_subtitle",t.target.value)})}),e.jsx(c,{label:"Hero Image",children:e.jsx(H,{bucket:"case-study-media",value:s.hero_image,onChange:t=>a("hero_image",t),accept:"image/*"})}),e.jsx(c,{label:"Hero Video URL (optional)",children:e.jsx("input",{className:d,value:s.hero_video,onChange:t=>a("hero_video",t.target.value),placeholder:"https://…"})}),e.jsx(c,{label:"Logo URL",children:e.jsx("input",{className:d,value:s.logo,onChange:t=>a("logo",t.target.value)})})]}),e.jsxs(p,{title:"Services & Platforms",children:[e.jsx(c,{label:"Services Used (comma separated)",children:e.jsx("input",{className:d,value:s.services_used.join(", "),onChange:t=>a("services_used",t.target.value.split(",").map(r=>r.trim()).filter(Boolean))})}),e.jsx(c,{label:"Platforms (comma separated)",children:e.jsx("input",{className:d,value:s.platforms.join(", "),onChange:t=>a("platforms",t.target.value.split(",").map(r=>r.trim()).filter(Boolean))})})]}),e.jsxs(p,{title:"Metrics",children:[s.metrics.map((t,r)=>e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{className:d,placeholder:"Value (e.g. 5.2M)",value:t.value,onChange:n=>a("metrics",s.metrics.map((i,h)=>h===r?{...i,value:n.target.value}:i))}),e.jsx("input",{className:d,placeholder:"Label",value:t.label,onChange:n=>a("metrics",s.metrics.map((i,h)=>h===r?{...i,label:n.target.value}:i))}),e.jsx("button",{onClick:()=>a("metrics",s.metrics.filter((n,i)=>i!==r)),className:"p-3 hover:bg-red-500/20 text-red-400 rounded-card",children:e.jsx(L,{className:"w-4 h-4"})})]},r)),e.jsx("button",{onClick:()=>a("metrics",[...s.metrics,{value:"",label:""}]),className:"text-xs font-black uppercase tracking-widest text-accent-cyan",children:"+ Add Metric"})]}),e.jsxs(p,{title:"Content",children:[e.jsx(c,{label:"Challenge",children:e.jsx(_,{value:s.challenge,onChange:t=>a("challenge",t),bucket:"case-study-media"})}),e.jsx(c,{label:"Strategy",children:e.jsx(_,{value:s.strategy,onChange:t=>a("strategy",t),bucket:"case-study-media"})}),e.jsx(c,{label:"Execution",children:e.jsx(_,{value:s.execution,onChange:t=>a("execution",t),bucket:"case-study-media"})}),e.jsx(c,{label:"Results Summary",children:e.jsx(_,{value:s.results_summary,onChange:t=>a("results_summary",t),bucket:"case-study-media"})})]}),e.jsx(p,{title:"Videos",children:e.jsx(J,{values:s.videos,onChange:t=>a("videos",t)})}),e.jsxs(p,{title:"Syndication",children:[e.jsx("p",{className:"text-xs text-white/40 font-medium mb-4",children:"Toggle the projects this case study should be syndicated out to. Saving pushes it to every project switched on."}),e.jsx(Q,{value:{harbor:s.syndicate_harbor,sniper:s.syndicate_sniper,flare:s.syndicate_flare},onChange:(t,r)=>{t==="harbor"&&a("syndicate_harbor",r),t==="sniper"&&a("syndicate_sniper",r),t==="flare"&&a("syndicate_flare",r)}}),!o&&e.jsxs("div",{className:"flex items-center gap-4 pt-6",children:[e.jsxs("button",{type:"button",onClick:()=>N(),disabled:j.isPending,className:"inline-flex items-center gap-2 border border-accent-cyan/40 text-accent-cyan font-black px-5 py-2.5 rounded-pill text-xs uppercase tracking-widest disabled:opacity-50",children:[e.jsx(G,{className:"w-3.5 h-3.5"})," ",j.isPending?"Pushing…":"Push now"]}),m?.last_syndicated_at&&e.jsxs("span",{className:"text-[10px] uppercase tracking-widest text-white/30 font-bold",children:["Last pushed ",new Date(m.last_syndicated_at).toLocaleStr
1ing()]})]})]}),e.jsx(p,{title:"Settings",children:e.jsxs(C,{children:[e.jsx(c,{label:"Sort Order",children:e.jsx("input",{type:"number",className:d,value:s.sort_order,onChange:t=>a("sort_order",parseInt(t.target.value)||0)})}),e.jsx(c,{label:"Status",children:e.jsxs("div",{className:"flex gap-4 pt-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:s.published,onChange:t=>a("published",t.target.checked)})," Published"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:s.featured,onChange:t=>a("featured",t.target.checked)})," Featured"]})]})})]})})]})]})}const d="w-full bg-white/5 border border-white/10 rounded-card px-4 py-3 focus:outline-none focus:border-accent-cyan text-sm";function p({title:l,children:o}){return e.jsxs("div",{className:"glass rounded-card p-8 border border-white/10",children:[e.jsx("h2",{className:"text-xs font-black uppercase tracking-widest text-accent-cyan mb-6",children:l}),e.jsx("div",{className:"space-y-4",children:o})]})}function c({label:l,children:o}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-black uppercase tracking-widest text-white/50 block mb-2",children:l}),o]})}function C({children:l}){return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:l})}export{oe 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.