PageSourceSearch

https://knuckl.com/assets/ContractorProjectCreate-DiRF6ZJH.js

js knuckl.com collected 2026-09-24 14:46:45 UTC 9,126 bytes, 1 lines download raw bytes

1import{u as z,a,j as e}from"./vendor-query-BxlSJxfF.js";import{u as J,a as W,X as Y,L as E,s as Z,e as F}from"./index-DO0aGFYL.js";import{H as ee}from"./Head-CFjoxvyt.js";import{P as te}from"./ProjectTemplatePicker-DDvjY5B7.js";import{u as re,P as ae}from"./use-project-limit-DCj7CUTe.js";import{m as se}from"./tier-error-C6TW3of0.js";import{u as oe}from"./vendor-react-DdNhUK9-.js";import{M as ne}from"./map-pin-Clc12hBl.js";import{C as le}from"./chevron-left-Bpy2VrDY.js";import{C as ie}from"./chevron-right-n5eCbV2c.js";import"./vendor-supabase-Csx7YFID.js";import"./phase-trade-defaults-4MDcN226.js";import"./skill-tiers-Dqp05d-G.js";import"./vendor-motion-CdL2ySym.js";import"./sparkles-B9Io74C_.js";import"./sheet-KxRpZ2qz.js";import"./folder-kanban-BIitgRxF.js";import"./arrow-up-right-JV_yD5Sz.js";import"./use-subscription-OP_b8dLc.js";const y=2;async function de(l,c){try{const t=(await(await fetch(`https://nominatim.openstreetmap.org/reverse?${new URLSearchParams({lat:String(l),lon:String(c),format:"json"})}`,{headers:{"User-Agent":"Knuckl-App/1.0"}})).json()).address||{};return[[t.house_number,t.road].filter(Boolean).join(" "),t.city||t.town||t.village||t.hamlet,t.state].filter(Boolean).join(", ")}catch{return""}}async function ce(l){try{const f=await(await fetch(`https://nominatim.openstreetmap.org/search?${new URLSearchParams({q:l,format:"json",limit:"1"})}`,{headers:{"User-Agent":"Knuckl-App/1.0"}})).json(),u=Array.isArray(f)?f[0]:null;return u?{lat:parseFloat(u.lat),lng:parseFloat(u.lon)}:null}catch{return null}}function Ae(){const l=oe(),{user:c}=J(),f=z(),{t:u}=W(),t=u.contractorProjectCreate,[s,C]=a.useState(0),[h,H]=a.use
1State(""),{canCreate:b}=re(),[O,j]=a.useState(!1);a.useEffect(()=>{b||j(!0)},[b]);const[o,L]=a.useState(""),[B,P]=a.useState(null),[K,q]=a.useState(null),[v,S]=a.useState(!1),[i,R]=a.useState(""),[p,U]=a.useState(""),[N,M]=a.useState(""),[w,k]=a.useState(!1),[n,G]=a.useState(null),I=h.trim().length>0||o.trim().length>0||!!i||!!p||N.trim().length>0,Q=()=>{I&&!window.confirm(t.discardConfirm)||l("/home")},V=()=>{navigator.geolocation&&(S(!0),navigator.geolocation.getCurrentPosition(async r=>{P(r.coords.latitude),q(r.coords.longitude);const x=await de(r.coords.latitude,r.coords.longitude);L(x||`${r.coords.latitude.toFixed(3)}, ${r.coords.longitude.toFixed(3)}`),S(!1)},()=>S(!1),{enableHighAccuracy:!1,timeout:1e4}))},A=i&&p&&new Date(p)<new Date(i),m=N.trim()===""?null:Number(N),D=m!==null&&(!Number.isFinite(m)||m<100||m>5e4),T=s===0?h.trim().length>0&&!D:!A&&!w,X=async()=>{if(!T)return;if(s===0){C(1);return}if(!c)return;if(!b){j(!0);return}k(!0);let r=B,x=K;if(o&&(r===null||x===null)){const g=await ce(o);g&&(r=g.lat,x=g.lng)}const{data:$,error:d}=await Z.from("projects").insert({contractor_id:c.id,name:h.trim(),address:o.trim()||null,lat:r,lng:x,start_date:i||null,end_date:p||null,status:"planning",conditioned_sqft:m}).select("id").single();if(k(!1),d||!$){const g=((d==null?void 0:d.message)??"")+" "+((d==null?void 0:d.details)??"");if(se(g)==="project_limit_reached"){j(!0);return}F.error(t.errorToast);return}F.success(t.successToast),f.invalidateQueries({queryKey:["project-limit-count",c.id]}),G({id:$.id,startDate:i||null,address:o.trim()||null,lat:r,lng:x,conditionedSqft:m})},_=s===0?t.step1of:t.step2of;return e.jsxs("div",{className:"min-h-[100dvh] flex flex-col bg-background text-foreground",children:[e.jsx(ee,{title:"Create project — Knuckl",description:"Start a new project."}),e.jsxs("header",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60",children:[e.jsx("button",{type:"button",onClick:Q,className:"w-9 h-9 rounded-full flex items-center justify-center hover:bg-muted","aria-label":t.close,children:e.jsx(Y,{className:"w-5 h-5"})}),e.jsx("div",{className:"text-small font-semibold text-muted-foreground",children:t.headerTitle}),e.jsx("div",{className:"w-9"})]}),e.jsx("div",{className:"px-5 pt-3",children:e.jsx("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${(s+1)/y*100}%`}})})}),e.jsxs("main",{className:"flex-1 flex flex-col px-5 pt-4 pb-4 max-w-xl w-full mx-auto min-h-0",children:[s===0&&e.jsxs("div",{className:"flex-1 flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-label font-semibold uppercase tracking-wider text-primary mb-2",children:[_," ",y]}),e.jsx("h1",{className:"text-display font-bold leading-tight",children:t.step1Title}),e.jsx("p",{className:"text-body text-muted-foreground mt-1",children:t.step1Sub})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-body font-semibold text-foreground",children:t.nameLabel}),e.jsx("input",{value:h,onChange:r=>H(r.target.value),placeholder:t.namePlaceholder,className:"h-12 rounded-card border border-border bg-card px-5 text-title text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-body font-semibold text-foreground",children:t.addressLabel}),e.jsxs("button",{type:"button",onClick:V,disabled:v,className:"h-12 rounded-card border border-primary/40 bg-primary/5 text-primary font-semibold flex items-center justify-center gap-2 active:scale-[0.98] transition-transform",children:[v?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsx(ne,{className:"w-4 h-4"}),v?t.detecting:o?`📍 ${o}`:t.useLocation]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{className:"text-label uppercase tracking-wider text-muted-foreground",children:t.orText}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("input",{type:"text",value:o,onChange:r=>{L(r.target.value),P(null),q(null)},placeholder:t.addressPlaceholder,className:"h-12 rounded-card border border-border bg-card px-5 text-title text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-label text-muted-foreground",children:t.addressHint})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-body font-semibold text-foreground",children:t.conditionedSqftLabel}),e.jsx("input",{type:"number",inputMode:"numeric",min:100,max:5e4,step:1,value:N,onChange:r=>M(r.target.value),placeholder:t.conditionedSqftPlaceholder,className:"h-12 rounded-card border border-border bg-card px-5 text-title text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary"}),e.jsx("p",{className:"text-label text-muted-foreground",children:t.conditionedSqftHint}),D&&e.jsx("p",{className:"text-label text-red-500",children:t.conditionedSqftValidation})]})]}),s===1&&e.jsxs("div",{className:"flex-1 flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-label font-semibold uppercase tracking-wider text-primary mb-2",children:[_," ",y]}),e.jsx("h1",{className:"text-display font-bold leading-tight",children:t.step2Title}),e.jsx("p",{className:"text-body text-muted-foreground mt-1",children:t.step2Sub})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-body font-semibold text-foreground",children:t.startDateLabel}),e.jsx("input",{type:"date",value:i,onChange:r=>R(r.target.value),className:"h-12 rounded-card border border-border bg-card px-5 text-title text-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-body font-semibold text-foreground",children:t.endDateLabel}),e.jsx("input",{type:"date",value:p,min:i||void 0,onChange:r=>U(r.target.value),className:"h-12 rounded-card border border-border bg-card px-5 text-title text-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),A&&e.jsx("p",{className:"text-small text-red-500",children:t.endBeforeStart})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-2",children:[s>0&&e.jsxs("button",{type:"button",onClick:()=>C(r=>r-1),disabled:w,className:"h-12 px-5 rounded-card border border-border bg-card text-title font-semibold flex items-center gap-2 active:scale-95 transition-transform disabled:opacity-40",children:[e.jsx(le,{className:"w-4 h-4"}),t.back]}),e.jsx("button",{type:"button",onClick:X,disabled:!T,className:"flex-1 h-12 rounded-card bg-primary text-primary-foreground text-title font-bold flex items-center justify-center gap-2 disabled:opacity-40 active:scale-[0.98] transition-transform",children:w?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[s===y-1?t.createCta:t.continueCta,e.jsx(ie,{className:"w-4 h-4"})]})})]})]}),n&&e.jsx(te,{open:!0,projectId:n.id,projectStartDate:n.startDate,projectAddress:n.address,projectLat:n.lat,projectLng:n.lng,projectConditionedSqft:n.conditionedSqft,onClose:()=>l(`/contractor/projects/${n.id}`,{replace:!0})}),e.jsx(ae,{open:O,onOpenChange:r=>{j(r),!r&&!b&&l("/home")}})]})}export{Ae 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.