PageSourceSearch

https://chat360.ai/assets/admin.case-studies-qFYaekom.js

js chat360.ai collected 2026-10-05 14:03:37 UTC 15,585 bytes, 1 lines download raw bytes

1import{bG as D,a9 as j,c6 as P,c7 as T,c8 as F,bK as R,r as x,j as e,I as K,ab as Q}from"./index-ChBq3-4g.js";import{u as U,a as C,A as M}from"./useAdminAuth-DBjlL-5q.js";import{P as O}from"./plus-_NCZ8t9P.js";import{C as $}from"./circle-alert-9iGbgk__.js";import{L as w}from"./loader-circle-BCB7xZCK.js";import{T as v}from"./trash-2-B_z4QeIM.js";const N=()=>({slug:"",client_name:"",title:"",industry:"",use_cases:"",channels:"",outcomes:"",technologies:"",short_description:"",hero_image_url:"",hero_image_alt:"",featured_image_url:"",featured_image_alt:"",logo_url:"",challenge:"",solution:"",implementation:"",results:"",business_impact:"",metrics:[],workflow:[],testimonial_quote:"",testimonial_author:"",testimonial_role:"",published_at:new Date().toISOString().slice(0,10),is_featured:!1,is_published:!1,meta_title:"",meta_description:"",canonical_url:"",og_title:"",og_description:"",og_image:"",robots:"index, follow"}),E=a=>({id:a.id,slug:a.slug,client_name:a.client_name,title:a.title,industry:a.industry??"",use_cases:(a.use_cases??[]).join(", "),channels:(a.channels??[]).join(", "),outcomes:(a.outcomes??[]).join(", "),technologies:(a.technologies??[]).join(", "),short_description:a.short_description??"",hero_image_url:a.hero_image_url??"",hero_image_alt:a.hero_image_alt??"",featured_image_url:a.featured_image_url??"",featured_image_alt:a.featured_image_alt??"",logo_url:a.logo_url??"",challenge:a.challenge??"",solution:a.solution??"",implementation:a.implementation??"",results:a.results??"",business_impact:a.business_impact??"",metrics:(a.metrics??[]).map(c=>({label:c.label??"",value:c.value??"",number:typeof c.number=="number"?String(c.number):"",prefix:c.prefix??"",suffix:c.suffix??""})),workflow:(a.workflow??[]).map(c=>({title:c.title??"",description:c.description??""})),testimonial_quote:a.testimonial?.quote??"",testimonial_author:a.testimonial?.author??"",testimonial_role:a.testimonial?.role??"",published_at:(a.published_at??"").slice(0,10),is_featured:a.is_featured,is_published:a.is_published,meta_title:a.meta_title??"",meta_description:a.meta_description??"",canonical_url:a.canonical_url??"",og_title:a.og_title??"",og_description:a.og_description??"",og_image:a.og_image??"",robots:a.robots??"index, follow"}),h=a=>a.split(",").map(c=>c.trim()).filter(Boolean),i="w-full rounded-lg border border-border bg-white px-3 py-2 text-sm text-ink outline-none focus:ring-2 focus:ring-ring";function r({label:a,children:c}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-xs font-semibold text-ink-soft",children:a}),c]})}function z(){const a=U(),c=a.isAdmin,m=D(),k=j(P),S=j(T),q=j(F),p=R({queryKey:["admin","case-studies"],queryFn:()=>k({}),enabled:c}),[t,l]=x.useState(N()),[_,L]=x.useState(""),[g,d]=x.useState(null),b=p.data??[],y=x.useMemo(()=>{const s=_.trim().toLowerCase();return s?b.filter(n=>[n.title,n.client_name,n.slug,n.industry,...n.use_cases??[],...n.channels??[]].join(" ").toLowerCase().includes(s)):b},[b,_]),f=C({mutationFn:async()=>{const s={...t.id?{id:t.id}:{},slug:t.slug.trim(),client_name:t.client_name.trim(),title:t.title.trim(),industry:t.industry.trim(),use_cases:h(t.use_cases),channels:h(t.channels),outcomes:h(t.outcomes),technologies:h(t.technologies),short_description:t.short_description.trim(),hero_image_url:t.hero_image_url.trim()||null,hero_image_alt:t.hero_image_alt.trim()||null,featured_image_url:t.featured_image_url.trim()||null,featured_image_alt:t.featured_image_alt.trim()||null,logo_url:t.logo_url.trim()||null,challenge:t.challenge,solution:t.solution,implementation:t.implementation,results:t.results,business_impact:t.business_impact,metrics:t.metrics.map(n=>({label:n.label,value:n.value,number:n.number.trim()===""?null:Number(n.number),prefix:n.prefix||null,suffix:n.suffix||null})),workflow:t.workflow,testimonial:{quote:t.testimonial_quote,author:t.testimonial_author,role:t.testimonial_role},published_at:new Date(t.published_at).toISOString(),is_featured:t.is_featured,is_published:t.is_published,meta_title:t.meta_title.trim()||null,meta_description:t.meta_description.trim()||null,canonical_url:t.canonical_url.trim()||null,og_title:t.og_title.trim()||null,og_description:t.og_description.trim()||null,og_image:t.og_image.trim()||null,robots:t.robots.trim()||"index, follow"};return S({data:s})},onSuccess:s=>{if(!s.ok){d({ok:!1,text:s.error??"Could not save."});return}d({ok:!0,text:"Case study saved."}
1),l(N()),m.invalidateQueries({queryKey:["admin","case-studies"]}),m.invalidateQueries({queryKey:["case-studies"]})},onError:s=>d({ok:!1,text:s.message})}),A=C({mutationFn:s=>q({data:{id:s}}),onSuccess:()=>{d({ok:!0,text:"Case study deleted."}),m.invalidateQueries({queryKey:["admin","case-studies"]}),m.invalidateQueries({queryKey:["case-studies"]})}});return c?e.jsx("div",{className:"min-h-dvh bg-background",children:e.jsxs("div",{className:"container-1440 py-10",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-ink",children:"Case Studies"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Publish customer stories to /case-study."})]}),e.jsxs("button",{type:"button",onClick:()=>{l(N()),d(null)},className:"inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground",children:[e.jsx(O,{className:"h-4 w-4"})," New case study"]})]}),g&&e.jsxs("div",{className:`mt-6 flex items-center gap-2 rounded-xl border p-3 text-sm ${g.ok?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-destructive/30 bg-destructive/10 text-destructive"}`,children:[g.ok?e.jsx(K,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"}),g.text]}),e.jsxs("div",{className:"mt-8 grid grid-cols-1 gap-8 lg:grid-cols-[minmax(0,320px)_minmax(0,1fr)]",children:[e.jsxs("aside",{children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-border bg-white px-3 py-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"search",value:_,onChange:s=>L(s.target.value),placeholder:"Search case studies","aria-label":"Search case studies",className:"min-w-0 flex-1 bg-transparent text-sm outline-none"})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[p.isLoading&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(w,{className:"h-4 w-4 animate-spin"})," Loading…"]}),!p.isLoading&&y.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No case studies found."}),y.map(s=>e.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-xl border border-border bg-card p-3",children:[e.jsxs("button",{type:"button",onClick:()=>{l(E(s)),d(null),window.scrollTo({top:0,behavior:"smooth"})},className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-semibold text-ink",children:s.title}),e.jsxs("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:[s.client_name," · /",s.slug," · ",s.is_published?"Published":"Draft"]})]}),e.jsx("button",{type:"button","aria-label":`Delete ${s.title}`,onClick:()=>{confirm(`Delete “${s.title}”?`)&&A.mutate(s.id)},className:"rounded-lg p-1.5 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:e.jsx(v,{className:"h-4 w-4"})})]},s.id))]})]}),e.jsxs("form",{onSubmit:s=>{s.preventDefault(),f.mutate()},className:"flex flex-col gap-5 rounded-2xl border border-border bg-card p-5",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(r,{label:"Client name",children:e.jsx("input",{className:i,required:!0,value:t.client_name,onChange:s=>l({...t,client_name:s.target.value})})}),e.jsx(r,{label:"Slug (lowercase-with-hyphens)",children:e.jsx("input",{className:i,required:!0,value:t.slug,onChange:s=>l({...t,slug:s.target.value})})})]}),e.jsx(r,{label:"Title",children:e.jsx("input",{className:i,required:!0,value:t.title,onChange:s=>l({...t,title:s.target.value})})}),e.jsx(r,{label:"Short description",children:e.jsx("textarea",{className:`${i} min-h-20`,value:t.short_description,onChange:s=>l({...t,short_description:s.target.value})})}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(r,{label:"Industry",children:e.jsx("input",{className:i,value:t.industry,onChange:s=>l({...t,industry:s.target.value})})}),e.jsx(r,{label:"Use cases (comma separated)",children:e.jsx("input",{className:i,value:t.use_cases,onChange:s=>l({...t,use_cases:s.target.value})})}),e.jsx(r,{label:"Channels (comma separated)",children:e.jsx("input",{className:i,value:t.channels,onChange:s=>l({...t,channels:s.target.value})})}),e.jsx(r,{label:"Business outcomes (comma separated)",children:e.jsx("input",{className:i,value:t.outcomes,onChange:s=>l({...t,outcomes:s.target.value})})}),e.jsx(r,{label:"Technologies (comma separated)",children:e.jsx("input",{className:i,value:t.technologies,onChange:s=>l({...t,technologies:s.target.value})})}),e.jsx(r,{label:"Publication date",children:e.jsx("input",{type:"date",className:i,value:t.published_at,onChange:s=>l({...t,published_at:s.target.value})})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(r,{label:"Hero image URL",children:e.jsx("input",{className:i,value:t.hero_image_url,onChange:s=>l({...t,hero_image_url:s.target.value})})}),e.jsx(r,{label:"Hero image alt text",children:e.jsx("input",{className:i,value:t.hero_image_alt,onChange:s=>l({...t,hero_image_alt:s.target.value})})}),e.jsx(r,{label:"Featured (card) image URL",children:e.jsx("input",{className:i,value:t.featured_image_url,onChange:s=>l({...t,featured_image_url:s.target.value})})}),e.jsx(r,{label:"Featured image alt text",children:e.jsx("input",{className:i,value:t.featured_image_alt,onChange:s=>l({...t,featured_image_alt:s.target.value})})}),e.jsx(r,{label:"Client logo URL",children:e.jsx("input",{className:i,value:t.logo_url,onChange:s=>l({...t,logo_url:s.target.value})})})]}),[["challenge","Business challenge"],["solution","The solution"],["implementation","Agentic AI implementation"],["results","Key results"],["business_impact","Business impact"]].map(([s,n])=>e.jsx(r,{label:n,children:e.jsx("textarea",{className:`${i} min-h-28`,value:t[s],onChange:u=>l({...t,[s]:u.target.value})})},s)),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-ink-soft",children:"Metrics"}),e.jsx("button",{type:"button",onClick:()=>l({...t,metrics:[...t.metrics,{label:"",value:"",number:"",prefix:"",suffix:""}]}),className:"text-xs font-semibold text-primary",children:"+ Add metric"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:t.metrics.map((s,n)=>e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:[e.jsx("input",{className:i,placeholder:"Label",value:s.label,onChange:u=>{const o=[...t.metrics];o[n]={...s,label:u.target.value},l({...t,metrics:o})}}),e.jsx("input",{className:i,placeholder:"Display value",value:s.value,onChange:u=>{const o=[...t.metrics];o[n]={...s,value:u.target.value},l({...t,metrics:o})}}),e.jsx("input",{className:i,placeholder:"Number (optional)",value:s.number,onChange:u=>{const o=[...t.metrics];o[n]={...s,number:u.target.value},l({...t,metrics:o})}}),e.jsx("input",{className:i,placeholder:"Prefix",value:s.prefix,onChange:u=>{const o=[...t.metrics];o[n]={...s,prefix:u.target.value},l({...t,metrics:o})}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:i,placeholder:"Suffix",value:s.suffix,onChange:u=>{const o=[...t.metrics];o[n]={...s,suffix:u.target.value},l({...t,metrics:o})}}),e.jsx("button",{type:"button","aria-label":"Remove metric",onClick:()=>l({...t,metrics:t.metrics.filter((u,o)=>
1o!==n)}),className:"rounded-lg p-2 text-muted-foreground hover:text-destructive",children:e.jsx(v,{className:"h-4 w-4"})})]})]},n))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-ink-soft",children:"Workflow journey steps"}),e.jsx("button",{type:"button",onClick:()=>l({...t,workflow:[...t.workflow,{title:"",description:""}]}),className:"text-xs font-semibold text-primary",children:"+ Add step"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:t.workflow.map((s,n)=>e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)_auto]",children:[e.jsx("input",{className:i,placeholder:"Step title",value:s.title,onChange:u=>{const o=[...t.workflow];o[n]={...s,title:u.target.value},l({...t,workflow:o})}}),e.jsx("input",{className:i,placeholder:"Step description",value:s.description,onChange:u=>{const o=[...t.workflow];o[n]={...s,description:u.target.value},l({...t,workflow:o})}}),e.jsx("button",{type:"button","aria-label":"Remove step",onClick:()=>l({...t,workflow:t.workflow.filter((u,o)=>o!==n)}),className:"rounded-lg p-2 text-muted-foreground hover:text-destructive",children:e.jsx(v,{className:"h-4 w-4"})})]},n))})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsx(r,{label:"Testimonial quote",children:e.jsx("textarea",{className:`${i} min-h-20`,value:t.testimonial_quote,onChange:s=>l({...t,testimonial_quote:s.target.value})})}),e.jsx(r,{label:"Testimonial author",children:e.jsx("input",{className:i,value:t.testimonial_author,onChange:s=>l({...t,testimonial_author:s.target.value})})}),e.jsx(r,{label:"Testimonial role",children:e.jsx("input",{className:i,value:t.testimonial_role,onChange:s=>l({...t,testimonial_role:s.target.value})})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsx(r,{label:"SEO title",children:e.jsx("input",{className:i,value:t.meta_title,onChange:s=>l({...t,meta_title:s.target.value})})}),e.jsx(r,{label:"SEO description",children:e.jsx("input",{className:i,value:t.meta_description,onChange:s=>l({...t,meta_description:s.target.value})})}),e.jsx(r,{label:"Canonical URL",children:e.jsx("input",{className:i,value:t.canonical_url,onChange:s=>l({...t,canonical_url:s.target.value})})}),e.jsx(r,{label:"Social share image URL",children:e.jsx("input",{className:i,value:t.og_image,onChange:s=>l({...t,og_image:s.target.value})})}),e.jsx(r,{label:"Open Graph title",children:e.jsx("input",{className:i,value:t.og_title,onChange:s=>l({...t,og_title:s.target.value})})}),e.jsx(r,{label:"Open Graph description",children:e.jsx("input",{className:i,value:t.og_description,onChange:s=>l({...t,og_description:s.target.value})})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-6",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.is_published,onChange:s=>l({...t,is_published:s.target.checked})}),"Published"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.is_featured,onChange:s=>l({...t,is_featured:s.target.checked})}),"Featured"]})]}),e.jsx("div",{children:e.jsxs("button",{type:"submit",disabled:f.isPending,className:"inline-flex items-center gap-2 rounded-full bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground disabled:opacity-60",children:[f.isPending&&e.jsx(w,{className:"h-4 w-4 animate-spin"}),t.id?"Update case study":"Create case study"]})})]})]})]})}):e.jsx(M,{guard:a,message:"You need an admin account to manage case studies."})}export{z 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.