PageSourceSearch

https://estimatekit.com/assets/EstimateQuickStart-QLXahOIa.js

js estimatekit.com collected 2026-10-04 03:34:09 UTC 15,188 bytes, 7 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/onboarding-flags-izowS2nh.js","assets/index-CbvCveKN.js","assets/index-DK9kCj9D.css"])))=>i.map(i=>d[i]);
2import{A as xe,k as pe,D as he,aa as fe,m as ge,r as i,ac as je,o as q,j as e,g as A,X as ye,z as y,I as p,B as be,Q as F,af as Ne,ad as _e,_ as U,K as T}from"./index-CbvCveKN.js";import{i as X}from"./initials-a0OX-QAT.js";import{D as ve,P as we}from"./PageContainer-Bx7SVsdy.js";import{P as ke}from"./PageHeader-ohyr15TW.js";import{S as Ce}from"./SearchInput-CwtZ1bZ_.js";import{T as Se}from"./TemplateIcon-CN0RSA5P.js";import{n as G,i as Ee,a as Pe,c as qe}from"./ActivityFeed-DKSo_sMt.js";import{l as Ae,a as Fe}from"./templates-DNmeeYY2.js";import{M as Te}from"./map-pin-6WClXrvU.js";import{P as Ie}from"./phone-C9i08TZ5.js";import{P as ze}from"./plus-kYCBPFxU.js";import{C as ee}from"./chevron-right-f4vsMuAf.js";import"./check-Bjw6cCk6.js";import"./index-Jf4OHjGl.js";import"./triangle-alert-BJBV5PBt.js";import"./en-US-wdCzBwgh.js";import"./file-text-DDhZ7a0t.js";import"./users-BkZzL3s4.js";import"./layout-dashboard-rEexJXnQ.js";import"./ek-mark-light-Y4_w-cFG.js";import"./parseISO-B0WEjCD3.js";import"./plug-BAhKXAxN.js";import"./chevron-down-yKD6BMcU.js";import"./search-fqqyqjqf.js";import"./snowflake-CDB4vx7u.js";import"./wrench-CG-mx_ij.js";import"./index-CKxf6gP2.js";import"./external-link-DtZsaCxu.js";import"./format-BZAqQT85.js";import"./differenceInCalendarDays-BmAYwV3_.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const Me=xe("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),Le=k=>{const d=k.replace(/\D/g,"");return d.length<=3?d:d.length<=6?`(${d.slice(0,3)}) ${d.slice(3)}`:`(${d.slice(0,3)}) ${d.slice(3,6)}-${d.slice(6,10)}`},I="rounded-xl border border-ink/[0.06] bg-card",z="text-[15px] font-semibold text-foreground",pt=()=>{const k=pe(),d=he(),{requireWrite:te}=fe(),[M]=ge(),b=M.get("customer"),L=M.get("template"),[N,R]=i.useState([]),[se,ae]=i.useState(!1),[h,$]=i.useState(null),[C,D]=i.useState([]),[f,B]=i.useState(""),[r,_]=i.useState(null),[re,O]=i.useState(!1),[ne,ie]=i.useState(!1),[n,x]=i.useState({name:"",phone:"",email:"",address:"",city:"",state:"",zip:""}),[Q,j]=i.useState(null),[V,le]=i.useState(""),[g,H]=i.useState(null),K=i.useRef(null);i.useEffect(()=>{je().then(t=>{const s=t||[];if(R(s),b){const a=s.find(m=>m.id===b);a&&_(a)}}).catch(()=>R([])).finally(()=>ae(!0))},[b]),i.useEffect(()=>{(async()=>{try{const{data:t,error:s}=await q.from("templates").select("id, name, category, folder_id, times_used").order("times_used",{ascending:!1}).order("name");if(s)throw s;const a=(t||[]).map(o=>o.id),{data:m}=a.length?await q.from("template_tiers").select("template_id, tier_name, display_order").in("template_id",a).order("display_order"):{data:[]};$((t||[]).map(o=>({id:o.id,name:o.name,category:o.category,folder_id:o.folder_id,tiers:(m||[]).filter(u=>u.template_id===o.id).map(u=>u.tier_name)})))}catch{$([])}Ae().then(D).catch(()=>D([]))})()},[]);const S=i.useMemo(()=>{const t=f.trim().toLowerCase();return t?N.filter(s=>[s.client_name,s.phone,s.email,s.address,s.city].some(a=>a==null?void 0:a.toLowerCase().includes(t))).slice(0,6):N.slice(0,5)},[N,f]),oe=i.useMemo(()=>{if(!h)return[];const t=new Map;for(const a of h){const m=a.folder_id&&C.some(o=>o.id===a.folder_id)?a.folder_id:"__none__";t.set(m,[...t.get(m)||[],a])}const s=C.filter(a=>t.has(a.id)).map(a=>({label:a.name,list:t.get(a.id)}));return t.has("__none__")&&s.push({label:s.length?"Other templates":"Templates",list:t.get("__none__")}),s},[h,C]),v=L?(h==null?void 0:h.find(t=>t.id===L))??null:null,W=t=>{_(t),j(null),setTimeout(()=>{var s;return(s=document.getElementById("qs-job"))==null?void 0:s.focus()},30)},J=()=>{O(!0),_(null),j(null),x(t=>({...t,name:t.name||f.trim()}))},ce=(r==null?void 0:r.client_name)??n.name.trim(),w=async t=>{var s;if(!g){if(!ce){j("Pick a customer or add a new one first."),(s=K.current)==null||s.scrollIntoView({behavior:"smooth",block:"center"});return}if(te()&&await Ne("create",()=>void w(t))){H((t==null?void 0:t.id)??"blank");try{const{data:{session:a}}=await q.auth.getSession(),m=a==null?void 0:a.user;if(!m)throw new Error("You are signed out. Sign in and try again.");
7const o=G(),u=await _e().catch(()=>null),Y=Number((u==null?void 0:u.default_materials_tax_rate)??0),me=Number((u==null?void 0:u.default_labor_tax_rate)??0);let E=(r==null?void 0:r.id)??null;const l=r?{name:r.client_name,phone:r.phone,email:r.email,address:r.address,city:r.city,state:r.state,zip:r.zip}:{name:n.name.trim(),phone:n.phone||null,email:n.email.trim()||null,address:n.address||null,city:n.city||null,state:n.state||null,zip:n.zip||null};if(!r){const c=G();try{await Ee(o,{id:c,user_id:m.id,client_name:l.name,email:l.email,phone:l.phone,address:l.address,city:l.city,state:l.state,zip:l.zip}),E=c,U(()=>import("./onboarding-flags-izowS2nh.js"),__vite__mapDeps([0,1,2])).then(P=>P.markOnboardingFlag("has_created_customer")).catch(()=>{})}catch(P){console.error("Error saving customer:",P)}}const ue=[l.address,l.city,l.state,l.zip].filter(Boolean).join(", "),Z={id:o,user_id:m.id,client_name:l.name,client_address:ue||null,client_phone:l.phone||null,client_email:l.email||null,job_description:V.trim()||null,template_type:(t==null?void 0:t.name)||"Custom Estimate",status:"draft",materials_tax_rate:Y,labor_tax_rate:me,tax_rate:Y,...E?{account_id:E}:{}};if(await Pe(Z),U(()=>import("./onboarding-flags-izowS2nh.js"),__vite__mapDeps([0,1,2])).then(c=>c.markOnboardingFlag("has_created_estimate")).catch(()=>{}),await qe(o,"created",`Estimate created for ${l.name}`,{client_name:l.name,job_type:Z.template_type}),await d.invalidateQueries({queryKey:["all-estimates"]}),t)try{const c=await Fe(o,t.id);T({title:"Template applied",description:c.optionsCreated>1?`${c.optionsCreated} pricing options are ready.`:`${c.itemsAdded} items added from the template.`})}catch(c){T({title:"Template not applied",description:c instanceof Error?c.message:"Add it from the estimate.",variant:"destructive"})}k(`/estimates/${o}/add-items`,{replace:!0})}catch(a){T({title:"Couldn't start the estimate",description:a instanceof Error?a.message:"Try again.",variant:"destructive"}),H(null)}}}},de=({t})=>{const s=g===t.id;return e.jsxs("button",{type:"button",onClick:()=>void w(t),disabled:!!g,className:"flex w-full items-center gap-3 bg-card px-4 py-3 text-left transition-colors hover:bg-ink/[0.04] disabled:opacity-60",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-ink/[0.05]",children:e.jsx(Se,{category:t.category,className:"h-4 w-4 text-foreground-secondary"})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate text-[14px] font-medium text-foreground",children:t.name}),e.jsx("span",{className:"truncate text-[12.5px] text-foreground-tertiary",children:t.tiers.length>1?t.tiers.join(" · "):"Single price"})]}),s?e.jsx(F,{className:"h-4 w-4 animate-spin text-foreground-secondary"}):e.jsx(ee,{className:"h-4 w-4 text-foreground-tertiary"})]})};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ve,{}),e.jsxs(we,{width:"default",children:[e.jsx(ke,{title:"New estimate",description:"Pick the customer and a starting point. You'll add, adjust and send on the next screen.",backTo:"/estimates",backLabel:"Estimates"}),e.jsxs("div",{className:"flex flex-col gap-7",children:[e.jsxs("section",{ref:K,className:"flex flex-col gap-3",children:[e.jsx("h2",{className:z,children:"Who's it for?"}),r?e.jsxs("div",{className:A(I,"flex items-center gap-3 px-4 py-3"),children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-ink/[0.06] text-[13px] font-semibold text-ink/80",children:X(r.client_name)}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold",children:r.client_name}),e.jsx("span",{className:"truncate text-[12.5px] text-foreground-secondary",children:[r.address,r.city].filter(Boolean).join(", ")||r.phone||r.email||"No contact details"})]}),e.jsx("button",{type:"button",onClick:()=>{_(null),B("")},className:"text-[13px] font-medium text-info underline-offset-2 hover:underline",children:"Change"})]}):re?e.jsxs("div",{className:A(I,"flex flex-col gap-4 p-4"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-medium text-foreground-secondary",children:"New customer"}),N.length>0&&e.jsxs("button",{type:"button",onClick:()=>O(!1),className:"inline-flex items-center gap-1 text-[12.5px] text-foreground-tertiary hover:text-foreground",children:[e.jsx(ye,{className:"h-3.5 w-3.5"})," Pick an existing one"]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(y,{htmlFor:"qs-name",className:"text-[12.5px] font-normal text-foreground-secondary",children:"Name"}),e.jsx(p,{id:"qs-name",autoFocus:!0,placeholder:"John Smith",value:n.name,onChange:t=>{x({...n,name:t.target.value}),j(null)},className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(y,{htmlFor:"qs-phone",className:"text-[12.5px] font-normal text-foreground-secondary",children:"Phone"}),e.jsx(p,{id:"qs-phone",type:"tel",inputMode:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:t=>x({...n,phone:Le(t.target.value)}),className:"mt-1"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(y,{htmlFor:"qs-email",className:"text-[12.5px] font-normal text-foreground-secondary",children:"Email"}),e.jsx(p,{id:"qs-email",type:"email",inputMode:"email",autoCapitalize:"none",placeholder:"[email protected]",value:n.email,onChange:t=>x({...n,email:t.target.value}),className:"mt-1"})]}),ne?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx(y,{htmlFor:"qs-address",className:"text-[12.5px] font-normal text-foreground-secondary",children:"Street address"}),e.jsx(p,{id:"qs-address",placeholder:"123 Main Street",value:n.address,onChange:t=>x({...n,address:t.target.value}),className:"mt-1"})]}),e.jsx(p,{"aria-label":"City",placeholder:"City",value:n.city,onChange:t=>x({...n,city:t.target.value})}),e.jsx(p,{"aria-label":"State",placeholder:"State",value:n.state,onChange:t=>x({...n,state:t.target.value})}),e.jsx(p,{"aria-label":"ZIP",placeholder:"ZIP",value:n.zip,onChange:t=>x({...n,zip:t.target.value})})]}):e.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"inline-flex items-center gap-1.5 text-left text-[13px] font-medium text-foreground-secondary hover:text-foreground sm:col-span-3",children:[e.jsx(Te,{className:"h-3.5 w-3.5"})," Add address"]})]})]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ce,{value:f,onChange:t=>{B(t),j(null)},onKeyDown:t=>{t.key!=="Enter"||!f.trim()||(t.preventDefault(),S.length?W(S[0]):J())},autoFocus:!b,placeholder:"Find or add a customer"}),e.jsxs("div",{className:"flex flex-col gap-px overflow-hidden rounded-xl border border-ink/[0.06] bg-ink/[0.05]",children:[S.map(t=>e.jsxs("button",{type:"button",onClick:()=>W(t),className:"flex w-full items-center gap-3 bg-card px-4 py-2.5 text-left transition-colors hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-ink/[0.06] text-[12px] font-semibold text-ink/80",children:X(t.client_name)}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate text-[14px] font-medium",children:t.client_name}),e.jsx("span",{className:"flex items-center gap-1 truncate text-[12.5px] text-foreground-tertiary",children:t.address||t.city?e.jsx(e.Fragment,{children:[t.address,t.city].filter(
7Boolean).join(", ")}):t.phone?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-3 w-3"}),t.phone]}):t.email||""})]})]},t.id)),e.jsxs("button",{type:"button",onClick:J,className:"flex w-full items-center gap-3 bg-card px-4 py-2.5 text-left transition-colors hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-dashed border-ink/25 text-foreground-secondary",children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-[14px] font-medium text-info",children:f.trim()?`New customer "${f.trim()}"`:"New customer"})]}),!se&&e.jsx("div",{className:"bg-card px-4 py-3 text-[13px] text-foreground-tertiary",children:"Loading customers…"})]})]}),Q&&e.jsx("p",{className:"text-[13px] text-bad",role:"alert",children:Q})]}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs(y,{htmlFor:"qs-job",className:z,children:["What's the job? ",e.jsx("span",{className:"text-[13px] font-normal text-foreground-tertiary",children:"Optional"})]}),e.jsx(p,{id:"qs-job",placeholder:"e.g. Replace 3-ton AC and coil",value:V,onChange:t=>le(t.target.value)})]}),e.jsxs("section",{className:"flex flex-col gap-3",children:[e.jsx("h2",{className:z,children:"Start from"}),v&&e.jsxs("div",{className:A(I,"flex flex-wrap items-center gap-3 border-cta-orange/35 p-4"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"text-[12px] font-medium text-foreground-tertiary",children:"Template"}),e.jsx("span",{className:"truncate text-[14px] font-semibold",children:v.name})]}),e.jsxs(be,{variant:"orange",onClick:()=>void w(v),disabled:!!g,children:[g===v.id?e.jsx(F,{className:"h-4 w-4 animate-spin"}):null,"Start estimate"]})]}),e.jsx("div",{className:"flex flex-col gap-px overflow-hidden rounded-xl border border-ink/[0.06] bg-ink/[0.05]",children:e.jsxs("button",{type:"button",onClick:()=>void w(null),disabled:!!g,className:"flex w-full items-center gap-3 bg-card px-4 py-3 text-left transition-colors hover:bg-ink/[0.04] disabled:opacity-60",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-dashed border-ink/15",children:e.jsx(Me,{className:"h-4 w-4 text-foreground-secondary"})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"text-[14px] font-medium",children:"Blank estimate"}),e.jsx("span",{className:"text-[12.5px] text-foreground-tertiary",children:"Add items from your price book as you go"})]}),g==="blank"?e.jsx(F,{className:"h-4 w-4 animate-spin text-foreground-secondary"}):e.jsx(ee,{className:"h-4 w-4 text-foreground-tertiary"})]})}),h===null?e.jsx("div",{className:"h-24 animate-pulse rounded-xl bg-ink/[0.04]"}):oe.map(t=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"px-1 text-[12.5px] text-foreground-tertiary",children:t.label.charAt(0).toUpperCase()+t.label.slice(1)}),e.jsx("div",{className:"flex flex-col gap-px overflow-hidden rounded-xl border border-ink/[0.06] bg-ink/[0.05]",children:t.list.map(s=>e.jsx(de,{t:s},s.id))})]},t.label))]})]})]})]})};export{pt 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.