PageSourceSearch

https://stone-profit-flow.base44.app/assets/CreateJob-DErUbPdG.js

js stone-profit-flow.base44.app collected 2026-10-03 03:10:52 UTC 28,013 bytes, 5 lines download raw bytes

1import{a as x,j as e,d as H,u as Y,e as X}from"./vendor-query-B-_nDQQY.js";import{I as v,L,m as ee,C as E,a as J,c as R,p as B,d as M,B as P,X as U,b as S,q as f,h as A,i as D,j as $,k as T,l as j,s as Z,e as F,aI as se,x as te,o as K,r as G,t as z}from"./index-D8ww6b7J.js";import{p as ae}from"./quoteNotes-BK67QilA.js";import{C as re}from"./checkbox-DYv8y0li.js";import"./textarea-Bhj0eADY.js";import{T as ne,a as le,b as Q}from"./tabs-DfRYzyJY.js";import{R as ce}from"./ruler-Bcj6zKuq.js";import{A as ie,m as I}from"./vendor-framer-DvY-ewtn.js";import{U as oe}from"./upload-DN-6vN7H.js";import{C as W}from"./circle-check-big-4Ew-rpqG.js";import{B as V}from"./brain-FGNdWGCL.js";import{T as de}from"./trending-down-BIipizug.js";import{P as me}from"./PageHeader-DOQecRZi.js";import{b as ue}from"./vendor-react-BUIlT3ms.js";import{P as pe}from"./plus-MQo5wr8n.js";import{U as xe}from"./user-CHo1Apvy.js";import{A as he}from"./arrow-right-BeikyhzV.js";import"./vendor-three-1K-S22da.js";import"./vendor-charts-i-522T5A.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";const je=/\b(\d{5})(?:-\d{4})?\b/,ge=/\b([A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d)\b/;function fe(c){return c&&c.replace(/(Dr|St|Rd|Ave|Blvd|Ln|Ct|Way|Pl|Pkwy|Hwy|Cir|Ter|Sq)([A-Z])/g,"$1 $2")}async function be(c){var r;if(!c)return null;try{const u=fe(c),o=await(await fetch(`https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=${encodeURIComponent(u)}&f=json&maxLocations=1`)).json();if(((r=o==null?void 0:o.candidates)==null?void 0:r.length)>0){const h=o.candidates[0],a=h.location;return{lat:a.y,lng:a.x,postcode:null,formatted:h.address||null}}}catch{}return null}function ye(c){if(!c)return null;const r=c.match(je);if(r)return r[1];const u=c.match(ge);return u?u[1].replace(/\s+/g," ").toUpperCase():null}async function Ne(c){const r={address:c||"",zip:null,coords:null};if(!c)return r;const u=ye(c);if(u)return r.zip=u,r;const n=await be(c);return n!=null&&n.postcode&&(r.address=`${c.trim().replace(/,\s*$/,"")}, ${n.postcode}`,r.zip=n.postcode),n!=null&&n.lat&&(r.coords={lat:n.lat,lng:n.lng}),r}async function ve(c){try{const u=await(await fetch(`https://nominatim.openstreetmap.org/search?format=json&addressdetails=1&q=${encodeURIComponent(c)}&limit=6`,{headers:{"Accept-Language":"en","User-Agent":"CountertopTracker/1.0"}})).json();return Array.isArray(u)?u:[]}catch{return[]}}function _e({value:c,onChange:r,onSelect:u,placeholder:n,className:o}){const[h,a]=x.useState(c||""),[t,m]=x.useState([]),[w,y]=x.useState(!1),[_,g]=x.useState(!1),[C,k]=x.useState(-1),s=x.useRef(null),i=x.useRef(null);x.useEffect(()=>{a(c||"")},[c]),x.useEffect(()=>{const d=p=>{i.current&&!i.current.contains(p.target)&&g(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]);const N=d=>{const p=d.target.value;if(a(p),r==null||r(p),g(!0),k(-1),s.current&&clearTimeout(s.current),p.trim().length<4){m([]),y(!1);return}s.current=setTimeout(async()=>{y(!0);const q=await ve(p);m(q),y(!1)},450)},l=d=>{var q;const p=d.display_name;a(p),r==null||r(p),u==null||u({address:p,postcode:((q=d.address)==null?void 0:q.postcode)||null,lat:parseFloat(d.lat),lng:parseFloat(d.lon)}),m([]),g(!1)},b=d=>{!_||!t.length||(d.key==="ArrowDown"?(d.preventDefault(),k(p=>Math.min(p+1,t.length-1))):d.key==="ArrowUp"?(d.preventDefault(),k(p=>Math.max(p-1,0))):d.key==="Enter"&&C>=0?(d.preventDefault(),l(t[C])):d.key==="Escape"&&g(!1))};return e.jsxs("div",{ref:i,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(v,{value:h,onChange:N,onKeyDown:b,onFocus:()=>{t.length&&g(!0)},placeholder:n,className:o,autoComplete:"off"}),w&&e.jsx(L,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 animate-spin text-muted-foreground"})]}),_&&t.length>0&&e.jsx("div",{className:"absolute z-50 mt-1 w-full rounded-md border border-border bg-popover shadow-lg max-h-64 overflow-auto",children:t.map((d,p)=>e.jsxs("button",{type:"button",onMouseDown:q=>{q.preventDefault(),l(d)},className:`w-full text-left px-3 py-2 text-sm flex items-start gap-2 hover:bg-accent ${p===C?"bg-accent":""}`,children:[e.jsx(ee,{className:"w-3.5 h-3.5 mt-0.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"line-clamp-2",children:d.display_name})]},d.place_id||p))})]})}function we({onResult:c}){var N;const[r,u]=x.useState(!1),[n,o]=x.useState(null),[h,a]=x.useState(!1),[t,m]=x.useState(null),[w,y]=x.useState(null),_=x.useRef(null),g=x.useCallback(l=>{l.preventDefault(),l.stopPropagation(),l.type==="dragenter"||l.type==="dragover"?u(!0):l.type==="dragleave"&&u(!1)},[]),C=async l=>{o(l),y(null),m(null),a(!0);try{const{file_url:b}=await S.integrations.Core.UploadFile({file:l}),d=await S.functions.invoke("parseJobPdf",{pdf_url:b});m(d.data),c&&c(d.data)}catch{y("Failed to process drawing. Please try again.")}finally{a(!1)}},k=x.useCallback(l=>{var d;l.preventDefault(),l.stopPropagation(),u(!1);const b=(d=l.dataTransfer.files)==null?void 0:d[0];b&&C(b)},[c]),s=l=>{var d;const b=(d=l.target.files)==null?void 0:d[0];b&&C(b)},i=()=>{o(null),m(null),y(null)};return e.jsxs(E,{children:[e.jsxs(J,{children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ce,{className:"w-5 h-5 text-primary"}),"Auto-Calculate Sq Ft from Drawing"]}),e.jsx(B,{children:"Drag & drop a PDF or image of your countertop drawing to extract square footage"})]}),e.jsx(M,{children:e.jsxs("div",{className:`
2            relative border-2 border-dashed rounded-xl p-8 text-center transition-all cursor-pointer
3            ${r?"border-primary bg-primary/5 scale-[1.02]":"border-muted-foreground
3/25 hover:border-muted-foreground/50"}
4            ${h?"pointer-events-none":""}
5          `,onDragEnter:g,onDragLeave:g,onDragOver:g,onDrop:k,onClick:()=>{var l;return(l=_.current)==null?void 0:l.click()},children:[e.jsx("input",{ref:_,type:"file",accept:".pdf,.png,.jpg,.jpeg",onChange:s,className:"hidden"}),e.jsxs(ie,{mode:"wait",children:[!n&&!h&&e.jsxs(I.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"space-y-3",children:[e.jsx(oe,{className:"w-10 h-10 mx-auto text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drop your PDF or image here, or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supports PDF, PNG, JPG"})]},"dropzone"),h&&e.jsxs(I.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"space-y-3",children:[e.jsx(L,{className:"w-10 h-10 mx-auto text-primary animate-spin"}),e.jsx("p",{className:"text-sm font-medium",children:"Analyzing drawing..."}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-xs mx-auto",children:n.name})]},"processing"),t&&!h&&e.jsxs(I.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(W,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{className:"text-sm font-medium text-green-600",children:"Drawing analyzed"})]}),e.jsxs("div",{className:"inline-flex items-baseline gap-1 bg-primary/10 rounded-xl px-6 py-4",children:[e.jsx("span",{className:"text-3xl font-bold text-primary",children:t.square_feet||"—"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"sq ft"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.material_type&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Material"}),e.jsx("p",{className:"font-medium capitalize",children:t.material_type})]}),t.edge_profile&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Edge Profile"}),e.jsx("p",{className:"font-medium capitalize",children:t.edge_profile})]}),t.document_type==="drawing"&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Cutouts"}),e.jsx("p",{className:"font-medium",children:((N=t.cutouts)==null?void 0:N.length)>0?t.cutouts.join(", "):"None detected"})]})]}),e.jsxs(P,{variant:"outline",size:"sm",onClick:i,className:"gap-1",children:[e.jsx(U,{className:"w-3.5 h-3.5"}),"Clear & Upload Another"]})]},"result"),w&&e.jsxs(I.div,{initial:{opacity:0}
5,animate:{opacity:1},className:"space-y-3 text-destructive",children:[e.jsx(U,{className:"w-10 h-10 mx-auto"}),e.jsx("p",{className:"text-sm",children:w}),e.jsx(P,{variant:"outline",size:"sm",onClick:i,children:"Try Again"})]},"error")]})]})})]})}function Ce({materialType:c,sqft:r,projectType:u,sellingPrice:n}){const[o,h]=x.useState({material_type:c||"",sqft:r||"",project_type:u||"kitchen"}),{data:a,isLoading:t,error:m,refetch:w,isFetching:y}=H({queryKey:["jobCostPrediction",o],queryFn:async()=>!o.sqft||o.sqft<=0?null:(await S.functions.invoke("predictJobCost",{material_type:o.material_type||void 0,sqft:parseFloat(o.sqft),project_type:o.project_type})).data,enabled:!1}),_={high:"bg-green-100 text-green-700",medium:"bg-yellow-100 text-yellow-700",low:"bg-orange-100 text-orange-700"};return e.jsxs(E,{children:[e.jsxs(J,{children:[e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(V,{className:"w-5 h-5 text-primary"}),"AI Cost Prediction"]}),e.jsx(B,{children:"P25 / P50 / P75 cost bands based on your historical completed jobs"})]}),e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(f,{className:"text-xs",children:"Material"}),e.jsxs(A,{value:o.material_type,onValueChange:g=>h({...o,material_type:g}),children:[e.jsx(D,{className:"h-9",children:e.jsx($,{placeholder:"Any"})}),e.jsxs(T,{children:[e.jsx(j,{value:null,children:"Any Material"}),e.jsx(j,{value:"granite",children:"Granite"}),e.jsx(j,{value:"quartz",children:"Quartz"}),e.jsx(j,{value:"marble",children:"Marble"}),e.jsx(j,{value:"quartzite",children:"Quartzite"}),e.jsx(j,{value:"soapstone",children:"Soapstone"})]})]})]}),e.jsxs("div",{children:[e.jsx(f,{className:"text-xs",children:"Project"}),e.jsxs(A,{value:o.project_type,onValueChange:g=>h({...o,project_type:g}),children:[e.jsx(D,{className:"h-9",children:e.jsx($,{})}),e.jsxs(T,{children:[e.jsx(j,{value:"kitchen",children:"Kitchen"}),e.jsx(j,{value:"bathroom",children:"Bathroom"}),e.jsx(j,{value:"commercial",children:"Commercial"}),e.jsx(j,{value:"outdoor",children:"Outdoor"})]})]})]}),e.jsxs("div",{children:[e.jsx(f,{className:"text-xs",children:"Sq Ft"}),e.jsx(v,{type:"number",value:o.sqft,onChange:g=>h({...o,sqft:g.target.value}),placeholder:"e.g. 45",className:"h-9"})]})]}),e.jsxs(P,{onClick:()=>w(),disabled:!o.sqft||y,className:"w-full gap-2",children:[y?e.jsx(L,{className:"w-4 h-4 animate-spin"}):e.jsx(V,{className:"w-4 h-4"}),"Predict Cost Bands"]}),t&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(L,{className:"w-6 h-6 animate-spin text-primary"})}),m&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-destructive/10 text-destructive text-sm",children:[e.jsx(Z,{className:"w-4 h-4"}),"Failed to generate prediction. Try again."]}),(a==null?void 0:a.status)==="insufficient_data"&&e.jsxs("div",{className:"text-center py-6 px-4 rounded-lg bg-muted",children:[e.jsx(Z,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.message}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Completed jobs found: ",a.sample_size]})]}),(a==null?void 0:a.status)==="success"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Based on ",e.jsx("span",{className:"font-bold text-foreground",children:a.sample_size})," completed jobs",a.material_type!=="all"&&` · ${a.material_type}`]}),e.jsx(F,{className:_[a.confidence],children:a.confidence_label})]}),e.jsx(Se,{p25:a.p25,p50:a.p50,p75:a.p75}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(O,{label:"P25 (Low)",value:a.p25,perSqft:a.p25_per_sqft,icon:e.jsx(de,{className:"w-4 h-4"}),color:"text-green-600",bg:"bg-green-50 dark:bg-green-950/20"}),e.jsx(O,{label:"P50 (Median)",value:a.p50,perSqft:a.p50_per_sqft,icon:e.jsx(se,{className:"w-4 h-4"}),color:"text-primary",bg:"bg-primary/5",highlight:!0}),e.jsx(O,{label:"P75 (High)",value:a.p75,perSqft:a.p75_per_sqft,icon:e.jsx(te,{className:"w-4 h-4"}),color:"text-orange-600",bg:"bg-orange-50 dark:bg-orange-950/20"})]}),n>0&&e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Your quoted price vs. prediction"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-lg font-bold",children:["$",n.toLocaleStr
5ing()]}),n<a.p25&&e.jsx(F,{className:"bg-green-100 text-green-700",children:"Below P25 — great deal"}),n>=a.p25&&n<a.p75&&e.jsx(F,{className:"bg-blue-100 text-blue-700",children:"Within expected range"}),n>=a.p75&&e.jsx(F,{className:"bg-orange-100 text-orange-700",children:"Above P75 — premium pricing"})]})]}),a.labor_bands&&e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Labor cost bands (from historical data)"}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-green-600",children:["P25: $",a.labor_bands.p25.toLocaleString()]}),e.jsxs("span",{className:"text-primary font-medium",children:["P50: $",a.labor_bands.p50.toLocaleString()]}),e.jsxs("span",{className:"text-orange-600",children:["P75: $",a.labor_bands.p75.toLocaleString()]})]})]})]})]})]})}function Se({p25:c,p50:r,p75:u}){const n=c*.85,o=u*1.15,h=o-n,a=(c-n)/h*100,t=(r-n)/h*100,m=(u-n)/h*100;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative h-8 rounded-full bg-muted overflow-hidden",children:[e.jsx("div",{className:"absolute h-full bg-primary/20",style:{left:`${a}%`,width:`${m-a}%`}}),e.jsx("div",{className:"absolute h-full w-1 bg-primary",style:{left:`${t}%`}}),e.jsx("div",{className:"absolute h-full w-0.5 bg-green-500",style:{left:`${a}%`}}),e.jsx("div",{className:"absolute h-full w-0.5 bg-orange-500",style:{left:`${m}%`}})]}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["$",Math.round(n).toLocaleString()]}),e.jsxs("span",{children:["$",Math.round(o).toLocaleString()]})]})]})}function O({label:c,value:r,perSqft:u,icon:n,color:o,bg:h,highlight:a}){return e.jsxs("div",{className:`p-3 rounded-lg text-center ${h} ${a?"ring-2 ring-primary/30":""}`,children:[e.jsxs("div",{className:`flex items-center justify-center gap-1 text-xs ${o} mb-1`,children:[n,c]}),e.jsxs("p",{className:`text-lg font-bold ${o}`,children:["$",r.toLocaleString()]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["$",u,"/sqft"]})]})}function Ge(){const c=ue(),[r,u]=x.useState("retail"),[n,o]=x.useState(1),[h,a]=x.useState(!1),[t,m]=x.useState({account_id:"",customer_name:"",customer_email:"",customer_phone:"",job_address:"",project_type:"kitchen",material_type:"",material_name:"",square_feet:"",selling_price:"",company_name:"",contact_name:"",password:"",template_date:""}),{data:w=[]}=H({queryKey:["accounts"],queryFn:()=>S.entities.Account.list()});x.useEffect(()=>{const s=new URLSearchParams(window.location.search),i={};["account_id","account_name","customer_name","customer_email","customer_phone","job_address","city","state","zip_code","salesperson_name"].forEach(l=>{const b=s.get(l);b&&(i[l]=b)}),Object.keys(i).length>0&&m(l=>({...l,...i,job_address:i.job_address||[i.city,i.state,i.zip_code].filter(Boolean).join(", ")||l.job_address}))},[]);const y=Y(),_=X({mutationFn:async s=>{let i=s.job_address,N=null;if(i){const p=await Ne(i);i=p.address,N=p.zip}const l=await S.entities.Quote.create({quote_number:`Q-${new Date().getFullYear()}-${String(Date.now()).slice(-4)}`,customer_name:s.customer_name,account_id:s.account_id,customer_email:s.customer_email,customer_phone:s.customer_phone,project_type:s.project_type,material_type:s.material_type||"unknown",sqft:parseFloat(s.square_feet)||0,selling_price:parseFloat(s.selling_price)||0,status:"accepted",created_date:new Date().toISOString().split("T")[0],notes:JSON.stringify({job_address:i,zip_code:N||void 0,job_type:s.job_type,company_name:s.company_name,account_id:s.account_id,template_only:!s.selling_price})});let b=null;if(s.job_type==="contractor"&&s.company_name)try{b=(await S.entities.Contractor.create({company_name:s.company_name,contact_name:s.contact_name||s.customer_name,email:s.customer_email,phone:s.customer_phone,status:"active",approved_date:new Date().toISOString()})).id,await S.entities.Quote.update(l.id,{notes:JSON.stringify({...ae(l.notes),contractor_id:b})})}catch(p){console.error("Contractor creation failed:",p),z.error("Job created but contractor account failed. Please create manually.")}return{...(await S.functions.invoke("convertQuoteToJobWithAccount",{quoteId:l.id,templateDate:s.template_date?new Date(s.template_date).toISOString():null})).data,contractorId:b,quoteId:l.id}},onSuccess:async s=>{await y.invalidateQueries({queryKey:["jobs"]}),await y.invalidateQueries({queryKey:["job"]}),await y.invalidateQueries({queryKey:["accounts"]}),z.success("Job created! You can schedule it from the job details page."),s.contractorId&&z.success(`Contractor account created for ${t.company_name}`),setTimeout(()=>{c(h?`/track/${s.jobId}`:`/job/${s.jobId}`)},500)},onError:s=>{console.error("Error creating job:",s),z.error("Failed to create job. Please try again.")}}),g=()=>{_.mutate({...t,job_type:r})},C=()=>t.customer_name&&t.customer_email&&t.customer_phone,k=()=>!(r==="contractor"&&!t.company_name||r==="retail"&&!t.selling_price);return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background to-card p-3 sm:p-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsx(me,{icon:pe,title:"Create New Job",subt
5itle:"Quick and simple job creation for any customer type",className:"mb-6 sm:mb-8"}),e.jsx(ne,{value:r,onValueChange:u,className:"mb-8",children:e.jsxs(le,{className:"grid w-full grid-cols-3",children:[e.jsxs(Q,{value:"retail",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2 text-[10px] sm:text-sm",children:[e.jsx(xe,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Retail Customer"}),e.jsx("span",{className:"sm:hidden",children:"Retail"})]}),e.jsxs(Q,{value:"contractor",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2 text-[10px] sm:text-sm",children:[e.jsx(K,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contractor/Dealer"}),e.jsx("span",{className:"sm:hidden",children:"Contractor"})]}),e.jsxs(Q,{value:"template",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2 text-[10px] sm:text-sm",children:[e.jsx(G,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Template Only"}),e.jsx("span",{className:"sm:hidden",children:"Template"})]})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-4 mb-6 sm:mb-8 flex-wrap",children:[e.jsxs("div",{className:`flex items-center gap-1 sm:gap-2 ${n>=1?"text-primary":"text-muted-foreground"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${n>=1?"bg-primary text-primary-foreground":"bg-muted"}`,children:"1"}),e.jsx("span",{className:"text-sm font-medium",children:"Customer Info"})]}),e.jsx("div",{className:`w-6 sm:w-12 h-1 ${n>=2?"bg-primary":"bg-muted"}`}),e.jsxs("div",{className:`flex items-center gap-1 sm:gap-2 ${n>=2?"text-primary":"text-muted-foreground"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${n>=2?"bg-primary text-primary-foreground":"bg-muted"}`,children:"2"}),e.jsx("span",{className:"text-sm font-medium",children:"Job Details"})]})]}),n===1&&e.jsxs(E,{children:[e.jsxs(J,{children:[e.jsx(R,{children:"Customer Information"}),e.jsxs(B,{children:[r==="retail"&&"Homeowner or residential customer details",r==="contractor"&&"Contractor company and contact information",r==="template"&&"Customer details for template scheduling"]})]}),e.jsxs(M,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Account"}),e.jsxs(A,{value:t.account_id,onValueChange:s=>{const i=w.find(N=>N.id===s);if(i){const N=[i.address,i.city,i.state,i.zip_code].filter(Boolean).join(", ");m(l=>({...l,account_id:s,customer_name:i.account_name||l.customer_name,customer_email:i.email||l.customer_email,customer_phone:i.phone||l.customer_phone,job_address:N||l.job_address}))}else m({...t,account_id:s})},children:[e.jsx(D,{children:e.jsx($,{placeholder:"Select an account (auto-fills info)"})}),e.jsx(T,{children:w.map(s=>e.jsxs(j,{value:s.id,children:[s.account_name,s.address?` — ${s.city||""}`:""]},s.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Customer Name *"}),e.jsx(v,{value:t.customer_name,onChange:s=>m({...t,customer_name:s.target.value}),placeholder:"John Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Email *"}),e.jsx(v,{type:"email",value:t.customer_email,onChange:s=>m({...t,customer_email:s.target.value}),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Phone *"}),e.jsx(v,{value:t.customer_phone,onChange:s=>m({...t,customer_phone:s.target.value}),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Project Type *"}),e.jsxs(A,{value:t.project_type,onValueChange:s=>m({...t,project_type:s}),children:[e.jsx(D,{children:e.jsx($,{})}),e.jsxs(T,{children:[e.jsx(j,{value:"kitchen",children:"Kitchen"}),e.jsx(j,{value:"bathroom",children:"Bathroom"}),e.jsx(j,{value:"commercial",children:"Commercial"}),e.jsx(j,{value:"outdoor",children:"Outdoor"}),e.jsx(j,{value:"other",children:"Other"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Job Address"}),e.jsx(_e,{value:t.job_address,onChange:s=>m({...t,job_address:s}),placeholder:"123 Main St, City, State 12345"})]}
5),r==="contractor"&&e.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg space-y-4",children:[e.jsxs("h3",{className:"font-semibold text-blue-800 dark:text-blue-400 flex items-center gap-2",children:[e.jsx(K,{className:"w-4 h-4"}),"Contractor Company Information"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Company Name *"}),e.jsx(v,{value:t.company_name,onChange:s=>m({...t,company_name:s.target.value}),placeholder:"ABC Construction"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Contact Name"}),e.jsx(v,{value:t.contact_name,onChange:s=>m({...t,contact_name:s.target.value}),placeholder:"John Smith"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Temporary Password *"}),e.jsx(v,{type:"password",value:t.password,onChange:s=>m({...t,password:s.target.value}),placeholder:"Set initial password"}),e.jsx("p",{className:"text-xs text-blue-700 dark:text-blue-500",children:"Contractor can change password after first login"})]}),e.jsx("div",{className:"p-3 bg-card rounded-lg",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-400",children:"✅ This will create a contractor account so they can submit future jobs online"})})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsxs(P,{onClick:()=>o(2),disabled:!C(),className:"gap-2",children:["Next: Job Details",e.jsx(he,{className:"w-4 h-4"})]})})]})]}),n===2&&e.jsxs(E,{children:[e.jsxs(J,{children:[e.jsx(R,{children:"Job Details"}),e.jsxs(B,{children:[r==="retail"&&"Pricing and material information",r==="contractor"&&"Job specifications (can be updated after template)",r==="template"&&"Create the job — schedule template from job details"]})]}),e.jsxs(M,{className:"space-y-4",children:[r==="template"?e.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(G,{className:"w-5 h-5 text-green-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-green-800 dark:text-green-400",children:"Template-Only Mode"}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-500",children:"No pricing or materials needed. Salesperson will measure and quote after template."})]})]}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-500",children:"📅 You can schedule the template measurement from the job details page after creation."})]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{onResult:s=>{m(i=>({...i,square_feet:s.square_feet||i.square_feet,material_type:s.material_type||i.material_type,material_name:s.material_name||i.material_name}))}}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Material Type"}),e.jsxs(A,{value:t.material_type,onValueChange:s=>m({...t,material_type:s}),children:[e.jsx(D,{children:e.jsx($,{placeholder:"Select material"})}),e.jsxs(T,{children:[e.jsx(j,{value:"quartz",children:"Quartz"}),e.jsx(j,{value:"granite",children:"Granite"}),e.jsx(j,{value:"marble",children:"Marble"}),e.jsx(j,{value:"laminate",children:"Laminate"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Material Name"}),e.jsx(v,{value:t.material_name,onChange:s=>m({...t,material_name:s.target.value}),placeholder:"Calacatta Quartz"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Square Footage"}),e.jsx(v,{type:"number",value:t.square_feet,onChange:s=>m({...t,square_feet:s.target.value}),placeholder:"50"})]}),r==="retail"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Selling Price ($) *"}),e.jsx(v,{type:"number",value:t.selling_price,onChange:s=>m({...t,selling_price:s.target.value}),placeholder:"2500"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for retail customers"})]}),r==="contractor"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{children:"Estimated Price (Optional)"}),e.jsx(v,{type:"number",value:t.selling_price,onChange:s=>m({...t,selling_price:s.target.value}),placeholder:"Can be updated after template"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be updated after template measurement"})]})]}),r!=="template"&&e.jsx("div",{className:"mt-4",children:e.jsx(Ce,{materialType:t.material_type,sqft:t.square_feet,projectType:t.project_type,sellingPrice:t.selling_price?parseFloat(t.selling_price):0})})]}),e.jsx("div",{className:"flex items-center gap-3 pt-2",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(re,{id:"trackAfterCreate",checked:h,onCheckedChange:s=>a(s)}),e.jsx(f,{htmlFor:"trackAfterCreate",className:"text-xs cursor-pointer",children:"Open tracking page after creation"})]})}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(P,{variant:"outline",onClick:()=>o(1),children:"Back"}),e.jsx(P,{onClick:g,disabled:!k()||_.isPending,className:"gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-primary-foreground border-t-transparent roun
5ded-full animate-spin"}),"Creating Job..."]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4"}),"Create Job"]})})]})]})]})]})})}export{Ge 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.