umwd-components 0.1.810 → 0.1.811
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@mui/material/IconButton"),s=require("@mui/material/Dialog"),n=require("@mui/material/DialogContent"),r=require("@mui/material/DialogActions"),o=require("@mui/material/Button"),l=require("@mui/material/CircularProgress"),c=require("@mui/icons-material/PictureAsPdf");const d=()=>{const[e,i]=t.useState(null),[s,n]=t.useState(!0),[r,o]=t.useState(null);return t.useEffect(()=>{let e=!0;return(async()=>{try{const t=await import("@react-pdf/renderer");e&&(i(t),n(!1))}catch(t){console.error("Failed to load PDF renderer:",t),e&&(o("Failed to load PDF components"),n(!1))}})(),()=>{e=!1}},[]),{pdfComponents:e,loading:s,error:r}},x=(e,t,i="")=>t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:i,e),h=({props:i})=>{const{invoice:s}=i,{pdfComponents:n,loading:r,error:o}=d();if(r)return e.jsx(l,{});if(o)return e.jsxs("div",{children:["Error loading PDF components: ",o]});if(!n)return e.jsx("div",{children:"PDF components not available"});if(!s)return e.jsx("div",{children:"No invoice data provided"});const{Document:c,Page:h,View:j,Text:y,StyleSheet:p}=n,a=(e=>e.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontWeight:"bold"},h3:{fontSize:16,fontWeight:"bold"}}))(p),{seller_business_credentials:u,seller_company_address:m,buyer_company_address:S,buyer_business_credentials:_,type:f}=s;return"credit"===f?e.jsx(c,{title:`credit_${x(s,"invoice_number","unknown")}`,children:e.jsxs(h,{size:"A4",style:a.page,children:[e.jsx(j,{style:a.header,children:e.jsx(y,{style:a.h1,children:x(u,"company_name")})}),e.jsx(j,{style:a.section,children:e.jsx(y,{style:a.h2,children:"CREDIT NOTE"})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:x(_,"company_name")}),e.jsxs(y,{children:[x(s,"buyer_first_name")," ",x(s,"buyer_last_name")]}),e.jsxs(y,{children:[x(S,"street")," ",x(S,"street_number")," ",x(S,"street_number_addition")]}),e.jsxs(y,{children:[x(S,"postal_code")," ",x(S,"city")]})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"FROM"}),e.jsx(y,{children:x(u,"company_name")}),e.jsxs(y,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(y,{children:[x(m,"postal_code")," ",x(m,"city")]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:x(u,"coc_number")}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:x(u,"vat_number")})]})]})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:x(s,"invoice_number")})]}),x(s,"customer_reference")&&e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:x(s,"customer_reference")})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:x(s,"invoice_date")})]})]})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"SUMMARY"}),e.jsxs(j,{style:a.row,children:[s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.length>0&&e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items&&Array.isArray(s.items)&&s.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`credit-item-${s}`)),s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`credit-admin-item-${s}`))]}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"TOTALS"}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"VAT_total",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(j,{style:a.section,children:e.jsxs(y,{style:{...a.h3,border:"2px solid black",padding:10},children:["Total: € ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})}):"proforma"===f?e.jsx(c,{title:`proforma_${x(s,"invoice_number","unknown")}`,children:e.jsxs(h,{size:"A4",style:a.page,children:[e.jsx(j,{style:a.header,children:e.jsx(y,{style:a.h1,children:x(u,"company_name")})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h2,children:"PROFORMA INVOICE"}),e.jsx(y,{style:{fontSize:10,marginTop:5},children:"This is not a final invoice and cannot be used for tax purposes"})]}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:x(_,"company_name")}),e.jsxs(y,{children:[x(s,"buyer_first_name")," ",x(s,"buyer_last_name")]}),e.jsxs(y,{children:[x(S,"street")," ",x(S,"street_number")," ",x(S,"street_number_addition")]}),e.jsxs(y,{children:[x(S,"postal_code")," ",x(S,"city")]})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"FROM"}),e.jsx(y,{children:x(u,"company_name")}),e.jsxs(y,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(y,{children:[x(m,"postal_code")," ",x(m,"city")]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:x(u,"coc_number")}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:x(u,"vat_number")})]})]})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:x(s,"invoice_number")})]}),x(s,"customer_reference")&&e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:x(s,"customer_reference")})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:x(s,"invoice_date")})]})]})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"SUMMARY"}),e.jsxs(j,{style:a.row,children:[s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.length>0&&e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items&&Array.isArray(s.items)&&s.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`proforma-item-${s}`)),s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`proforma-admin-item-${s}`))]}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"TOTALS"}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"VAT_total",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(j,{style:a.section,children:e.jsxs(y,{style:{...a.h3,border:"2px solid black",padding:10},children:["Total Due: € ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})}):e.jsx(c,{title:`invoice_${x(s,"invoice_number","unknown")}`,children:e.jsxs(h,{size:"A4",style:a.page,children:[e.jsx(j,{style:a.header,children:e.jsx(y,{style:a.h1,children:x(u,"company_name")})}),e.jsx(j,{style:a.section,children:e.jsx(y,{style:a.h2,children:"INVOICE"})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:x(_,"company_name")}),e.jsxs(y,{children:[x(s,"buyer_first_name")," ",x(s,"buyer_last_name")]}),e.jsxs(y,{children:[x(S,"street")," ",x(S,"street_number")," ",x(S,"street_number_addition")]}),e.jsxs(y,{children:[x(S,"postal_code")," ",x(S,"city")]})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:a.h3,children:"FROM"}),e.jsx(y,{children:x(u,"company_name")}),e.jsxs(y,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(y,{children:[x(m,"postal_code")," ",x(m,"city")]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:x(u,"coc_number")}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:x(u,"vat_number")})]})]})}),e.jsx(j,{style:a.section,children:e.jsxs(j,{style:a.row,children:[e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:x(s,"invoice_number")})]}),x(s,"customer_reference")&&e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:x(s,"customer_reference")})]}),e.jsxs(j,{style:a.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:x(s,"invoice_date")})]})]})}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"SUMMARY"}),e.jsxs(j,{style:a.row,children:[s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.length>0&&e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items&&Array.isArray(s.items)&&s.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(y,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`invoice-item-${s}`)),s?.admin_items&&Array.isArray(s.admin_items)&&s.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`invoice-admin-item-${s}`))]}),e.jsxs(j,{style:a.section,children:[e.jsx(y,{style:a.h3,children:"TOTALS"}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:a.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:a.row,children:[e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"VAT_total",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(j,{style:a.productRowSection,children:e.jsxs(y,{children:["€ ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(j,{style:a.section,children:e.jsxs(y,{style:{...a.h3,border:"2px solid black",padding:10},children:["Total Due: € ",x(s,"total_incl_vat",0)?.toFixed(2)]})})]})})};exports.InvoiceDownloadLink=function({invoice:t}){const{pdfComponents:s,loading:n,error:r}=d();if(n||r||!s||!t)return e.jsx(i,{disabled:!0,children:e.jsx(l,{size:20})});const{PDFDownloadLink:o}=s;try{return e.jsx(o,{document:e.jsx(h,{props:{invoice:t}}),fileName:`invoice_${x(t,"invoice_number","unknown")}`,children:e.jsx(i,{children:e.jsx(c,{})})},Date.now())}catch(t){return console.error("Error creating PDF download link:",t),e.jsx(i,{disabled:!0,children:e.jsx(c,{})})}},exports.InvoicePDFViewer=function({invoice:x}){const[j,y]=t.useState(!1),[p,a]=t.useState(null),{pdfComponents:u,loading:m,error:S}=d();if(m||S||!u||!x)return e.jsx(i,{disabled:!0,children:e.jsx(l,{size:20})});const{PDFViewer:_}=u;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>{a(null),y(!0)},children:e.jsx(c,{})}),e.jsxs(s,{open:j,fullWidth:!0,maxWidth:"lg",children:[e.jsx(n,{children:p?e.jsxs("div",{children:["Error rendering PDF: ",p]}):e.jsx(_,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(h,{props:{invoice:x}})},Date.now())}),e.jsx(r,{children:e.jsx(o,{variant:"contained",onClick:()=>y(!1),children:"Close"})})]})]})},exports.default=h;
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/IconButton"),n=require("@mui/material/Dialog"),o=require("@mui/material/DialogContent"),t=require("@mui/material/DialogActions"),s=require("@mui/material/Button"),l=require("@mui/material/CircularProgress"),c=require("@mui/icons-material/PictureAsPdf");const d=()=>{const[e,i]=r.useState(null),[n,o]=r.useState(!0),[t,s]=r.useState(null);return r.useEffect(()=>{let e=!0;return(async()=>{try{const r=await import("@react-pdf/renderer");e&&(i(r),o(!1))}catch(r){console.error("Failed to load PDF renderer:",r),e&&(s("Failed to load PDF components"),o(!1))}})(),()=>{e=!1}},[]),{pdfComponents:e,loading:n,error:t}},a=(e,r,i="")=>r.split(".").reduce((e,r)=>e&&void 0!==e[r]?e[r]:i,e),u=({props:r})=>{const{invoice:i}=r,{pdfComponents:n,loading:o,error:t}=d();if(o)return e.jsx(l,{});if(t)return e.jsxs("div",{children:["Error loading PDF components: ",t]});if(!n)return e.jsx("div",{children:"PDF components not available"});if(!i)return e.jsx("div",{children:"No invoice data provided"});const{Document:s,Page:c,View:a,Text:u,StyleSheet:h}=n,x=(e=>e.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontWeight:"bold"},h3:{fontSize:16,fontWeight:"bold"}}))(h),{seller_business_credentials:m,seller_company_address:p,buyer_company_address:f,buyer_business_credentials:j,type:g}=i;return e.jsx(s,{children:e.jsx(c,{size:"A4",style:x.page,children:e.jsx(a,{style:x.header,children:e.jsx(u,{style:x.h1,children:"Test Invoice PDF"})})})})};exports.InvoiceDownloadLink=function({invoice:r}){const{pdfComponents:n,loading:o,error:t}=d();if(o||t||!n||!r)return e.jsx(i,{disabled:!0,children:e.jsx(l,{size:20})});const{PDFDownloadLink:s}=n;try{return e.jsx(s,{document:e.jsx(u,{props:{invoice:r}}),fileName:`invoice_${a(r,"invoice_number","unknown")}`,children:e.jsx(i,{children:e.jsx(c,{})})},Date.now())}catch(r){return console.error("Error creating PDF download link:",r),e.jsx(i,{disabled:!0,children:e.jsx(c,{})})}},exports.InvoicePDFViewer=function({invoice:a}){const[h,x]=r.useState(!1),[m,p]=r.useState(null),{pdfComponents:f,loading:j,error:g}=d();if(j||g||!f||!a)return e.jsx(i,{disabled:!0,children:e.jsx(l,{size:20})});const{PDFViewer:v}=f;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>{p(null),x(!0)},children:e.jsx(c,{})}),e.jsxs(n,{open:h,fullWidth:!0,maxWidth:"lg",children:[e.jsx(o,{children:m?e.jsxs("div",{children:["Error rendering PDF: ",m]}):e.jsx(v,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(u,{props:{invoice:a}})},Date.now())}),e.jsx(t,{children:e.jsx(s,{variant:"contained",onClick:()=>x(!1),children:"Close"})})]})]})},exports.default=u;
|