umwd-components 0.1.807 → 0.1.809

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"),l=require("@mui/material/DialogActions"),c=require("@mui/material/Button"),o=require("@mui/material/CircularProgress"),r=require("@mui/icons-material/PictureAsPdf");let d=null;const x=async()=>("undefined"==typeof window||d||(d=await import("@react-pdf/renderer")),d),h=({props:i})=>{const{invoice:s}=i,[n,l]=t.useState(null),[c,r]=t.useState(null);if(t.useEffect(()=>{(async()=>{const e=await x();e&&(l(e),r(e.StyleSheet.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"}})))})()},[]),!n||!c)return e.jsx(o,{});const{Document:d,Page:h,View:j,Text:y}=n,{seller_business_credentials:p,seller_company_address:a,buyer_company_address:u,buyer_business_credentials:S,type:_,invoice_number:f}=s;console.log("type",_);return"credit"===_?e.jsx(d,{title:`credit_${s?.invoice_number}`,children:e.jsxs(h,{size:"A4",style:c.page,children:[e.jsx(j,{style:c.header,children:e.jsx(y,{style:c.h1,children:p?.company_name})}),e.jsx(j,{style:c.section,children:e.jsx(y,{style:c.h2,children:"CREDIT NOTE"})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:S?.company_name}),e.jsxs(y,{children:[s?.buyer_first_name," ",s?.buyer_last_name]}),e.jsxs(y,{children:[u?.street," ",u?.street_number," ",u?.street_number_addition]}),e.jsxs(y,{children:[u?.postal_code," ",u?.city]})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"FROM"}),e.jsx(y,{children:p?.company_name}),e.jsxs(y,{children:[a?.street," ",a?.street_number," ",a?.street_number_addition]}),e.jsxs(y,{children:[a?.postal_code," ",a?.city]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:p?.coc_number}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:p?.vat_number})]})]})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:s?.invoice_number})]}),s?.customer_reference&&e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:s?.customer_reference})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:s?.invoice_date})]})]})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"SUMMARY"}),e.jsxs(j,{style:c.row,children:[s?.admin_items?.length>0&&e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["product_title"in i&&i.product_title,"item_description"in i&&i.item_description]})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i.vat_rate," %"]})}),e.jsx(j,{style:c.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:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_incl_vat?.toFixed(2)]})})]})},s)),s?.admin_items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.line_item_number})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.description})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i?.price?.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price_incl_vat?.toFixed(2)]})})]})},s))]}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"TOTALS"}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.VAT_total?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_incl_vat?.toFixed(2)]})})]})]}),e.jsx(j,{style:c.section,children:e.jsxs(y,{style:{...c.h3,border:"2px solid black",padding:10},children:["Total: € ",s?.total_incl_vat?.toFixed(2)]})})]})}):"proforma"===_?e.jsx(d,{title:`proforma_${s?.invoice_number}`,children:e.jsxs(h,{size:"A4",style:c.page,children:[e.jsx(j,{style:c.header,children:e.jsx(y,{style:c.h1,children:p?.company_name})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.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:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:S?.company_name}),e.jsxs(y,{children:[s?.buyer_first_name," ",s?.buyer_last_name]}),e.jsxs(y,{children:[u?.street," ",u?.street_number," ",u?.street_number_addition]}),e.jsxs(y,{children:[u?.postal_code," ",u?.city]})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"FROM"}),e.jsx(y,{children:p?.company_name}),e.jsxs(y,{children:[a?.street," ",a?.street_number," ",a?.street_number_addition]}),e.jsxs(y,{children:[a?.postal_code," ",a?.city]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:p?.coc_number}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:p?.vat_number})]})]})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:s?.invoice_number})]}),s?.customer_reference&&e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:s?.customer_reference})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:s?.invoice_date})]})]})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"SUMMARY"}),e.jsxs(j,{style:c.row,children:[s?.admin_items?.length>0&&e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["product_title"in i&&i.product_title,"item_description"in i&&i.item_description]})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i.vat_rate," %"]})}),e.jsx(j,{style:c.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:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_incl_vat?.toFixed(2)]})})]})},s)),s?.admin_items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.line_item_number})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.description})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i?.price?.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price_incl_vat?.toFixed(2)]})})]})},s))]}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"TOTALS"}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.VAT_total?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_incl_vat?.toFixed(2)]})})]})]}),e.jsx(j,{style:c.section,children:e.jsxs(y,{style:{...c.h3,border:"2px solid black",padding:10},children:["Total Due: € ",s?.total_incl_vat?.toFixed(2)]})})]})}):e.jsx(d,{title:`invoice_${s?.invoice_number}`,children:e.jsxs(h,{size:"A4",style:c.page,children:[e.jsx(j,{style:c.header,children:e.jsx(y,{style:c.h1,children:p?.company_name})}),e.jsx(j,{style:c.section,children:e.jsx(y,{style:c.h2,children:"INVOICE"})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"BILLING DETAILS"}),e.jsx(y,{children:S?.company_name}),e.jsxs(y,{children:[s?.buyer_first_name," ",s?.buyer_last_name]}),e.jsxs(y,{children:[u?.street," ",u?.street_number," ",u?.street_number_addition]}),e.jsxs(y,{children:[u?.postal_code," ",u?.city]})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:c.h3,children:"FROM"}),e.jsx(y,{children:p?.company_name}),e.jsxs(y,{children:[a?.street," ",a?.street_number," ",a?.street_number_addition]}),e.jsxs(y,{children:[a?.postal_code," ",a?.city]}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(y,{children:p?.coc_number}),e.jsx(y,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(y,{children:p?.vat_number})]})]})}),e.jsx(j,{style:c.section,children:e.jsxs(j,{style:c.row,children:[e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(y,{children:s?.invoice_number})]}),s?.customer_reference&&e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(y,{children:s?.customer_reference})]}),e.jsxs(j,{style:c.rowSection,children:[e.jsx(y,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(y,{children:s?.invoice_date})]})]})}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"SUMMARY"}),e.jsxs(j,{style:c.row,children:[s?.admin_items?.length>0&&e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),s?.items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["product_title"in i&&i.product_title,"item_description"in i&&i.item_description]})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i.vat_rate," %"]})}),e.jsx(j,{style:c.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:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i.price_incl_vat?.toFixed(2)]})})]})},s)),s?.admin_items?.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.line_item_number})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.description})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontSize:"10px"},children:i.quantity})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:[i?.price?.vat_rate," %"]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{style:{fontSize:"10px"},children:["€ ",i?.price?.price_incl_vat?.toFixed(2)]})})]})},s))]}),e.jsxs(j,{style:c.section,children:[e.jsx(y,{style:c.h3,children:"TOTALS"}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(j,{style:c.productRowSection,children:e.jsx(y,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(j,{style:c.row,children:[e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.VAT_total?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_excl_vat?.toFixed(2)]})}),e.jsx(j,{style:c.productRowSection,children:e.jsxs(y,{children:["€ ",s?.total_incl_vat?.toFixed(2)]})})]})]}),e.jsx(j,{style:c.section,children:e.jsxs(y,{style:{...c.h3,border:"2px solid black",padding:10},children:["Total Due: € ",s?.total_incl_vat?.toFixed(2)]})})]})})};exports.InvoiceDownloadLink=function({invoice:s}){const[n,l]=t.useState(null);if(t.useEffect(()=>{(async()=>{const e=await x();l(e)})()},[]),!n)return e.jsx(i,{disabled:!0,children:e.jsx(o,{size:20})});const{PDFDownloadLink:c}=n;return e.jsx(c,{document:e.jsx(h,{props:{invoice:s}}),fileName:`invoice_${s?.invoice_number}`,children:e.jsx(i,{children:e.jsx(r,{})})})},exports.InvoicePDFViewer=function({invoice:d}){const[j,y]=t.useState(!1),[p,a]=t.useState(null);if(t.useEffect(()=>{(async()=>{const e=await x();a(e)})()},[]),!p)return e.jsx(i,{disabled:!0,children:e.jsx(o,{size:20})});const{PDFViewer:u}=p;return e.jsxs(e.Fragment,{children:[e.jsx(i,{onClick:()=>y(!0),children:e.jsx(r,{})}),e.jsxs(s,{open:j,fullWidth:!0,maxWidth:"lg",children:[e.jsx(n,{children:e.jsx(u,{style:{width:"100%",minHeight:"70vh"},children:e.jsx(h,{props:{invoice:d}})})}),e.jsx(l,{children:e.jsx(c,{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"),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,{})})})}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}})})}),e.jsx(r,{children:e.jsx(o,{variant:"contained",onClick:()=>y(!1),children:"Close"})})]})]})},exports.default=h;
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},z=["picked","packed","shipped","reports"];function B({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function N({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this order?"}),e.jsxs(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await C.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:b}){const C=i.updateOpoAction.bind(null,d.documentId),[E,T]=r.useActionState(C,M),[U,P]=r.useState(d.opo_items?d.opo_items:[]),[L,R]=r.useState(!1),[W,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]),Q=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,P(n)},Y=(e,r)=>{const i=[...U],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,P(i)},$=(e,r)=>{const i=[...U],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,P(i)},{handleAddMessage:K}=O.useSnackbar();return r.useEffect(()=>{E?.message&&(K({message:E.message,severity:E.severity||"error"}),"success"===E.severity&&(m&&m(),p&&p()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&K({message:E.strapiErrors.message||"Error updating OPO",severity:E.severity||"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&P(d.opo_items?d.opo_items:[])},[d]),e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Outbound Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_number})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===b&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(B,{open:L,handleClose:()=>R(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(N,{open:W,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),z.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:T,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(U))}),U&&U.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:$,revalidateCallback:m,showing:H})},i)),e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js"),M=require("../../StyledLink.js");const z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},B=["picked","packed","shipped","reports"];function N({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function E({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this order?"}),e.jsxs(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await C.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:b}){const C=i.updateOpoAction.bind(null,d.documentId),[T,U]=r.useActionState(C,z),[P,L]=r.useState(d.opo_items?d.opo_items:[]),[R,W]=r.useState(!1),[$,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]),Q=(e,r,i)=>{const n=[...P],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,L(n)},Y=(e,r)=>{const i=[...P],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,L(i)},K=(e,r)=>{const i=[...P],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,L(i)},{handleAddMessage:V}=O.useSnackbar();return r.useEffect(()=>{T?.message&&(V({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(m&&m(),p&&p()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&V({message:T.strapiErrors.message||"Error updating OPO",severity:T.severity||"error"})},[T?.strapiErrors]),r.useEffect(()=>{d.opo_items&&L(d.opo_items?d.opo_items:[])},[d]),e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Outbound Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_number})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(M.StyledLink,{target:"_self",href:`/dashboard/admin/e-commerce/customers?selectedCustomerId=${d.customer?.documentId}`,children:d.customer?.business_credentials?.company_name})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===b&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>W(!0),children:"Confirm order"}),e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(N,{open:R,handleClose:()=>W(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(E,{open:$,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),B.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:U,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(P))}),P&&P.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:H})},i)),e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};