PageSourceSearch

https://amuze.vercel.app/assets/QuotationPreviewPage-71bcb61d.js

js amuze.vercel.app collected 2026-10-03 06:16:20 UTC 8,592 bytes, 1 lines download raw bytes

1import{h as K,j as t,L as v}from"./router-c36739b0.js";import{r as x}from"./react-vendor-2b9b67e4.js";import{M as _,C as W,a as X}from"./ModernTemplate-83ffc28f.js";import{S as q}from"./SendDocumentModal-f24f8578.js";import{bi as ee,bg as ae,z as te,bj as ne,au as se,av as re,J as oe,bh as U,S as ie,V as de}from"./index-5a102d2c.js";import{u as ce}from"./settings.hooks-9957e19e.js";import{d as le}from"./pdf-b74d120a.js";import{P as me}from"./PencilSquareIcon-b728df80.js";import{A as ue}from"./ArrowDownTrayIcon-40c92b75.js";import"./forms-0f3a8dd8.js";import"./charts-260c3602.js";import"./animation-b71d3bd1.js";const w="quotation-print-area",pe=n=>"R "+n.toLocaleString("en-ZA",{minimumFractionDigits:2,maximumFractionDigits:2});function xe(n,s){var c,l,e,r,m;return{documentType:"quotation",documentNumber:n.quotationNumber,date:n.date,dueDate:n.validUntil,status:n.status,company:s,client:{name:((c=n.client)==null?void 0:c.name)??"",company:(l=n.client)==null?void 0:l.company,email:((e=n.client)==null?void 0:e.email)??"",phone:(r=n.client)==null?void 0:r.phone,address:(m=n.client)==null?void 0:m.address},lineItems:n.lineItems,subtotal:n.subtotal,discountPercentage:n.discountPercentage,discountAmount:n.discountAmount,taxRate:n.taxRate,taxAmount:n.taxAmount,total:n.total,notes:n.notes,paymentTerms:n.paymentTerms,currency:"ZAR"}}const ge=[{value:"draft",label:"Draft"},{value:"sent",label:"Sent"},{value:"accepted",label:"Accepted"},{value:"rejected",label:"Rejected"}],be={draft:"bg-gray-900 text-white dark:bg-white dark:text-gray-900",sent:"bg-brand-600 text-white",accepted:"bg-gray-600 text-white",rejected:"bg-brand-600 text-white"},ye={draft:"bg-gray-400",sent:"bg-brand-500",accepted:"bg-gray-500",rejected:"bg-brand-500"};function Ae(){var T,k,D,P,A,E,C,Q,F,R;const{quotationId:n}=ee.useParams(),{data:s,isLoading:c,error:l}=ae(n),{data:e}=ce(),{toast:r}=te(),m=K(),g=ne(),S=se(),j=re(),b=x.useRef(!1),[u]=x.useState(()=>localStorage.getItem("preferred-template")||"modern"),[z,y]=x.useState(!1),[f,N]=x.useState(!1);if(c)return t.jsx(oe,{label:"Loading quotation"});if(l||!s)return t.jsxs("div",{className:"mx-4 mt-6 flex flex-col items-center justify-center rounded-xl border border-gray-200 p-12 text-center dark:border-gray-700 sm:mx-6",children:[t.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Quotation not found"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"The quotation you are looking for does not exist or could not be loaded."}),t.jsxs(v,{to:"/dashboard/quotations",className:"mt-4 flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700",children:[t.jsx(U,{className:"h-4 w-4"}),"Back to Quotations"]})]});const I={name:((T=e==null?void 0:e.company)==null?void 0:T.companyName)??"Your Company",email:((k=e==null?void 0:e.company)==null?void 0:k.email)??"",phone:(D=e==null?void 0:e.company)==null?void 0:D.phone,address:(P=e==null?void 0:e.company)!=null&&P.address?`${e.company.address}${e.company.city?`, ${e.company.city}`:""}${e.company.state?`, ${e.company.state}`:""}${e.company.zip?` ${e.company.zip}`:""}`:void 0,logoInitials:((A=e==null?void 0:e.company)==null?void 0:A.logoInitials)??"CO",taxId:(E=e==null?void 0:e.company)==null?void 0:E.taxId},B=((C=e==null?void 0:e.documents)==null?void 0:C.defaultNotes)||localStorage.getItem("default-notes")||void 0,V=((Q=e==null?void 0:e.documents)==null?void 0:Q.defaultTerms)||localStorage.getItem("default-terms-and-conditions")||void 0,h=xe(s,I),p={...h,notes:h.notes||B,paymentTerms:h.paymentTerms||V},Z=async()=>{N(!0);try{await le(w,`Quotation-${s.quotationNumber}`),r("PDF downloaded","success")}catch{r("Failed to generate PDF","error")}finally{N(!1)}},G=a=>{var $,O,M,L;if(b.current)return;b.current=!0;const o=new Date().toISOString().slice(0,10),i=new Date;i.setDate(i.getDate()+30);const H=i.toISOString().slice(0,10);j.mutate({client:(($=a.client)==null?void 0:$.name)??"",clientId:(O=a.client)==null?void 0:O.id,clientAddress:(M=a.client)==null?void 0:M.address,clientVatNumber:(L=a.client)==null?void 0:L.vatNumber,clientData:a.client?{id:a.client.id,name:a.client.name,company:a.client.company,email:a.client.email,phone:a.client.phone,address:a.client.address}:null,date:o,dueDate:H,status:"pending",lineItems:(a.lineItems??[]).map(d=>({name:d.name,description:d.description,quantity:d.quantity,unitPrice:d.unitPrice})),taxRate:a.taxRate,notes:a.notes,paymentTerms:a.paymentTerms,quotationId:a.id},{onSuccess:d=>{r("Invoice created from quotation","success"),m({to:"/dashboard/invoices/$invoiceId",params:{invoiceId:d.id}})},onError:()=>{b.current=!1,r("Failed to auto-create invoice","error")}})},J=a=>{if(!s||a===s.status)return;const o=s.status==="accepted";S.mutate({id:n,updates:{status:a}},{onSuccess:()=>{r(`Status changed to ${a}`,"success"),a==="accepted"&&!o&&G(s)},onError:()=>{r("Failed to update status","error")}})},Y=a=>{g.mutate({id:n,recipientEmail:a.recipientEmail,subject:a.subject,message:a.message,pdfBase64:a.pdfBase64,pdfFilename:a.pdfFilename},{onSuccess:()=>{r("Quotation sent","success"),y(!1)},onError:()=>{r("Failed to send quotation","error")}})};return t.jsxs("div",{className:"p-4 pb-28 sm:p-6 sm:pb-28",children:[t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs(v,{to:"/dashboard/quotations",className:"flex items-center gap-2 py-1 text-sm font-medium text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white",children:[t.jsx(U,{className:"h-4 w-4"}),"Back to Quotations"]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[t.jsxs(v,{to:"/dashboard/quotations/create",search:{editId:n},className:"flex min-h-[44px] items-center gap-2 rounded-lg border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700",children:[t.jsx(me,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Edit"})]}),t.jsxs("button",{onClick:Z,disabled:f,"aria-label":"Download PDF",className:"flex min-h-[44px] items-center gap-2 rounded-lg border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700",children:[f?t.jsx(ie,{size:"xs"}):t.jsx(ue,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:f?"Generating...":"Download PDF"})]}),t.jsxs("button",{onClick:()=>y(!0),disabled:g.isPending,"aria-label":"Send Quotation",className:"flex min-h-[44px] items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50",children:[t.jsx(de,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Send Quotation"})]})]})]}),t.jsxs("div",{className:"mt-4 flex items-center gap-2 overflow-x-auto",children:[t.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Status"}),t.jsx("div",{role:"radiogroup","aria-label":"Quotation status",className:"inline-flex items-center gap-0.5 rounded-full bg-gray-100 p-0.5 dark:bg-gray-800",children:ge.map(a=>{const o=a.value===s.status,i=S.isPending||j.isPending;return t.jsxs("button",{type:"button",role:"radio","aria-checked":o,disabled:i||o,onClick:()=>
1J(a.value),className:`flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-semibold transition-all duration-150 disabled:cursor-not-allowed ${o?be[a.value]+" shadow-sm":"text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white "+(i?"opacity-50":"")}`,children:[t.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${o?"bg-white/80":ye[a.value]}`}),a.label]},a.value)})})]}),t.jsx("div",{className:"mt-6 overflow-x-auto rounded-xl border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800 sm:p-6",children:t.jsxs("div",{id:w,className:"mx-auto max-w-[800px]",children:[u==="modern"&&t.jsx(_,{data:p}),u==="classic"&&t.jsx(W,{data:p}),u==="minimal"&&t.jsx(X,{data:p}),u==="custom"&&t.jsx(_,{data:p})]})}),t.jsx(q,{isOpen:z,onClose:()=>y(!1),documentType:"quotation",documentNumber:s.quotationNumber,clientName:((F=s.client)==null?void 0:F.name)??"",clientEmail:((R=s.client)==null?void 0:R.email)??"",companyName:I.name,dueDate:s.validUntil,total:pe(s.total),printElementId:w,emailTemplates:e==null?void 0:e.emailTemplates,onSend:Y,isSending:g.isPending})]})}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.