PageSourceSearch

https://knuckl.com/assets/PostProject-BA-RS1j_.js

js knuckl.com collected 2026-09-24 14:47:15 UTC 12,566 bytes, 1 lines download raw bytes

1import{a as r,j as e}from"./vendor-query-BxlSJxfF.js";import{a as fe,X as be,L as T,I as j,B,e as x,s as F}from"./index-DO0aGFYL.js";import{H as je}from"./Head-CFjoxvyt.js";import{K as we}from"./KnucklLogo-DmAzyuOm.js";import{L as Ne}from"./LocationAutocomplete-BSme0mji.js";import{L as c}from"./label-Lh_RHPfV.js";import{T as ve}from"./textarea-CY9O0h4D.js";import{C as ye}from"./checkbox-CpsEjWIE.js";import{H as X,T as ke,B as Ce}from"./homeowner-trades-DdI3fK_X.js";import{b as Se,c as _e,a as Le}from"./homeowner-i18n-BlSJu_P4.js";import{c as Pe}from"./gtm-BvBzX99D.js";import{u as Te,d as Be,L as Fe}from"./vendor-react-DdNhUK9-.js";import{A as J}from"./arrow-left-DNK6fh5x.js";import{C as Ae}from"./camera-vAyeR-gp.js";import{M as Ee}from"./map-pin-Clc12hBl.js";import{C as Me}from"./circle-check-BzeG-ygw.js";import"./vendor-supabase-Csx7YFID.js";import"./geocode-CX448-fu.js";import"./locate-fixed-DXW6AJ3Q.js";import"./clock-TDYRjmmL.js";import"./check-BTT3mgzE.js";import"./skill-catalog-CiwHrT6-.js";const A=6;function rt(){const Y=Te(),{tr:s}=fe(),[E]=Be(),w=r.useRef(null),[a,u]=r.useState(E.get("trade")?1:0),[d,q]=r.useState(X.find(t=>t.id===E.get("trade"))??null),[g,Q]=r.useState(""),[k,M]=r.useState([]),[V,$]=r.useState([]),[D,H]=r.useState(!1),[f,O]=r.useState(""),[i,R]=r.useState(null),[C,Z]=r.useState(""),[I,ee]=r.useState("this_month"),[S,te]=r.useState(""),[N,se]=r.useState(""),[b,oe]=r.useState(""),[h,re]=r.useState(""),[U,ae]=r.useState(!1),[z,ne]=r.useState(null),[le,me]=r.useState("email"),[_,de]=r.useState(""),[ie,ce]=r.useState(null),[L,he]=r.useState(0),[v,y]=r.useState(!1),{city:K,state:W}=r.useMemo(()=>{const[t,l]=f.split(",").map(o=>o.trim());return{city:t||null,state:l||null}},[f]),pe=async t=>{if(!(t!=null&&t.length))return;const l=A-k.length;if(l<=0){x.error(s("homeowner.post.photoLimit",{max:A}));return}H(!0);try{for(const o of Array.from(t).slice(0,l)){if(o.size>10*1024*1024){x.error(s("homeowner.post.fileTooLarge",{name:o.name}));continue}const n=new FormData;n.append("file",o);const{data:m,error:p}=await F.functions.invoke("homeowner-photo-upload",{body:n}),G=m==null?void 0:m.path;if(p||!G){x.error(s("homeowner.post.uploadFailed"));continue}M(P=>[...P,G]),$(P=>[...P,URL.createObjectURL(o)])}}finally{H(!1),w.current&&(w.current.value="")}},xe=async()=>{var t;if(d){if(!b.trim()&&!h.trim()){x.error(s("homeowner.post.needContact"));return}y(!0);try{const{data:l,error:o}=await F.functions.invoke("homeowner-lead-submit",{body:{trade:d.label,trade_skills:d.skills,description:g.trim(),photos:k,address_line:C.trim()||null,city:K,state:W,lat:(i==null?void 0:i.lat)??null,lng:(i==null?void 0:i.lng)??null,timeline:I,budget_band:S||null,contact_name:N.trim(),contact_email:b.trim()||null,contact_phone:h.trim()||null,sms_consent:U}}),n=l;if(o||!(n!=null&&n.lead_id)){x.error((n==null?void 0:n.error)==="rate_limited"?s("homeowner.post.rateLimited"):s("homeowner.post.submitFailed"));return}const m=((t=`${C} ${f}`.match(/\b\d{5}(?:-\d{4})?\b/))==null?void 0:t[0])??null,p=N.trim().split(/\s+/).filter(Boolean);Pe({job_id:n.lead_id,trade:d.id,postal_code:m,email:b.trim()||null,phone:h.trim()||null,first_name:p[0]??null,last_name:p.length>1?p[p.length-1]:null,city:K,region:W}),ne(n.lead_id),me(n.channel??"email"),u(4)}finally{y(!1)}}},ue=async()=>{if(z){y(!0);try{const{data:t,error:l}=await F.functions.invoke("homeowner-lead-verify",{body:{lead_id:z,code:_.trim()}}),o=t;if(l||!(o!=null&&o.access_token)){x.error((o==null?void 0:o.error)==="invalid_code"?s("homeowner.post.codeWrong"):(o==null?void 0:o.error)==="code_expired"?s("homeowner.post.codeExpired"):s("homeowner.post.verifyFailed"));return}ce(o.access_token),he(o.notified_pro_count??0),u(5)}finally{y(!1)}}},ge=a===0&&!!d||a===1&&g.trim().length>=20||a===2&&!!i||a===3&&N.trim().length>=2&&(!!b.trim()||!!h.trim());return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(je,{title:"Post your home project | Knuckl",description:"Describe your project, add photos and reach local contractors. No account needed.",noindex:!0}),e.jsxs("header",{className:"px-5 py-4 flex items-center gap-3 border-b border-border/60",children:[a>0&&a<4?e.jsx("button",{onClick:()=>u(t=>
1t-1),className:"p-2 -ml-2 rounded-lg hover:bg-muted","aria-label":s("homeowner.post.back"),children:e.jsx(J,{className:"w-5 h-5"})}):e.jsx(Fe,{to:"/homeowners",className:"p-2 -ml-2 rounded-lg hover:bg-muted","aria-label":s("homeowner.post.back"),children:e.jsx(J,{className:"w-5 h-5"})}),e.jsx(we,{className:"h-6"})]}),e.jsx("div",{className:"h-1 bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${(a+1)/6*100}%`}})}),e.jsxs("main",{className:"px-5 py-8 max-w-xl mx-auto pb-32",children:[a===0&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("homeowner.post.step0Title")}),e.jsx("p",{className:"text-muted-foreground mt-1.5 text-sm",children:s("homeowner.post.step0Body")}),e.jsx("div",{className:"mt-6 grid gap-2.5",children:X.map(t=>e.jsxs("button",{onClick:()=>{q(t),u(1)},className:`text-left p-4 rounded-xl border transition-colors ${(d==null?void 0:d.id)===t.id?"border-primary bg-primary/10":"border-border/60 bg-card/60 hover:border-primary/50"}`,children:[e.jsx("div",{className:"font-medium",children:Se(s,t.id,t.label)}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:_e(s,t.id,t.blurb)})]},t.id))})]}),a===1&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("homeowner.post.step1Title")}),e.jsx("p",{className:"text-muted-foreground mt-1.5 text-sm",children:s("homeowner.post.step1Body")}),e.jsx(ve,{value:g,onChange:t=>Q(t.target.value),rows:7,maxLength:4e3,placeholder:s("homeowner.post.descriptionPlaceholder"),className:"mt-5 rounded-xl"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:g.trim().length<20?s("homeowner.post.needMoreWords"):s("homeowner.post.characters",{count:g.trim().length})}),e.jsxs("div",{className:"mt-6",children:[e.jsx(c,{className:"text-sm",children:s("homeowner.post.photosOptional")}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[V.map((t,l)=>e.jsxs("div",{className:"relative w-20 h-20 rounded-lg overflow-hidden border border-border/60",children:[e.jsx("img",{src:t,alt:s("homeowner.post.projectPhoto",{n:l+1}),className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>{$(o=>o.filter((n,m)=>m!==l)),M(o=>o.filter((n,m)=>m!==l))},className:"absolute top-0.5 right-0.5 p-1 rounded-full bg-background/80","aria-label":s("homeowner.post.removePhoto"),children:e.jsx(be,{className:"w-3 h-3"})})]},t)),k.length<A&&e.jsx("button",{onClick:()=>{var t;return(t=w.current)==null?void 0:t.click()},disabled:D,className:"w-20 h-20 rounded-lg border border-dashed border-border grid place-items-center text-muted-foreground hover:border-primary/60","aria-label":s("homeowner.post.addPhoto"),children:D?e.jsx(T,{className:"w-5 h-5 animate-spin"}):e.jsx(Ae,{className:"w-5 h-5"})})]}),e.jsx("input",{ref:w,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:t=>pe(t.target.files)})]})]}),a===2&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("homeowner.post.step2Title")}),e.jsx("p",{className:"text-muted-foreground mt-1.5 text-sm",children:s("homeowner.post.step2Body")}),e.jsxs("div",{className:"relative mt-5",children:[e.jsx(Ee,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none text-muted-foreground z-10"}),e.jsx(Ne,{value:f,onChange:t=>{O(t),R(null)},onSelect:t=>{O(t.display),R({lat:t.lat,lng:t.lng})},placeholder:s("homeowner.post.locationPlaceholder"),showGpsButton:!0,inputClassName:"h-12 pl-10 pr-20 rounded-xl"})]}),f.trim().length>=2&&!i&&e.jsx("p",{className:"text-xs text-amber-500/90 mt-2",children:s("homeowner.post.pickSuggestion")}),e.jsxs("div",{className:"mt-6",children:[e.jsx(c,{htmlFor:"addr",className:"text-sm",children:s("homeowner.post.streetAddress")}),e.jsx(j,{id:"addr",value:C,onChange:t=>Z(t.target.value),placeholder:s("homeowner.post.streetAddressPlaceholder"),className:"mt-2 h-12 rounded-xl"})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx(c,{className:"text-sm",children:s("homeowner.post.whenLabel")}),e.jsx("div",{className:"mt-2 grid gap-2",children:ke.map(t=>e.jsx("button",{onClick:()=>ee(t.id),className:`p-3 rounded-xl border text-left text-sm ${I===t.id?"border-primary bg-primary/10":"border-border/60 bg-card/60"}`,children:Le(s,t.id)},t.id))})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx(c,{className:"text-sm",children:s("homeowner.post.budgetLabel")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Ce.map(t=>e.jsx("button",{onClick:()=>te(S===t?"":t),className:`px-3 py-2 rounded-full border text-sm ${S===t?"border-primary bg-primary/10 text-primary":"border-border/60"}`,children:t},t))})]})]}),a===3&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("homeowner.post.step3Title")}),e.jsx("p",{className:"text-muted-foreground mt-1.5 text-sm",children:s("homeowner.post.step3Body")}),e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"name",className:"text-sm",children:s("homeowner.post.y
1ourName")}),e.jsx(j,{id:"name",value:N,onChange:t=>se(t.target.value),className:"mt-2 h-12 rounded-xl",placeholder:s("homeowner.post.yourNamePlaceholder")})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"email",className:"text-sm",children:s("homeowner.post.email")}),e.jsx(j,{id:"email",type:"email",value:b,onChange:t=>oe(t.target.value),className:"mt-2 h-12 rounded-xl",placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"phone",className:"text-sm",children:s("homeowner.post.mobile")}),e.jsx(j,{id:"phone",type:"tel",value:h,onChange:t=>re(t.target.value),className:"mt-2 h-12 rounded-xl",placeholder:"(555) 123-4567"})]}),h.trim().length>0&&e.jsxs("label",{className:"flex items-start gap-3 text-xs text-muted-foreground leading-relaxed",children:[e.jsx(ye,{checked:U,onCheckedChange:t=>ae(t===!0),className:"mt-0.5"}),e.jsx("span",{children:s("homeowner.post.smsConsent")})]})]})]}),a===4&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s("homeowner.post.step4Title")}),e.jsx("p",{className:"text-muted-foreground mt-1.5 text-sm",children:s(le==="sms"?"homeowner.post.step4BodySms":"homeowner.post.step4BodyEmail")}),e.jsx(j,{value:_,onChange:t=>de(t.target.value.replace(/\D/g,"").slice(0,6)),inputMode:"numeric",placeholder:"123456",className:"mt-6 h-14 rounded-xl text-center text-2xl tracking-[0.5em]"}),e.jsx(B,{onClick:ue,disabled:v||_.length!==6,className:"w-full h-12 rounded-xl mt-5",children:v?e.jsx(T,{className:"w-4 h-4 animate-spin"}):s("homeowner.post.confirmAndSend")})]}),a===5&&e.jsxs("div",{className:"text-center",children:[e.jsx(Me,{className:"w-14 h-14 mx-auto text-primary"}),e.jsx("h1",{className:"text-2xl font-bold mt-4",children:s("homeowner.post.doneTitle")}),e.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:L===1?s("homeowner.post.doneSentToOne"):L>1?s("homeowner.post.doneSentTo",{count:L}):s("homeowner.post.doneNoneYet")}),e.jsxs("div",{className:"mt-8 text-left",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:s("homeowner.post.nextHeading")}),e.jsx("ol",{className:"mt-3 space-y-3",children:[1,2,3].map(t=>e.jsxs("li",{className:"flex gap-3 p-4 rounded-xl border border-border/60 bg-card/60",children:[e.jsx("span",{className:"w-6 h-6 shrink-0 rounded-full bg-primary/15 text-primary grid place-items-center text-xs font-semibold",children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:s(`homeowner.post.next${t}Title`)}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:s(`homeowner.post.next${t}Body`)})]})]},t))})]}),e.jsx(B,{onClick:()=>Y(`/homeowners/p/${ie}`,{replace:!0}),className:"w-full h-12 rounded-xl mt-6",children:s("homeowner.post.openProject")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:s("homeowner.post.savedLinkNote")})]})]}),a<4&&e.jsx("div",{className:"fixed bottom-0 inset-x-0 p-5 bg-background/95 backdrop-blur border-t border-border/60",children:e.jsx(B,{onClick:()=>a===3?xe():u(t=>t+1),disabled:!ge||v,className:"w-full h-12 rounded-xl max-w-xl mx-auto flex",children:v?e.jsx(T,{className:"w-4 h-4 animate-spin"}):s(a===3?"homeowner.post.postMyProject":"homeowner.post.continue")})})]})}export{rt 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.