1import{i as Ve,E as Le,cl as Ue,r as o,d as W,k as $e,j as e,B as x,a0 as pe,I as n,F as he,G as xe,S as fe,H as ge,J as m,T as X,cu as Be,ab as Me,D as Ge,l as ze,m as Ke,n as He,o as Je,aP as We,z as Xe,y as Ye}from"./index-bciIWLG1.js";import{C as v,a as w,b as F,c as T,d as j}from"./card-DTK7dWeM.js";import{R as ve,a as E}from"./radio-group-CIku3Aol.js";import{C as je,a as ye,b as Ne,c as Ce,d as be,e as Pe}from"./command-D67Cj6NB.js";import{U as Ze}from"./user-plus-B3ctW4ZY.js";import{C as es}from"./calendar-days-D0XZ51YK.js";import{P as ss}from"./plus-U5Z5nz4N.js";import{T as ts}from"./trash-2-D3zE-Sp8.js";import{C as as}from"./calculator-afOE0i_O.js";function xs(){var me;const{toast:h}=Ve(),[,S]=Le(),we=Ue(),q=new URLSearchParams(we).get("clone"),[y,Y]=o.useState("existing"),Q=y==="prospective",f=y==="one_off",D=Q||f,[N,R]=o.useState(""),[k,O]=o.useState(5),[Fe,ns]=o.useState(""),[Ee,qe]=o.useState(""),[_,Z]=o.useState(""),[u,g]=o.useState([]),[Ae,ee]=o.useState(!1),[se,te]=o.useState(!1),[ae,Ie]=o.useState(!1),[A,V]=o.useState(""),[ie,L]=o.useState(""),[ne,U]=o.useState(""),[$,B]=o.useState(""),[re,M]=o.useState(""),[oe,G]=o.useState(""),[C,z]=o.useState("one_off"),[K,le]=o.useState(""),[Te,H]=o.useState(!1),[d,I]=o.useState(null),{data:J=[]}=W({queryKey:["/api/clients"]}),{data:Se=[]}=W({queryKey:["/api/service-catalog"]}),{data:r}=W({queryKey:["/api/quotations",q],enabled:!!q});o.useEffect(()=>{if(r&&!ae){const t=(r.customerMode??void 0)||(r.isProspectiveCustomer?"prospective":"existing");if(Y(t),t==="existing"&&r.clientId?R(r.clientId):(V(r.companyName||""),L(r.commercialRegistrationNumber||""),U(r.contactPersonName||""),B(r.emailAddress||""),M(r.contactNumber||""),G(r.companyAddress||"")),O(r.validityDays||5),Z(r.customTerms||""),r.lineItems&&r.lineItems.length>0){const i=r.lineItems.map(a=>({serviceCatalogItemId:a.serviceCatalogItemId||null,descriptionEnglish:a.descriptionEnglish||"",descriptionArabic:a.descriptionArabic||"",unitEnglish:a.unitEnglish||"",unitArabic:a.unitArabic||"",price:a.price||"0",quantity:a.quantity||"1",finalTotal:(parseFloat(a.price||"0")*parseFloat(a.quantity||"1")).toFixed(2)}));g(i)}Ie(!0),h({title:"Quotation Cloned",description:`Loaded data from ${r.quotationReference}. Edit and submit to create a new quotation.`})}},[r,ae,h]);const ce=$e({mutationFn:async s=>Xe("POST","/api/quotations",s),onSuccess:()=>{Ye.invalidateQueries({queryKey:["/api/quotations"]}),h({title:"Success",description:"Quotation created successfully"}),S("/quotations")},onError:s=>{h({title:"Error",description:s.message||"Failed to create quotation",variant:"destructive"})}}),Qe=s=>{const t={serviceCatalogItemId:s.id,descriptionEnglish:s.nameEnglish,descriptionArabic:s.nameEnglish,unitEnglish:s.unitEnglish,unitArabic:s.unitEnglish,price:s.defaultPrice,quantity:"1",finalTotal:parseFloat(s.defaultPrice||"0").toFixed(2)};g([...u,t])},De=()=>{const s={serviceCatalogItemId:null,descriptionEnglish:"",descriptionArabic:"",unitEnglish:"",unitArabic:"",price:"0",quantity:"1",finalTotal:"0.00"};g([...u,s])},b=(s,t,i)=>{const a=[...u];if(a[s]={...a[s],[t]:i},t==="descriptionEnglish"&&(a[s].descriptionArabic=i),t==="unitEnglish"&&(a[s].unitArabic=i),t==="price"||t==="quantity"){const p=parseFloat(a[s].price)||0,c=parseFloat(a[s].quantity)||1;a[s].finalTotal=(p*c).toFixed(2)}g(a)},Re=s=>{const t=u[s],i=parseFloat(t.finalTotal)||0,a=parseFloat(t.price)||0,p=parseFloat(t.quantity)||1,c=a*p;if(a<=0||i===c)return;const P=i/a,ue=P%1===0?P.toString():P.toFixed(4);I({index:s,finalTotal:t.finalTotal,calculatedQty:ue,editableQty:ue,unitPrice:a}),H(!0)},ke=()=>{if(!d)return;const{index:s,editableQty:t,unitPrice:i}=d,a=parseFloat(t)||1,p=[...u];p[s]={...p[s],quantity:t,finalTotal:(i*a).toFixed(2)},g(p),H(!1),I(null)},de=()=>{if(!d)return;const{index:s}=d,t=u[s],i=parseFloat(t.price)||0,a=parseFloat(t.quantity)||1,p=[...u];p[s]={...p[s],finalTotal:(i*a).toFixed(2)},g(p),H(!1),I(null)},Oe=s=>{g(u.filter((t,i)=>i!==s))},_e=()=>{if(Q){if(!A.trim()){h({title:"Validation Error",description:"Please enter the company name",variant:"destructive"});return}}else if(!D&&!N){h({title:"Validation Error",description:"Please select a client",variant:"destructive"});return}if(u.length===0){h({title:"Validation Error",description:"Please add at least one service item",variant:"destructive"});return}if(u.some(c=>
1!c.descriptionEnglish||!c.unitEnglish||!c.price)){h({title:"Validation Error",description:"Please fill in all required fields for each line item",variant:"destructive"});return}if(!f&&C==="service_addendum"&&!K){h({title:"Validation Error",description:"Please select an effective date for the service agreement addendum",variant:"destructive"});return}if(f){if(!A.trim()){h({title:"Validation Error",description:"Company name is required",variant:"destructive"});return}if(!$.trim()){h({title:"Validation Error",description:"Email is required for one-off customers (invoice delivery)",variant:"destructive"});return}}const t=u.map((c,P)=>({serviceCatalogItemId:c.serviceCatalogItemId,descriptionEnglish:c.descriptionEnglish,descriptionArabic:c.descriptionArabic,unitEnglish:c.unitEnglish,unitArabic:c.unitArabic,quantity:c.quantity||"1",price:c.price,sortOrder:P})),a={customerMode:y,validityDays:k,validUntil:Fe||null,status:"draft",quotationType:f?"one_off":C,effectiveFromDate:!f&&C==="service_addendum"?K:null,customTerms:_.trim()?_:null,lineItems:t},p=D?{...a,isProspectiveCustomer:Q,clientId:null,companyName:A.trim(),commercialRegistrationNumber:ie.trim()||null,contactPersonName:ne.trim()||null,contactNumber:re.trim()||null,emailAddress:$.trim()||null,companyAddress:oe.trim()||null}:{...a,isProspectiveCustomer:!1,clientId:N,companyName:(l==null?void 0:l.companyName)||"",contactPersonName:(l==null?void 0:l.contactPerson)||null,contactNumber:(l==null?void 0:l.phoneNumber)||null,emailAddress:(l==null?void 0:l.email)||null};ce.mutate(p)},l=J.find(s=>s.id===N);return e.jsxs("div",{className:"container mx-auto p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold tracking-tight",children:q?"Clone Ad-hoc Quotation":"Create Ad-hoc Quotation"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:q?`Creating a new quotation based on ${(r==null?void 0:r.quotationReference)||"existing quotation"}`:"Generate a professional quotation for a client"})]}),e.jsxs(x,{onClick:()=>S("/quotations"),variant:"outline",className:"w-full sm:w-auto","data-testid":"button-view-quotations",children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"View All Ad-hoc Quotations"]})]}),e.jsxs(v,{children:[e.jsxs(w,{children:[e.jsx(F,{children:"Client Information"}),e.jsx(T,{children:"Select an existing client or enter new customer details"})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-muted rounded-md space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ze,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(n,{className:"text-sm font-medium",children:"Customer Type"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose how this quotation will be billed"})]})]}),e.jsxs(ve,{value:y,onValueChange:s=>{const t=s;Y(t),t==="existing"?(V(""),L(""),U(""),B(""),M(""),G("")):R("")},className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsxs(n,{htmlFor:"mode-existing",className:"flex items-start gap-2 p-3 rounded-md border bg-background hover-elevate cursor-pointer",children:[e.jsx(E,{value:"existing",id:"mode-existing","data-testid":"radio-mode-existing",className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Existing Client"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Already onboarded in the system"})]})]}),e.jsxs(n,{htmlFor:"mode-prospective",className:"flex items-start gap-2 p-3 rounded-md border bg-background hover-elevate cursor-pointer",children:[e.jsx(E,{value:"prospective",id:"mode-prospective","data-testid":"radio-mode-prospective",className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Prospective Customer"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"New lead, subject to service agreement"})]})]}),e.jsxs(n,{htmlFor:"mode-one-off",className:"flex items-start gap-2 p-3 rounded-md border bg-background hover-elevate cursor-pointer",children:[e.jsx(E,{value:"one_off",id:"mode-one-off","data-testid":"radio-mode-one-off",className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"One-off Customer"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Single invoice, no service agreement"})]})]})]})]}),y==="existing"&&e.jsxs(e.Fragment,{children:[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(n,{htmlFor:"client",children:"Client *"}),e.jsxs(he,{open:se,onOpenChange:te,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(x,{variant:"outline",role:"combobox","aria-expanded":se,className:"w-full justify-between","data-testid":"select-client",children:[N?(me=J.find(s=>
1s.id===N))==null?void 0:me.companyName:"Select a client...",e.jsx(fe,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ge,{className:"w-full p-0",align:"start",children:e.jsxs(je,{children:[e.jsx(ye,{placeholder:"Search clients..."}),e.jsxs(Ne,{children:[e.jsx(Ce,{children:"No clients found."}),e.jsx(be,{children:J.map(s=>e.jsx(Pe,{value:s.companyName,onSelect:()=>{R(s.id),te(!1)},"data-testid":`command-item-client-${s.id}`,children:e.jsxs("div",{className:"flex flex-col flex-1",children:[e.jsx("p",{className:"font-medium",children:s.companyName}),s.contactPerson&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.contactPerson})]})},s.id))})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"validityDays",children:"Validity (Business Days)"}),e.jsx(m,{id:"validityDays",type:"number",min:"1",value:k,onChange:s=>O(parseInt(s.target.value)||5),"data-testid":"input-validity-days"})]})]}),l&&e.jsxs("div",{className:"p-4 bg-muted rounded-md",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Contact:"})," ",l.contactPerson||"N/A"]}),e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Phone:"})," ",l.phoneNumber||"N/A"]}),l.email&&e.jsxs("p",{className:"text-sm",children:[e.jsx("strong",{children:"Email:"})," ",l.email]})]})]}),D&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-4 border border-primary/20 bg-primary/5 rounded-md",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"This quotation is for a one-off customer. Upon approval, a single invoice will be issued â no service agreement or ongoing billing profile is created.":"This quotation is for a new customer. A disclaimer will be included stating that this is subject to a full service agreement with all applicable terms and conditions."})}),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(n,{htmlFor:"prospectCompanyName",children:"Company Name *"}),e.jsx(m,{id:"prospectCompanyName",value:A,onChange:s=>V(s.target.value),placeholder:"Enter company name","data-testid":"input-prospect-company"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n,{htmlFor:"prospectCRNumber",children:["Commercial Registration / Tax ID ",f?"(Optional)":""]}),e.jsx(m,{id:"prospectCRNumber",value:ie,onChange:s=>L(s.target.value),placeholder:"CR or VAT/Tax number","data-testid":"input-prospect-cr-number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"prospectContactPerson",children:"Contact Person"}),e.jsx(m,{id:"prospectContactPerson",value:ne,onChange:s=>U(s.target.value),placeholder:"Enter contact person name","data-testid":"input-prospect-contact"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"prospectEmail",children:"Email Address"}),e.jsx(m,{id:"prospectEmail",type:"email",value:$,onChange:s=>B(s.target.value),placeholder:"Enter email address","data-testid":"input-prospect-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"prospectPhone",children:"Phone Number"}),e.jsx(m,{id:"prospectPhone",value:re,onChange:s=>M(s.target.value),placeholder:"Enter phone number","data-testid":"input-prospect-phone"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"prospectAddress",children:"Company Address"}),e.jsx(X,{id:"prospectAddress",value:oe,onChange:s=>G(s.target.value),placeholder:"Enter company address",rows:2,"data-testid":"input-prospect-address"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"validityDays",children:"Validity (Business Days)"}),e.jsx(m,{id:"validityDays",type:"number",min:"1",value:k,onChange:s=>O(parseInt(s.target.value)||5),"data-testid":"input-validity-days-prospect"})]})})]})]})]}),!f&&e.jsxs(v,{children:[e.jsxs(w,{children:[e.jsx(F,{className:"text-lg sm:text-xl",children:"Quotation Type"}),e.jsx(T,{children:"Choose whether this is a one-time service or a recurring service rate"})]}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs(ve,{value:C,onValueChange:s=>{z(s),s==="one_off"&&le("")},className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start space-x-3 p-4 rounded-lg border hover-elevate cursor-pointer",onClick:()=>z("one_off"),children:[e.jsx(E,{value:"one_off",id:"one_off",className:"mt-1","data-testid":"radio-one-off"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(n,{htmlFor:"one_off",className:"flex items-center gap-2 cursor-pointer font-medium",children:[e.jsx(Be,{className:"h-4 w-4 text-blue-500"}),"One-Off Service"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"A single-use quotation for ad-hoc billing. The customer will be billed once for these services."})]})]}),e.jsxs("div",{className:"flex items-start space-x-3 p-4 rounded-lg border hover-elevate cursor-pointer",onClick:()=>z("service_addendum"),children:[e.jsx(E,{value:"service_addendum",id:"service_addendum",className:"mt-1","data-testid":"radio-service-addendum"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(n,{htmlFor:"service_addendum",className:"flex items-center gap-2 cursor-pointer font-medium",children:[e.jsx(Me,{className:"h-4 w-4 text-green-500"}
1),"Service Agreement Addendum"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Accepted prices become part of the ongoing service agreement. These rates will apply every time the customer uses these services from the effective date onwards."})]})]})]}),C==="service_addendum"&&e.jsxs("div",{className:"space-y-2 p-4 bg-muted rounded-lg",children:[e.jsxs(n,{htmlFor:"effectiveFromDate",className:"flex items-center gap-2",children:[e.jsx(es,{className:"h-4 w-4"}),"Effective From Date *"]}),e.jsx(m,{id:"effectiveFromDate",type:"date",value:K,onChange:s=>le(s.target.value),"data-testid":"input-effective-date",className:"max-w-xs"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The date from which these rates become effective as part of the service agreement."})]})]})]}),e.jsxs(v,{children:[e.jsx(w,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-lg sm:text-xl",children:"Services"}),e.jsx(T,{className:"text-xs sm:text-sm",children:"Add services from catalog or create custom items"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(he,{open:Ae,onOpenChange:ee,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(x,{size:"sm",className:"text-xs sm:text-sm","data-testid":"button-add-from-catalog",children:[e.jsx(fe,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Add from Catalog"}),e.jsx("span",{className:"sm:hidden",children:"Catalog"})]})}),e.jsx(ge,{className:"w-[calc(100vw-2rem)] sm:w-96 p-0",align:"end",children:e.jsxs(je,{children:[e.jsx(ye,{placeholder:"Search services..."}),e.jsxs(Ne,{children:[e.jsx(Ce,{children:"No services found."}),e.jsx(be,{children:Se.map(s=>e.jsx(Pe,{onSelect:()=>{Qe(s),ee(!1)},"data-testid":`command-item-${s.id}`,children:e.jsxs("div",{className:"flex flex-col flex-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s.nameEnglish}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.unitEnglish," ⢠",parseFloat(s.defaultPrice).toFixed(2)," QAR"]})]})},s.id))})]})]})})]}),e.jsxs(x,{variant:"outline",size:"sm",className:"text-xs sm:text-sm",onClick:De,"data-testid":"button-add-custom",children:[e.jsx(ss,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Add Custom Item"}),e.jsx("span",{className:"sm:hidden",children:"Custom"})]})]})]})}),e.jsx(j,{className:"space-y-4",children:u.length===0?e.jsx("div",{className:"p-8 text-center text-muted-foreground",children:'No services added. Click "Add from Catalog" or "Add Custom Item" to get started.'}):e.jsx("div",{className:"space-y-4",children:u.map((s,t)=>e.jsx(v,{className:"hover-elevate",children:e.jsxs(j,{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Item ",t+1]}),e.jsx(x,{size:"icon",variant:"ghost",onClick:()=>Oe(t),"data-testid":`button-remove-${t}`,children:e.jsx(ts,{className:"h-4 w-4"})})]}),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(n,{children:"Description *"}),e.jsx(m,{value:s.descriptionEnglish,onChange:i=>b(t,"descriptionEnglish",i.target.value),placeholder:"Service description","data-testid":`input-desc-en-${t}`})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Unit *"}),e.jsx(m,{value:s.unitEnglish,onChange:i=>b(t,"unitEnglish",i.target.value),placeholder:"e.g., Per CBM","data-testid":`input-unit-en-${t}`})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Unit Price (QAR) *"}),e.jsx(m,{type:"number",min:"0",step:"0.01",value:s.price,onChange:i=>b(t,"price",i.target.value),"data-testid":`input-price-${t}`})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Quantity"}),e.jsx(m,{type:"number",min:"1",step:"1",value:s.quantity,onChange:i=>b(t,"quantity",i.target.value),"data-testid":`input-quantity-${t}`})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Final Total (QAR)"}),e.jsx(m,{type:"number",min:"0",step:"0.01",value:s.finalTotal,onChange:i=>b(t,"finalTotal",i.target.value),onBlur:()=>Re(t),"data-testid":`input-final-total-${t}`})]})]})]})},t))})})]}),e.jsxs(v,{children:[e.jsxs(w,{children:[e.jsx(F,{children:"Terms & Conditions"}),e.jsx(T,{children:"Optional. Anything you enter here will appear on the customer's approval link and in the generated PDF. Leave blank to omit."})]}
1),e.jsx(j,{children:e.jsx(X,{value:_,onChange:s=>Z(s.target.value),placeholder:"e.g. Payment terms: 50% advance, 50% on delivery. Quotation valid for 15 days...",rows:6,"data-testid":"textarea-custom-terms"})})]}),e.jsxs(v,{children:[e.jsx(w,{children:e.jsx(F,{children:"Additional Notes"})}),e.jsx(j,{children:e.jsx(X,{value:Ee,onChange:s=>qe(s.target.value),placeholder:"Optional internal notes...",rows:4,"data-testid":"textarea-notes"})})]}),e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row gap-2 sm:justify-end",children:[e.jsx(x,{variant:"outline",className:"w-full sm:w-auto",onClick:()=>S("/quotations"),"data-testid":"button-cancel",children:"Cancel"}),e.jsxs(x,{className:"w-full sm:w-auto",onClick:_e,disabled:ce.isPending,"data-testid":"button-create-quotation",children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Create Ad-hoc Quotation"]})]}),e.jsx(Ge,{open:Te,onOpenChange:s=>{s||de()},children:e.jsxs(ze,{children:[e.jsxs(Ke,{children:[e.jsxs(He,{className:"flex items-center gap-2",children:[e.jsx(as,{className:"h-5 w-5"}),"Confirm Calculated Quantity"]}),e.jsx(Je,{children:"Based on the Final Total you entered, the system has calculated a quantity. Please confirm or adjust it."})]}),d&&e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Unit Price:"}),e.jsxs("p",{className:"font-medium",children:[d.unitPrice.toFixed(2)," QAR"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Entered Final Total:"}),e.jsxs("p",{className:"font-medium",children:[parseFloat(d.finalTotal).toFixed(2)," QAR"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{children:"Calculated Quantity"}),e.jsx(m,{type:"number",min:"0.0001",step:"any",value:d.editableQty,onChange:s=>I({...d,editableQty:s.target.value}),"data-testid":"input-confirm-quantity"}),d.editableQty!==d.calculatedQty&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["System suggested: ",d.calculatedQty," â Final Total will update to ",(d.unitPrice*(parseFloat(d.editableQty)||0)).toFixed(2)," QAR"]})]})]}),e.jsxs(We,{className:"gap-2",children:[e.jsx(x,{variant:"outline",onClick:de,"data-testid":"button-cancel-qty",children:"Cancel"}),e.jsx(x,{onClick:ke,"data-testid":"button-confirm-qty",children:"Confirm Quantity"})]})]})})]})}export{xs 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.