PageSourceSearch

https://knuckl.com/assets/SubPackageDetail-D3UsxtWM.js

js knuckl.com collected 2026-10-02 01:34:19 UTC 17,489 bytes, 1 lines download raw bytes

1import{u as ve,a as h,e as C,k as ke,j as e}from"./vendor-query-CRhh6spR.js";import{u as Ce}from"./use-primary-query-LdYs10m3.js";import{u as Se,b as qe,e as Be,a as Pe,L as E,B as g,y as ee,g as Le,z as Te,ab as Fe,h as y,S as Me,q as Ie,r as De,v as Ee,I as $e,s as j}from"./index-BkVb42KZ.js";import{f as Ae}from"./use-profile-summary-CvkL6Ay4.js";import{P as Oe}from"./ProBadge-CeeKgQ59.js";import{S as Ue}from"./SampleBadge-DfdiBrQW.js";import{u as Ge}from"./use-contextual-prompt-C-UOBaQg.js";import{a as Re}from"./bid-deadline-BsuXNHJh.js";import{a as Ke,F as Qe,b as He,c as We,r as ze,D as Je}from"./attachment-url-BGa7v_B7.js";import{T as Ve}from"./TransportOptions-loD-saWv.js";import{M as Xe}from"./MessagingGate-DMz-Yzwh.js";import{u as Ye}from"./use-message-worker-action-DwTPFeve.js";import{T as Ze}from"./textarea-BQTQ5UjX.js";import{m as et}from"./tier-error-C6TW3of0.js";import{r as tt}from"./SubPackageCard-DzRx9-ET.js";import{H as st}from"./Head-B4hXUiBE.js";import{I as at}from"./InsurancePartnerCard-DRRhT2mH.js";import{u as rt}from"./use-sub-bid-quota-CAcZFq8b.js";import{L as it}from"./LoadErrorCard-B2FnJgy6.js";import{L as nt}from"./LeadCrewSection-zChk7J7G.js";import{t as ot}from"./image-url-_sEuZELz.js";import{t as lt}from"./marketing-events-Ch2Ss8qi.js";import{g as ct,u as dt,N as mt,L as pt}from"./vendor-react-BAmwgVqg.js";import{A as ut}from"./arrow-left-B9mh4lKG.js";import{C as te}from"./circle-check-big-Cjr7FrMh.js";import{M as se}from"./message-square-BwPXUwfW.js";import{G as xt}from"./gavel-By4x2vGi.js";import{m as ft}from"./vendor-motion-BcLIBd36.js";import{W as bt}from"./wrench-CQB9vgwx.js";import{C as ht}from"./clock-B5A68DmX.js";import{C as gt}from"./calendar-BOzI1TJy.js";import{M as yt}from"./map-pin-BnyER353.js";import{P as jt}from"./paperclip-DL8oCpsi.js";import{F as ae}from"./file-text-DfpMrF0r.js";import{E as re}from"./external-link-ibDNud24.js";import{D as Nt}from"./download-C8JTs7FR.js";import{S as wt}from"./star-BpldOkBP.js";import"./vendor-charts-BVeOEGzI.js";import"./vendor-stripe-2y4Jo9_W.js";import"./vendor-supabase-Csx7YFID.js";import"./popover-D6r7zknv.js";import"./sparkles-BuBBRAeM.js";import"./flask-conical-RfZJi1zC.js";import"./chevron-right-DSioQ7mT.js";import"./post-job-sheet-BxL-Oe-u.js";import"./message-circle-BTvelDNo.js";import"./zap-lWgtODcO.js";import"./briefcase-D-vMkZXu.js";import"./use-messaging-permission-Dax1aQua.js";import"./haptics-C4kiRWSa.js";import"./use-geolocation-CHbY3Amh.js";import"./CrewAvailableList-BD5VkafE.js";import"./badge-DfIFDYyU.js";import"./use-work-offers-B0aATY--.js";import"./users-CLblnKO6.js";import"./hard-hat-DFuF37sz.js";import"./OfferSheet-ByMX9GkF.js";import"./label-Xk_s6Ck5.js";import"./use-market-rate-0ltI8I7S.js";function qs(){var K,Q,H,W,z,J,V;const{messageWorker:$,gateProps:ie}=Ye(),{id:c}=ct(),S=dt(),{user:r}=Se(),{t:m,lang:A}=qe(),a=m.subMarketplace,ne=ve(),[N,O]=h.useState(null),[oe,U]=h.useState(null),[le,w]=h.useState(!1),[q,B]=h.useState(""),[_,P]=h.useState(""),{open:ce}=Be(),L=rt(),x=m.subBidQuota??{},{data:T}=Pe(r==null?void 0:r.id),de=!!((K=T==null?void 0:T.sub)!=null&&K.licenseClass),F=Ge("sub_add_license_after_first_bid",!!(r!=null&&r.id),{alreadyDone:de}),me=()=>{var n,l,u,b,k;if(!F.show)return;const s=((u=(l=(n=m.prompts)==null?void 0:n.contextual)==null?void 0:l.sub)==null?void 0:u.addLicenseClass)??{},o=((k=(b=m.prompts)==null?void 0:b.contextual)==null?void 0:k.dismissCta)??"Not now";y(s.title??"Add license class to bid on more packages",{description:s.body,duration:8e3,action:{label:s.cta??"Add license",onClick:()=>{F.markComplete(),S("/profile")}},cancel:{label:o,onClick:()=>F.dismiss()}})},{data:t,isLoading:pe,isError:ue,isFetching:xe,refetch:fe}=Ce({queryKey:["sub-package-detail",c],enabled:!!c,queryFn:async()=>{const{data:s,error:o}=await j.from("jobs").select("id, title, description, trade_type, location, lat, lng, pay, pay_range_max, start_date, bid_deadline, duration, requires_license, insurance_required, contractor_id, attachments, job_type, status, is_demo").eq("id",c).maybeSingle();if(o)throw o;return s}}),{data:i}=C({queryKey:["sub-package-poster",t==null?void 0:t.contractor_id],enabled:!!(t!=null&&t.contractor_id),queryFn:async()=>{var l,u;const s=await Ae(t.contractor_id),o=s?{user_id:s.userId,full_name:s.displayName,avatar_url:s.avatarUrl}:null,n=s!=null&&s.sub?{company_name:s.sub.companyName,avg_rating:((l=s.hiring)==null?void 0:l.avgRating)??null,total_hires:((u=s.hiring)==null?void 0:u.totalHires)??0,isPaid:!!s.sub.isPaid}:null;return{profile:o,cprofile:n}}}),{data:d}=C({queryKey:["sub-package-my-application",c,r==null?void 0:r.id],enabled:!!c&&!!r,queryFn:async()=>{const{data:s}=await j.from("applications").select("id, status, bid_amount, bid_note, created_at").eq("job_id",c).eq("worker_id",r.id).maybeSingle();return s}}),{data:be}=C({queryKey:["sub-prior-bid-count",r==null?void 0:r.id],enabled:!!r,staleTime:5*6e4,queryFn:async()=>{const{count:s}=await j.from("applications").select("id",{count:"exact",head:!0}).eq("worker_id",r.id).not("bid_amount","is",null);return s??0}}),he=be===0,{data:ge}=C({queryKey:["sub-package-bid-invite",c,r==null?void 0:r.id],enabled:!!c&&!!r,queryFn:async()=>{const{data:s}=await j.from("job_invitations").select("id, status, invite_method").eq("job_id",c).eq("worker_id",r.id).eq("invite_method","bid_invite").eq("status","pen
1ding").maybeSingle();return s}}),v=ke({mutationFn:async()=>{const s=q.trim(),o=_.trim(),n=s?Number(s):null;if(s&&(!Number.isFinite(n)||n<=0))throw new Error(a.errBidInvalid);const{error:l}=await j.from("applications").insert({job_id:c,worker_id:r.id,bid_amount:n,bid_note:o||null,status:"pending",apply_source:"sub_marketplace"});if(l)throw l;lt("sub_marketplace")},onSuccess:()=>{y.success(a.toastBidSubmitted),me(),w(!1),B(""),P(""),ne.invalidateQueries({queryKey:["sub-package-my-application",c,r==null?void 0:r.id]}),L.refetch()},onError:s=>{var n;const o=et(s==null?void 0:s.message);if(o){const l=(n=m.subscriptionGates.serverErrors)==null?void 0:n[o];y.error(l??m.subscriptionGates.common[o]??o),o==="sub_bid_limit_reached"&&(w(!1),ce("sub_bid",x.capReachedTitle),L.refetch());return}y.error((s==null?void 0:s.message)??a.toastBidFailed)}});if(pe)return e.jsx("div",{className:"p-6 flex justify-center",children:e.jsx(E,{className:"w-6 h-6 animate-spin text-muted-foreground"})});if(ue)return e.jsx("div",{className:"max-w-xl mx-auto p-6",children:e.jsx(it,{onRetry:()=>fe(),isRetrying:xe})});if(!t||t.job_type!=="sub_package")return e.jsxs("div",{className:"max-w-xl mx-auto p-6 text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:a.notFound}),e.jsx(g,{variant:"outline",onClick:()=>S("/contractor/sub-jobs"),children:a.backToFeed})]});if(r!=null&&r.id&&t.contractor_id===r.id)return e.jsx(mt,{to:`/contractor/jobs/${t.id}`,replace:!0});const ye=tt(t.pay!=null?Number(t.pay):null,t.pay_range_max!=null?Number(t.pay_range_max):null,a),M=t.attachments??[],p=Re(t.bid_deadline,t.start_date),f=((Q=i==null?void 0:i.cprofile)==null?void 0:Q.company_name)??((H=i==null?void 0:i.profile)==null?void 0:H.full_name)??a.unknownPoster,I=((W=i==null?void 0:i.cprofile)==null?void 0:W.avg_rating)!=null?Number(i.cprofile.avg_rating):null,G=!!d,D=m.inviteToBid,R=(d==null?void 0:d.status)==="accepted"&&!t.is_demo,je=!!ge&&!G&&!R;return e.jsxs("div",{className:"max-w-2xl mx-auto p-4 pb-32 space-y-5",children:[e.jsx(st,{title:t.title,description:(t.description??"").slice(0,160)}),e.jsxs("button",{onClick:()=>S(-1),className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(ut,{className:"w-4 h-4"})," ",m.common.back]}),R&&e.jsxs("div",{className:"rounded-card border border-success/40 bg-success/10 px-4 py-3 space-y-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-success shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:a.awardedTitle}),e.jsx("p",{className:"text-label text-muted-foreground",children:a.awardedBody}),(d==null?void 0:d.bid_amount)!=null&&e.jsxs("p",{className:"text-label text-foreground mt-0.5",children:[a.awardedBidLabel,": $",Number(d.bid_amount).toLocaleString()]})]})]}),e.jsxs(g,{className:"w-full",onClick:()=>$(t.contractor_id,f),children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),String(a.awardedMessageCta??"").replace("{name}",f)]})]}),je&&e.jsxs("div",{className:"rounded-card border border-primary/40 bg-primary/10 px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(xt,{className:"w-4 h-4 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:D.bannerTitle}),e.jsx("p",{className:"text-label text-muted-foreground",children:i?D.bannerBody(f):D.bannerBodyNoName})]})]}),L.atCap]}),e.jsxs(ft.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-card border border-border/60 bg-card/80 backdrop-blur-md p-5 space-y-4",children:[t.trade_type&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary/10 text-primary text-caption font-semibold px-2 py-0.5",children:[e.jsx(bt,{className:"w-3 h-3"})," ",t.trade_type]}),t.is_demo&&e.jsx("span",{className:"inline-flex ml-1.5 align-middle",children:e.jsx(Ue,{})}),e.jsx("h1",{className:"font-display text-2xl text-foreground leading-tight",children:t.title}),e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-bold text-foreground",children:ye}),e.jsx("p",{className:"text-caption text-muted-foreground mt-0.5",children:a.fixedPricePackage})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground flex-wrap",children:[p.date&&p.urgency!=="passed"&&p.urgency!=="none"&&e.jsxs("span",{className:Le("inl
1ine-flex items-center gap-1 rounded-full text-caption font-semibold px-2 py-0.5",p.urgency==="urgent"&&"bg-destructive/10 text-destructive",p.urgency==="soon"&&"bg-warning/10 text-warning",p.urgency==="normal"&&"bg-muted text-muted-foreground"),children:[e.jsx(ht,{className:"w-3.5 h-3.5"}),p.urgency==="urgent"&&typeof a.bidsClosingIn=="function"?a.bidsClosingIn(Math.max(1,Math.round(p.hoursRemaining??0))):`${a.bidsClose??"Bids close"}: ${ee(p.date.toISOString(),A,{month:"short",day:"numeric"})}`]}),t.start_date&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(gt,{className:"w-3.5 h-3.5"}),a.startsOn(ee(t.start_date,A,{month:"short",day:"numeric"})),t.duration?` · ${a.approxDays(t.duration)}`:""]}),t.location&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(yt,{className:"w-3.5 h-3.5"})," ",t.location]}),t.requires_license&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-warning/10 text-warning text-micro font-semibold px-2 py-0.5",children:[e.jsx(Te,{className:"w-3 h-3"})," ",a.licenseRequired??"License required"]})]})]}),e.jsx(nt,{targetType:"sub_package",targetId:t.id,title:t.title,trade:t.primary_skill??null}),e.jsx(Ve,{location:t.location??"",lat:t.lat??null,lng:t.lng??null,jobTitle:t.title||"Job site",reimbursement:null}),t.description&&e.jsxs("section",{className:"rounded-card border border-border/60 bg-card/60 p-5 space-y-2",children:[e.jsx("h2",{className:"text-caption font-semibold uppercase tracking-widest text-muted-foreground",children:a.scopeTitle}),e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:t.description})]}),M.length>0&&e.jsxs("section",{className:"rounded-card border border-border/60 bg-card/60 p-5 space-y-3",children:[e.jsxs("h2",{className:"text-caption font-semibold uppercase tracking-widest text-muted-foreground flex items-center gap-1.5",children:[e.jsx(jt,{className:"w-3.5 h-3.5"})," ",a.plansTitle," (",M.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.map((s,o)=>{const n=Ke(s)||`file-${o+1}`,l=(n.split(".").pop()||"").toLowerCase(),u=l==="pdf",b=["jpg","jpeg","png","webp","gif","bmp","svg"].includes(l),k=["xlsx","xls","csv"].includes(l),Ne=["docx","doc"].includes(l),X=u||b,we=u?ae:b?Qe:k?He:Ne?ae:We,_e=n.length>40?`${n.slice(0,18)}…${n.slice(-18)}`:n,Y=oe===s;return e.jsxs("button",{type:"button",disabled:Y,onClick:async()=>{if(t!=null&&t.id){U(s);try{const Z=await ze(s,t.id);X?O({url:Z,name:n}):await Fe(Z)}catch{y.error(m.common.attachmentOpenError)}finally{U(null)}}},className:"w-full flex items-center gap-3 p-3 rounded-xl border border-border/60 bg-card/60 hover:border-primary/30 transition-all text-left",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(we,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-sm text-foreground truncate flex-1",children:_e}),Y?e.jsx(E,{className:"w-4 h-4 text-primary animate-spin shrink-0"}):X?e.jsx(re,{className:"w-4 h-4 text-muted-foreground shrink-0"}):e.jsx(Nt,{className:"w-4 h-4 text-muted-foreground shrink-0"})]},o)})})]}),t.contractor_id&&e.jsxs("section",{className:"rounded-card border border-border/60 bg-card/60 p-5 space-y-3",children:[e.jsx("h2",{className:"text-caption font-semibold uppercase tracking-widest text-muted-foreground",children:a.postedByTitle}),e.jsxs(pt,{to:`/profile/${t.contractor_id}`,className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-muted overflow-hidden flex items-center justify-center shrink-0",children:(z=i==null?void 0:i.profile)!=null&&z.avatar_url?e.jsx("img",{src:ot(i.profile.avatar_url,96),alt:"",className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-sm font-semibold text-muted-foreground",children:f.slice(0,1).toUpperCase()})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[f,((J=i==null?void 0:i.cprofile)==null?void 0:J.isPaid)&&e.jsx(Oe,{visible:!0,size:"xs"})]})}),I!=null&&I>0&&e.jsxs("p",{className:"text-caption text-muted-foreground inline-flex items-center gap-1",children:[e.jsx(wt,{className:"w-3 h-3 fill-warning text-warning"}),I.toFixed(1),(V=i==null?void 0:i.cprofile)!=null&&V.total_hires?` · ${a.hires(i.cprofile.total_hires)}`:""]})]}),e.jsx(re,{className:"w-4 h-4 text-muted-foreground group-hover:text-primary transition-colors"})]})]}),e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-30 bg-background/95 backdrop-blur-md border-t border-border/60 px-4 py-3 pb-[calc(env(safe-area-inset-bottom)+12px)]",children:e.jsx("div",{className:"max-w-2xl mx-auto",children:G?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-xl bg-success/10 border border-success/30 px-4 py-2.5 text-sm text-foreground flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-success shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold",children:a.appliedStatus(String(d.status))}),d.bid_amount!=null&&e.jsxs("p",{className:"text-caption text-muted-foreground",children:[a.yourBidLabel,": $",Number(d.bid_amount).toLocaleStr
1ing()]})]})]}),e.jsxs(g,{variant:"outline",className:"w-full",onClick:()=>$(t.contractor_id),children:[e.jsx(se,{className:"w-4 h-4 mr-2"})," ",a.messagePoster]})]}):e.jsx(g,{className:"w-full h-12 text-base font-semibold",disabled:v.isPending,onClick:()=>{!q&&t.pay!=null&&B(String(Math.round(Number(t.pay)))),w(!0)},children:a.applyCta})})}),e.jsx(Me,{open:le,onOpenChange:w,children:e.jsxs(Ie,{side:"bottom",className:"rounded-t-2xl max-h-[90dvh] overflow-y-auto",children:[e.jsx(De,{children:e.jsx(Ee,{children:a.applySheetTitle})}),!1,e.jsxs("div",{className:"space-y-5 pt-4 pb-6",children:[t.insurance_required&&e.jsx(at,{context:"bid",jobId:t.id}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:a.bidLabel}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx($e,{type:"number",inputMode:"decimal",min:"0",step:"1",value:q,onChange:s=>B(s.target.value),placeholder:"0",className:"pl-7"})]}),e.jsx("p",{className:"text-caption text-muted-foreground",children:a.bidHint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:a.noteLabel}),he&&!_&&e.jsxs("div",{className:"rounded-lg bg-primary/10 px-3 py-2 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:x.firstBidTitle}),e.jsx("p",{className:"text-caption text-muted-foreground",children:x.firstBidBody}),e.jsx("button",{type:"button",onClick:()=>P(String(x.template??"")),className:"text-caption font-semibold text-primary underline underline-offset-2",children:x.useTemplate})]}),e.jsx(Ze,{value:_,onChange:s=>P(s.target.value.slice(0,300)),placeholder:a.notePlaceholder,rows:4}),e.jsxs("p",{className:"text-caption text-muted-foreground text-right",children:[_.length,"/300"]})]}),e.jsx(g,{className:"w-full h-11",disabled:v.isPending,onClick:()=>v.mutate(),children:v.isPending?e.jsx(E,{className:"w-4 h-4 animate-spin"}):a.submitBid})]})]})}),N&&e.jsx(Je,{open:!!N,onOpenChange:s=>{s||O(null)},url:N.url,name:N.name}),e.jsx(Xe,{...ie})]})}export{qs 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.