PageSourceSearch

https://indiespring.com/assets/AdminServiceForm-Cd0L6TiK.js

js indiespring.com collected 2026-10-04 20:08:56 UTC 17,065 bytes, 1 lines download raw bytes

1import{a4 as M,a5 as V,a6 as O,n as G,w as Q,r as S,j as e,L as Y}from"./react-vendor-o-62gUsK.js";import{u as J,a as A,F as K,b as t,c as r,d as c,e as n,f as o,g as E,T as j,t as W}from"./form-CD6KdMGM.js";import{s as y,I as x,B as u}from"./index-BxebFInA.js";import{S as X,a as Z,b as ee,c as se,d as q}from"./select-BYxu3Vr0.js";import{u as ie}from"./use-toast-CeM3bjHh.js";import{s as T,x as F,m as B,C as te,w as re}from"./icons-CuqSVQ6h.js";import{o as v,s as a,e as ne,c as oe,a as N}from"./types-PBYTEVGX.js";import"./label-CDlTyg0m.js";import"./tanstack-bfvW12lo.js";import"./supabase-L9V-I8OX.js";const le=M,ae=V,ce=O,de=v({title:a().min(1),slug:a().min(1),status:ne(["draft","review","published"]),order_position:oe.number().int().default(0),tagline:a().optional(),hero_description:a().optional(),hero_cta_text:a().optional(),hero_image:a().optional(),problem_heading:a().optional(),problem_description:a().optional(),reasons:N(v({value:a().min(1)})),deliverables_intro:a().optional(),deliverables_heading:a().optional(),deliverables:N(v({title:a().min(1),description:a().min(1)})),testimonial_quote:a().optional(),testimonial_author:a().optional(),testimonial_image:a().optional(),social_proof_heading:a().optional(),social_proof_description:a().optional(),social_proof_points:N(v({value:a().min(1)})),steps_heading:a().optional(),steps:N(v({label:a().min(1),text:a().min(1)})),final_cta_heading:a().optional(),final_cta_description:a().optional(),final_cta_button_text:a().optional(),hub_description:a().optional(),hub_points:N(v({value:a()})),meta_title:a().optional(),meta_description:a().optional()});function xe(p){return p.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")}async function me(p){const m=p.name.split(".").pop(),g=`services/${Date.now()}-${Math.random().toString(36).slice(2)}.${m}`,{error:b}=await y.storage.from("media").upload(g,p);if(b)return null;const{data:D}=y.storage.from("media").getPublicUrl(g);return D.publicUrl}function _({title:p,children:m,defaultOpen:g=!1}){return e.jsxs(le,{defaultOpen:g,className:"rounded-lg border bg-card",children:[e.jsxs(ae,{className:"flex w-full items-center justify-between p-4 text-left font-semibold hover:bg-muted/50 transition-colors",children:[p,e.jsx(te,{className:"h-4 w-4 text-muted-foreground transition-transform [[data-state=open]>&]:rotate-180"})]}),e.jsx(ce,{className:"px-4 pb-4 space-y-4",children:m})]})}function Ne(){const{id:p}=G(),m=!!p,g=Q(),{toast:b}=ie(),[D,U]=S.useState({}),i=J({resolver:W(de),defaultValues:{title:"",slug:"",status:"draft",order_position:0,tagline:"",hero_description:"",hero_cta_text:"",hero_image:"",problem_heading:"",problem_description:"",reasons:[],deliverables_intro:"",deliverables_heading:"",deliverables:[],testimonial_quote:"",testimonial_author:"",testimonial_image:"",social_proof_heading:"",social_proof_description:"",social_proof_points:[],steps_heading:"",steps:[],final_cta_heading:"",final_cta_description:"",final_cta_button_text:"",hub_description:"",hub_points:[{value:""},{value:""},{value:""}],meta_title:"",meta_description:""}}),I=A({control:i.control,name:"reasons"}),$=A({control:i.control,name:"deliverables"}),P=A({control:i.control,name:"social_proof_points"}),k=A({control:i.control,name:"steps"});S.useEffect(()=>{m&&y.from("services").select("*").eq("id",p).single().then(({data:s})=>{if(!s)return;const l=Array.isArray(s.reasons)?s.reasons.map(w=>({value:w})):[],d=Array.isArray(s.deliverables)?s.deliverables:[],h=Array.isArray(s.social_proof_points)?s.social_proof_points.map(w=>({value:w})):[],C=Array.isArray(s.steps)?s.steps:[],f=Array.isArray(s.hub_points)?s.hub_points.map(w=>({value:w})):[{value:""},{value:""},{value:""}];for(;f.length<3;)f.push({value:""});i.reset({title:s.title??"",slug:s.slug??"",status:s.status??"draft",order_position:s.order_position??0,tagline:s.tagline??"",hero_description:s.hero_description??"",hero_cta_text:s.hero_cta_text??"",hero_image:s.hero_image??"",problem_heading:s.problem_heading??"",problem_description:s.problem_description??"",reasons:l,deliverables_intro:s.deliverables_intro??"",deliverables_heading:s.deliverables_heading??"",deliverables:d,testimonial_quote:s.testimonial_quote??"",testimonial_author:s.testimonial_author??"",testimonial_image:s.testimonial_image??"",social_proof_heading:s.social_proof_heading??"",social_proof_description:s.social_proof_description??"",social_proof_points:h,steps_heading:s.steps_heading??"",steps:C,final_cta_heading:s.final_cta_heading??"",final_cta_description:s.final_cta_description??"",final_cta_button_text:s.final_cta_button_text??"",hub_description:s.hub_description??"",hub_points:f,meta_title:s.meta_title??"",meta_description:s.meta_description??""})})},[p]);const H=i.watch("title");S.useEffect(()=>{!m&&H&&i.setValue("slug",xe(H))},[H,m]);const L=S.useCallback(async(s,l)=>{var C;const d=(C=s.target.files)==null?void 0:C[0];if(!d)return;U(f=>({...f,[l]:!0}));const h=await me(d);U(f=>({...f,[l]:!1})),h?(i.setValue(l,h),b({title:"Image uploaded"})):b({title:"Upload failed",variant:"destructive"})},[i,b]);async function R(s){const l={title:s.title,slug:s.slug,status:s.status,order_position:s.order_position,tagline:s.tagline||null,hero_description:s.hero_description||null,hero_cta_text:s.hero_cta_text||null,hero_image:s.hero_image||null,problem_heading:s.problem_heading||null,problem_description:s.problem_description||null,reasons:s.reasons.map(h=>h.value),deliverables_intro:s.deliverables_intro||null,deliverables_heading:s.deliverables_heading||null,deliverables:s.deliverables,testimonial_quote:s.testimonial_quote||null,testimonial_author:s.testimonial_author||null,testimonial_image:s.testimonial_image||null,social_proof_heading:s.social_proof_heading||null,social_proof_description:s.social_proof_description||null,social_proof_points:s.social_proof_points.map(h=>h.value),steps_heading:s.steps_heading||null,steps:s.steps,final_cta_heading:s.final_cta_heading||null,final_cta_description:s.final_cta_description||null,final_cta_button_text:s.final_cta_button_text||null,hub_description:s.hub_description||null,hub_points:s.hub_points.map(h=>
1h.value).filter(Boolean),meta_title:s.meta_title||null,meta_description:s.meta_description||null},{error:d}=m?await y.from("services").update(l).eq("id",p):await y.from("services").insert(l);d?b({title:"Error",description:d.message,variant:"destructive"}):(b({title:m?"Updated":"Created"}),g("/admin/services"))}function z({fieldName:s,label:l}){return e.jsx(t,{control:i.control,name:s,render:({field:d})=>e.jsxs(r,{children:[e.jsx(c,{children:l}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:e.jsx(x,{placeholder:"Image URL",...d})}),e.jsxs("label",{className:"inline-flex items-center gap-2 cursor-pointer rounded-md border border-border px-3 py-2 text-sm hover:bg-muted transition-colors",children:[D[s]?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(re,{className:"h-4 w-4"}),"Upload",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:h=>L(h,s)})]}),d.value&&e.jsx("img",{src:d.value,alt:"Preview",className:"h-20 w-auto rounded border border-border object-cover"})]}),e.jsx(o,{})]})})}return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(Y,{to:"/admin/services",className:"hover:text-foreground transition-colors",children:"Services"}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-foreground",children:m?"Edit":"New"})]}),e.jsxs("h1",{className:"text-3xl font-semibold mb-6",children:[m?"Edit":"New"," Service"]}),e.jsx(K,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(R),className:"space-y-4",children:[e.jsxs(_,{title:"Basic Info",defaultOpen:!0,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(t,{control:i.control,name:"title",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Title"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"slug",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Slug"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(t,{control:i.control,name:"status",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Status"}),e.jsxs(X,{onValueChange:s.onChange,value:s.value,children:[e.jsx(n,{children:e.jsx(Z,{children:e.jsx(ee,{})})}),e.jsxs(se,{children:[e.jsx(q,{value:"draft",children:"Draft"}),e.jsx(q,{value:"review",children:"Review"}),e.jsx(q,{value:"published",children:"Published"})]})]}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"order_position",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Order Position"}),e.jsx(n,{children:e.jsx(x,{type:"number",...s})}),e.jsx(o,{})]})})]})]}),e.jsxs(_,{title:"Hero Section",defaultOpen:!0,children:[e.jsx(t,{control:i.control,name:"tagline",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Tagline"}),e.jsx(E,{children:"Short one-liner shown in hero and on hub card"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"hero_description",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Hero Description"}),e.jsx(n,{children:e.jsx(j,{rows:3,...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"hero_cta_text",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"CTA Button Text"}),e.jsx(n,{children:e.jsx(x,{placeholder:"e.g. Get a Code Audit",...s})}),e.jsx(o,{})]})}),e.jsx(z,{fieldName:"hero_image",label:"Hero Image"})]}),e.jsxs(_,{title:"Problem Section",children:[e.jsx(t,{control:i.control,name:"problem_heading",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Heading"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"problem_description",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Description"}),e.jsx(n,{children:e.jsx(j,{rows:4,...s})}),e.jsx(o,{})]})})]}),e.jsxs(_,{title:"Reasons",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:'"You might be here because…" items'}),e.jsxs(u,{type:"button",variant:"outline",size:"sm",onClick:()=>I.append({value:""}),children:[e.jsx(T,{className:"mr-1 h-4 w-4"})," Add"]})]}),I.fields.map((s,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground w-6",children:[l+1,"."]}),e.jsx(t,{control:i.control,name:`reasons.${l}.value`,render:({field:d})=>e.jsxs(r,{className:"flex-1",children:[e.jsx(n,{children:e.jsx(x,{placeholder:"Reason",...d})}),e.jsx(o,{})]})}),e.jsx(u,{type:"button",variant:"ghost",size:"icon",onClick:()=>I.remove(l),children:e.jsx(F,{className:"h-4 w-4 text-destructive"})})]},s.id))]}),e.jsxs(_,{title:"Deliverables",children:[e.jsx(t,{control:i.control,name:"deliverables_intro",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Intro Text"}),e.jsx(n,{children:e.jsx(j,{rows:2,...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"deliverables_heading",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Heading"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deliverable items"}),e.jsxs(u,{type:"button",variant:"outline",size:"sm",onClick:()=>$.append({title:"",description:""}),children:[e.jsx(T,{className:"mr-1 h-4 w-4"})," Add"]})]}),$.fields.map((s,l)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Deliverable ",l+1]}),e.jsx(u,{type:"button",variant:"ghost",size:"icon",onClick:()=>$.remove(l),children:e.jsx(F,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(t,{control:i.control,name:`deliverables.${l}.title`,render:({field:d})=>e.jsxs(r,{children:[e.jsx(c,{children:"Title"}),e.jsx(n,{children:e.jsx(x,{...d})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:`deliverables.${l}.description`,render:({field:d})=>e.jsxs(r,{children:[e.jsx(c,{children:"Description"}),e.jsx(n,{children:e.jsx(j,{rows:2,...d})}),e.jsx(o,{})]})})]},s.id))]}),e.jsxs(_,{title:"Social Proof",children:[e.jsx(t,{control:i.control,name:"social_proof_heading",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Heading"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"social_proof_description",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Description"}),e.jsx(n,{children:e.jsx(j,{rows:3,...s})}),e.jsx(o,{})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bullet points"}),e.jsxs(u,{type:"button",variant:"outline",size:"sm",onClick:()=>P.append({value:""}),children:[e.jsx(T,{className:"mr-1 h-4 w-4"})," Add"]})]}),P.fields.map((s,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{control:i.control,name:`social_proof_points.${l}.value`,render:({field:d})=>e.jsxs(r,{className:"flex-1",children:[e.jsx(n,{children:e.jsx(x,{placeholder:"Bullet point",...d})}),e.jsx(o,{})]})}),e.jsx(u,{type:"button",variant:"ghost",size:"icon",onClick:()=>P.remove(l),children:e.jsx(F,{className:"h-4 w-4 text-destructive"})})]},s.id)),e.jsx(t,{control:i.control,name:"testimonial_quote",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Testimonial Quote"}),e.jsx(n,{children:e.jsx(j,{rows:3,...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"testimonial_author",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Testimonial Author"}),e.jsx(n,{children:e.jsx(x,{placeholder:"e.g. Megabus",...s})}),e.jsx(o,{})]})}),e.jsx(z,{fieldName:"testimonial_image",label:"Testimonial Image"})]}),e.jsxs(_,{title:"Process Steps",children:[e.jsx(t,{control:i.control,name:"steps_heading",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Section Heading"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Step items"}),e.jsxs(u,{type:"button",variant:"outline",size:"sm",onClick:()=>k.append({label:"",text:""}),children:[e.jsx(T,{className:"mr-1 h-4 w-4"})," Add"]})]}),k.fields.map((s,l)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Step ",l+1]}),e.jsx(u,{type:"button",variant:"ghost",size:"icon",onClick:()=>k.remove(l),children:e.jsx(F,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(t,{control:i.control,name:`steps.${l}.label`,render:({field:d})=>e.jsxs(r,{children:[e.jsx(c,{children:"Label"}),e.jsx(n,{children:e.jsx(x,{...d})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:`steps.${l}.text`,render:({field:d})=>e.jsxs(r,{children:[e.jsx(c,{children:"Description"}),e.jsx(n,{children:e.jsx(j,{rows:2,...d})}),e.jsx(o,{})]})})]},s.id))]}),e.jsxs(_,{title:"Final CTA",children:[e.jsx(t,{control:i.control,name:"final_cta_heading",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Heading"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"final_cta_description",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Description"}),e.jsx(n,{children:e.jsx(j,{rows:2,...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"final_cta_button_text",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Button Text"}),e.jsx(n,{children:e.jsx(x,{placeholder:"e.g. Request a Code Audit",...s})}),e.jsx(o,{})]})})]}),e.jsxs(_,{title:"Hub Card (Services Page)",children:[e.jsx(t,{control:i.control,name:"hub_description",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Hub Description"}),e.jsx(E,{children:"Longer description shown on the /services hub page"}),e.jsx(n,{children:e.jsx(j,{rows:3,...s})}),e.jsx(o,{})]})}),[0,1,2].map(s=>e.jsx(t,{control:i.control,name:`hub_points.${s}.value`,render:({field:l})=>e.jsxs(r,{children:[e.jsxs(c,{children:["Hub Point ",s+1]}),e.jsx(n,{children:e.jsx(x,{...l})}),e.jsx(o,{})]})},s))]}),e.jsxs(_,{title:"SEO",children:[e.jsx(t,{control:i.control,name:"meta_title",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Meta Title"}),e.jsx(n,{children:e.jsx(x,{...s})}),e.jsx(o,{})]})}),e.jsx(t,{control:i.control,name:"meta_description",render:({field:s})=>e.jsxs(r,{children:[e.jsx(c,{children:"Meta Description"}),e.jsx(n,{children:e.jsx(j,{rows:2,...s})}),e.jsx(o,{})]})})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsxs(u,{type:"submit",disabled:i.formState.isSubmitting,children:[i.formState.isSubmitting&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),m?"Save Changes":"Create"]}),e.jsx(u,{type:"button",variant:"outline",onClick:()=>g("/admin/services"),children:"Cancel"})]})]})})]})}export{Ne 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.