2 lines
6.4 KiB
JavaScript
2 lines
6.4 KiB
JavaScript
import{j as s,A as c,c as i,f as d,b as a,R as m,a as x}from"./styles-CphAgR3l.js";function g({invoice:e}){const h=i(e.status||""),l=e.currency||"USD",n=t=>{if(!t)return null;const r=[t.address,t.city,t.state,t.postalCode,t.country].filter(Boolean);return r.length>0?r.join(", "):null};return s.jsx("div",{className:"ghl-app",children:s.jsxs("div",{className:"ghl-card",children:[s.jsx("div",{className:"ghl-card-header",style:{background:"var(--ghl-bg)"},children:s.jsxs("div",{className:"ghl-flex ghl-justify-between ghl-items-center",children:[s.jsxs("div",{className:"ghl-flex ghl-items-center ghl-gap-4",children:[e.businessDetails?.logoUrl&&s.jsx("img",{src:e.businessDetails.logoUrl,alt:"Logo",style:{height:48,width:"auto",objectFit:"contain"}}),s.jsxs("div",{children:[s.jsx("h1",{style:{fontSize:24,fontWeight:700,color:"var(--ghl-text)"},children:"INVOICE"}),s.jsxs("p",{className:"ghl-text-muted",children:["#",e.invoiceNumber||e._id||e.id]})]})]}),s.jsx("div",{className:`ghl-badge ghl-badge-${h}`,style:{fontSize:14,padding:"6px 16px"},children:e.status?.toUpperCase()||"DRAFT"})]})}),s.jsxs("div",{className:"ghl-card-body",children:[s.jsxs("div",{className:"ghl-grid ghl-grid-2",style:{marginBottom:24},children:[s.jsxs("div",{children:[s.jsx("h3",{className:"ghl-text-sm ghl-text-muted",style:{marginBottom:8},children:"FROM"}),e.businessDetails?s.jsxs("div",{children:[s.jsx("div",{className:"ghl-font-semibold",children:e.businessDetails.name}),n(e.businessDetails)&&s.jsx("div",{className:"ghl-text-sm ghl-text-secondary",style:{marginTop:4},children:n(e.businessDetails)}),e.businessDetails.email&&s.jsx("div",{className:"ghl-text-sm ghl-text-secondary",children:e.businessDetails.email}),e.businessDetails.phone&&s.jsx("div",{className:"ghl-text-sm ghl-text-secondary",children:e.businessDetails.phone})]}):s.jsx("span",{className:"ghl-text-muted",children:"Not specified"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"ghl-text-sm ghl-text-muted",style:{marginBottom:8},children:"BILL TO"}),e.contactDetails?s.jsxs("div",{children:[s.jsx("div",{className:"ghl-font-semibold",children:e.contactDetails.name||e.contactDetails.companyName}),e.contactDetails.companyName&&e.contactDetails.name&&s.jsx("div",{className:"ghl-text-sm ghl-text-secondary",children:e.contactDetails.companyName}),n(e.contactDetails)&&s.jsx("div",{className:"ghl-text-sm ghl-text-secondary",style:{marginTop:4},children:n(e.contactDetails)}),e.contactDetails.email&&s.jsx("div",{className:"ghl-text-sm ghl-text-secondary",children:e.contactDetails.email})]}):s.jsx("span",{className:"ghl-text-muted",children:"Not specified"})]})]}),s.jsxs("div",{className:"ghl-grid ghl-grid-3",style:{marginBottom:24},children:[s.jsxs("div",{children:[s.jsx("span",{className:"ghl-text-sm ghl-text-muted",children:"Issue Date"}),s.jsx("div",{className:"ghl-font-medium",children:d(e.issueDate)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"ghl-text-sm ghl-text-muted",children:"Due Date"}),s.jsx("div",{className:"ghl-font-medium",children:d(e.dueDate)})]}),e.paidAt&&s.jsxs("div",{children:[s.jsx("span",{className:"ghl-text-sm ghl-text-muted",children:"Paid Date"}),s.jsx("div",{className:"ghl-font-medium",style:{color:"var(--ghl-success)"},children:d(e.paidAt)})]})]}),s.jsx("div",{style:{marginBottom:24},children:s.jsxs("table",{className:"ghl-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"50%"},children:"Item"}),s.jsx("th",{style:{textAlign:"center"},children:"Qty"}),s.jsx("th",{style:{textAlign:"right"},children:"Price"}),s.jsx("th",{style:{textAlign:"right"},children:"Amount"})]})}),s.jsx("tbody",{children:e.invoiceItems&&e.invoiceItems.length>0?e.invoiceItems.map((t,r)=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("div",{className:"ghl-font-medium",children:t.name||"Item"}),t.description&&s.jsx("div",{className:"ghl-text-sm ghl-text-muted",children:t.description})]}),s.jsx("td",{style:{textAlign:"center"},children:t.quantity||1}),s.jsx("td",{style:{textAlign:"right"},children:a(t.price,l)}),s.jsx("td",{style:{textAlign:"right"},children:a(t.amount,l)})]},r)):s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"ghl-text-muted",style:{textAlign:"center"},children:"No items"})})})]})}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsxs("div",{style:{width:280},children:[s.jsxs("div",{className:"ghl-flex ghl-justify-between",style:{padding:"8px 0"},children:[s.jsx("span",{className:"ghl-text-muted",children:"Subtotal"}),s.jsx("span",{children:a(e.subTotal,l)})]}),e.discount&&e.discount>0&&s.jsxs("div",{className:"ghl-flex ghl-justify-between",style:{padding:"8px 0"},children:[s.jsx("span",{className:"ghl-text-muted",children:"Discount"}),s.jsxs("span",{style:{color:"var(--ghl-success)"},children:["-",a(e.discount,l)]})]}),e.taxAmount&&e.taxAmount>0&&s.jsxs("div",{className:"ghl-flex ghl-justify-between",style:{padding:"8px 0"},children:[s.jsx("span",{className:"ghl-text-muted",children:"Tax"}),s.jsx("span",{children:a(e.taxAmount,l)})]}),s.jsxs("div",{className:"ghl-flex ghl-justify-between",style:{padding:"12px 0",marginTop:8,borderTop:"2px solid var(--ghl-border)"},children:[s.jsx("span",{className:"ghl-font-semibold",children:"Total"}),s.jsx("span",{className:"ghl-font-semibold",style:{fontSize:18},children:a(e.totalAmount,l)})]}),e.amountDue!==void 0&&e.amountDue!==e.totalAmount&&s.jsxs("div",{className:"ghl-flex ghl-justify-between",style:{padding:"12px 16px",marginTop:8,background:e.amountDue===0?"rgba(34, 197, 94, 0.1)":"rgba(239, 68, 68, 0.1)",borderRadius:"var(--ghl-radius)"},children:[s.jsx("span",{className:"ghl-font-semibold",children:"Amount Due"}),s.jsx("span",{className:"ghl-font-semibold",style:{fontSize:18,color:e.amountDue===0?"var(--ghl-success)":"var(--ghl-danger)"},children:a(e.amountDue,l)})]}),e.amountPaid!==void 0&&e.amountPaid>0&&s.jsxs("div",{className:"ghl-flex ghl-justify-between",style:{padding:"8px 0",marginTop:8},children:[s.jsx("span",{className:"ghl-text-muted",children:"Amount Paid"}),s.jsx("span",{style:{color:"var(--ghl-success)"},children:a(e.amountPaid,l)})]})]})})]}),s.jsx("div",{className:"ghl-card-footer",children:s.jsxs("div",{className:"ghl-flex ghl-justify-between ghl-items-center ghl-text-sm ghl-text-muted",children:[s.jsxs("span",{children:["Created: ",d(e.createdAt),e.updatedAt&&` | Updated: ${d(e.updatedAt)}`]}),e.sentAt&&s.jsxs("span",{children:["Sent: ",d(e.sentAt)]})]})})]})})}function o(){return s.jsx(c,{children:e=>s.jsx(g,{invoice:e})})}m.createRoot(document.getElementById("root")).render(x.createElement(o));
|