umwd-components 0.1.817 → 0.1.819
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.
- package/dist/cjs/node_modules/color-string/index.js +1 -1
- package/dist/cjs/node_modules/crypto-js/index.js +1 -1
- package/dist/cjs/src/components/e-commerce/invoice/InvoicePDF.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/iro/createIroAction.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/iro/requestRmaAction.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/invoice/InvoicePDF.js +3 -4
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +6 -7
- package/dist/esm/src/data/actions/e-commerce/iro/createIroAction.js +1 -0
- package/dist/esm/src/data/actions/e-commerce/iro/requestRmaAction.js +3 -2
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/components/e-commerce/invoice/InvoicePDF.d.ts +2 -4
- package/package.json +1 -1
|
@@ -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 r=require("../../_virtual/_commonjsHelpers.js"),e=require("../../_virtual/
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("../../_virtual/_commonjsHelpers.js"),e=require("../../_virtual/index6.js"),t=require("../color-name/index.js"),a=require("../simple-swizzle/index.js"),s=t.colorName,n=a.simpleSwizzleExports,o=Object.hasOwnProperty,l=Object.create(null);for(var u in s)o.call(s,u)&&(l[s[u]]=u);var d=e.__module.exports={to:{},get:{}};function i(r,e,t){return Math.min(Math.max(e,r),t)}function h(r){var e=Math.round(r).toString(16).toUpperCase();return e.length<2?"0"+e:e}d.get=function(r){var e,t;switch(r.substring(0,3).toLowerCase()){case"hsl":e=d.get.hsl(r),t="hsl";break;case"hwb":e=d.get.hwb(r),t="hwb";break;default:e=d.get.rgb(r),t="rgb"}return e?{model:t,value:e}:null},d.get.rgb=function(r){if(!r)return null;var e,t,a,n=[0,0,0,1];if(e=r.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(a=e[2],e=e[1],t=0;t<3;t++){var l=2*t;n[t]=parseInt(e.slice(l,l+2),16)}a&&(n[3]=parseInt(a,16)/255)}else if(e=r.match(/^#([a-f0-9]{3,4})$/i)){for(a=(e=e[1])[3],t=0;t<3;t++)n[t]=parseInt(e[t]+e[t],16);a&&(n[3]=parseInt(a+a,16)/255)}else if(e=r.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(t=0;t<3;t++)n[t]=parseInt(e[t+1],0);e[4]&&(e[5]?n[3]=.01*parseFloat(e[4]):n[3]=parseFloat(e[4]))}else{if(!(e=r.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=r.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:o.call(s,e[1])?((n=s[e[1]])[3]=1,n):null:null;for(t=0;t<3;t++)n[t]=Math.round(2.55*parseFloat(e[t+1]));e[4]&&(e[5]?n[3]=.01*parseFloat(e[4]):n[3]=parseFloat(e[4]))}for(t=0;t<3;t++)n[t]=i(n[t],0,255);return n[3]=i(n[3],0,1),n},d.get.hsl=function(r){if(!r)return null;var e=r.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var t=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,i(parseFloat(e[2]),0,100),i(parseFloat(e[3]),0,100),i(isNaN(t)?1:t,0,1)]}return null},d.get.hwb=function(r){if(!r)return null;var e=r.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var t=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,i(parseFloat(e[2]),0,100),i(parseFloat(e[3]),0,100),i(isNaN(t)?1:t,0,1)]}return null},d.to.hex=function(){var r=n(arguments);return"#"+h(r[0])+h(r[1])+h(r[2])+(r[3]<1?h(Math.round(255*r[3])):"")},d.to.rgb=function(){var r=n(arguments);return r.length<4||1===r[3]?"rgb("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+")":"rgba("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+", "+r[3]+")"},d.to.rgb.percent=function(){var r=n(arguments),e=Math.round(r[0]/255*100),t=Math.round(r[1]/255*100),a=Math.round(r[2]/255*100);return r.length<4||1===r[3]?"rgb("+e+"%, "+t+"%, "+a+"%)":"rgba("+e+"%, "+t+"%, "+a+"%, "+r[3]+")"},d.to.hsl=function(){var r=n(arguments);return r.length<4||1===r[3]?"hsl("+r[0]+", "+r[1]+"%, "+r[2]+"%)":"hsla("+r[0]+", "+r[1]+"%, "+r[2]+"%, "+r[3]+")"},d.to.hwb=function(){var r=n(arguments),e="";return r.length>=4&&1!==r[3]&&(e=", "+r[3]),"hwb("+r[0]+", "+r[1]+"%, "+r[2]+"%"+e+")"},d.to.keyword=function(r){return l[r.slice(0,3)]};var c=e.__module.exports,f=r.getDefaultExportFromCjs(c);exports.default=f;
|
|
@@ -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,r=require("../../_virtual/_commonjsHelpers.js"),i=require("../../_virtual/
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../_virtual/_commonjsHelpers.js"),i=require("../../_virtual/index5.js"),u=require("./core.js"),_=require("./x64-core.js"),q=require("./lib-typedarrays.js"),s=require("./enc-utf16.js"),j=require("./enc-base64.js"),a=require("./enc-base64url.js"),o=require("./md5.js"),d=require("./sha1.js"),t=require("./sha256.js"),p=require("./sha224.js"),c=require("./sha512.js"),m=require("./sha384.js"),l=require("./sha3.js"),n=require("./ripemd160.js"),b=require("./hmac.js"),f=require("./pbkdf2.js"),h=require("./evpkdf.js"),x=require("./cipher-core.js"),v=require("./mode-cfb.js"),g=require("./mode-ctr.js"),y=require("./mode-ctr-gladman.js"),k=require("./mode-ofb.js"),E=require("./mode-ecb.js"),w=require("./pad-ansix923.js"),z=require("./pad-iso10126.js"),C=require("./pad-iso97971.js"),D=require("./pad-zeropadding.js"),F=require("./pad-nopadding.js"),G=require("./format-hex.js"),H=require("./aes.js"),M=require("./tripledes.js"),O=require("./rc4.js"),P=require("./rabbit.js"),A=require("./rabbit-legacy.js"),B=require("./blowfish.js");e=i.__module,r.commonjsGlobal,e.exports=function(e){return e}(u.__require(),_.__require(),q.__require(),s.__require(),j.__require(),a.__require(),o.md5Exports,d.__require(),t.__require(),p.__require(),c.__require(),m.__require(),l.__require(),n.__require(),b.__require(),f.__require(),h.__require(),x.__require(),v.__require(),g.__require(),y.__require(),k.__require(),E.__require(),w.__require(),z.__require(),C.__require(),D.__require(),F.__require(),G.__require(),H.__require(),M.__require(),O.__require(),P.__require(),A.__require(),B.__require());var I=i.__module.exports,J=r.getDefaultExportFromCjs(I);exports.default=J;
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";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 Promise.resolve().then(function(){return require("../../../../node_modules/@react-pdf/renderer/lib/react-pdf.browser.js")});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.InvoicePDF=h,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"})})]})]})};
|
|
7
|
+
"use strict";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 Promise.resolve().then(function(){return require("../../../../node_modules/@react-pdf/renderer/lib/react-pdf.browser.js")});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=({invoice:i})=>{const{pdfComponents:s,loading:n,error:r}=d();if(n)return e.jsx(l,{});if(r)return e.jsxs("div",{children:["Error loading PDF components: ",r]});if(!s)return e.jsx("div",{children:"PDF components not available"});if(!i)return e.jsx("div",{children:"No invoice data provided"});const{Document:o,Page:c,View:h,Text:j,StyleSheet:y}=s,p=(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"}}))(y),{seller_business_credentials:a,seller_company_address:u,buyer_company_address:m,buyer_business_credentials:S,type:_}=i;return"credit"===_?e.jsx(o,{title:`credit_${x(i,"invoice_number","unknown")}`,children:e.jsxs(c,{size:"A4",style:p.page,children:[e.jsx(h,{style:p.header,children:e.jsx(j,{style:p.h1,children:x(a,"company_name")})}),e.jsx(h,{style:p.section,children:e.jsx(j,{style:p.h2,children:"CREDIT NOTE"})}),e.jsx(h,{style:p.section,children:e.jsxs(h,{style:p.row,children:[e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:p.h3,children:"BILLING DETAILS"}),e.jsx(j,{children:x(S,"company_name")}),e.jsxs(j,{children:[x(i,"buyer_first_name")," ",x(i,"buyer_last_name")]}),e.jsxs(j,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(j,{children:[x(m,"postal_code")," ",x(m,"city")]})]}),e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:p.h3,children:"FROM"}),e.jsx(j,{children:x(a,"company_name")}),e.jsxs(j,{children:[x(u,"street")," ",x(u,"street_number")," ",x(u,"street_number_addition")]}),e.jsxs(j,{children:[x(u,"postal_code")," ",x(u,"city")]}),e.jsx(j,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(j,{children:x(a,"coc_number")}),e.jsx(j,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(j,{children:x(a,"vat_number")})]})]})}),e.jsx(h,{style:p.section,children:e.jsxs(h,{style:p.row,children:[e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(j,{children:x(i,"invoice_number")})]}),x(i,"customer_reference")&&e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(j,{children:x(i,"customer_reference")})]}),e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(j,{children:x(i,"invoice_date")})]})]})}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h3,children:"SUMMARY"}),e.jsxs(h,{style:p.row,children:[i?.admin_items&&Array.isArray(i.admin_items)&&i.admin_items.length>0&&e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),i?.items&&Array.isArray(i.items)&&i.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(h,{style:p.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(j,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`credit-item-${s}`)),i?.admin_items&&Array.isArray(i.admin_items)&&i.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`credit-admin-item-${s}`))]}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h3,children:"TOTALS"}),e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"VAT_total",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(h,{style:p.section,children:e.jsxs(j,{style:{...p.h3,border:"2px solid black",padding:10},children:["Total: € ",x(i,"total_incl_vat",0)?.toFixed(2)]})})]})}):"proforma"===_?e.jsx(o,{title:`proforma_${x(i,"invoice_number","unknown")}`,children:e.jsxs(c,{size:"A4",style:p.page,children:[e.jsx(h,{style:p.header,children:e.jsx(j,{style:p.h1,children:x(a,"company_name")})}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h2,children:"PROFORMA INVOICE"}),e.jsx(j,{style:{fontSize:10,marginTop:5},children:"This is not a final invoice and cannot be used for tax purposes"})]}),e.jsx(h,{style:p.section,children:e.jsxs(h,{style:p.row,children:[e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:p.h3,children:"BILLING DETAILS"}),e.jsx(j,{children:x(S,"company_name")}),e.jsxs(j,{children:[x(i,"buyer_first_name")," ",x(i,"buyer_last_name")]}),e.jsxs(j,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(j,{children:[x(m,"postal_code")," ",x(m,"city")]})]}),e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:p.h3,children:"FROM"}),e.jsx(j,{children:x(a,"company_name")}),e.jsxs(j,{children:[x(u,"street")," ",x(u,"street_number")," ",x(u,"street_number_addition")]}),e.jsxs(j,{children:[x(u,"postal_code")," ",x(u,"city")]}),e.jsx(j,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(j,{children:x(a,"coc_number")}),e.jsx(j,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(j,{children:x(a,"vat_number")})]})]})}),e.jsx(h,{style:p.section,children:e.jsxs(h,{style:p.row,children:[e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(j,{children:x(i,"invoice_number")})]}),x(i,"customer_reference")&&e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(j,{children:x(i,"customer_reference")})]}),e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(j,{children:x(i,"invoice_date")})]})]})}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h3,children:"SUMMARY"}),e.jsxs(h,{style:p.row,children:[i?.admin_items&&Array.isArray(i.admin_items)&&i.admin_items.length>0&&e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),i?.items&&Array.isArray(i.items)&&i.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(h,{style:p.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(j,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`proforma-item-${s}`)),i?.admin_items&&Array.isArray(i.admin_items)&&i.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`proforma-admin-item-${s}`))]}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h3,children:"TOTALS"}),e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"VAT_total",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(h,{style:p.section,children:e.jsxs(j,{style:{...p.h3,border:"2px solid black",padding:10},children:["Total Due: € ",x(i,"total_incl_vat",0)?.toFixed(2)]})})]})}):e.jsx(o,{title:`invoice_${x(i,"invoice_number","unknown")}`,children:e.jsxs(c,{size:"A4",style:p.page,children:[e.jsx(h,{style:p.header,children:e.jsx(j,{style:p.h1,children:x(a,"company_name")})}),e.jsx(h,{style:p.section,children:e.jsx(j,{style:p.h2,children:"INVOICE"})}),e.jsx(h,{style:p.section,children:e.jsxs(h,{style:p.row,children:[e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:p.h3,children:"BILLING DETAILS"}),e.jsx(j,{children:x(S,"company_name")}),e.jsxs(j,{children:[x(i,"buyer_first_name")," ",x(i,"buyer_last_name")]}),e.jsxs(j,{children:[x(m,"street")," ",x(m,"street_number")," ",x(m,"street_number_addition")]}),e.jsxs(j,{children:[x(m,"postal_code")," ",x(m,"city")]})]}),e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:p.h3,children:"FROM"}),e.jsx(j,{children:x(a,"company_name")}),e.jsxs(j,{children:[x(u,"street")," ",x(u,"street_number")," ",x(u,"street_number_addition")]}),e.jsxs(j,{children:[x(u,"postal_code")," ",x(u,"city")]}),e.jsx(j,{style:{fontWeight:"bold",marginTop:10},children:"CoC Number"}),e.jsx(j,{children:x(a,"coc_number")}),e.jsx(j,{style:{fontWeight:"bold",marginTop:10},children:"VAT Number"}),e.jsx(j,{children:x(a,"vat_number")})]})]})}),e.jsx(h,{style:p.section,children:e.jsxs(h,{style:p.row,children:[e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Invoice number: "}),e.jsx(j,{children:x(i,"invoice_number")})]}),x(i,"customer_reference")&&e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Your reference: "}),e.jsx(j,{children:x(i,"customer_reference")})]}),e.jsxs(h,{style:p.rowSection,children:[e.jsx(j,{style:{fontWeight:"bold"},children:"Invoice date"}),e.jsx(j,{children:x(i,"invoice_date")})]})]})}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h3,children:"SUMMARY"}),e.jsxs(h,{style:p.row,children:[i?.admin_items&&Array.isArray(i.admin_items)&&i.admin_items.length>0&&e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Line Item Number"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Title"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Amount"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT rate"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px",fontWeight:"bold"},children:"Incl. VAT"})})]}),i?.items&&Array.isArray(i.items)&&i.items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[i&&"product_title"in i?i.product_title:"",i&&"item_description"in i?i.item_description:""]})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[x(i,"vat_rate")," %"]})}),e.jsx(h,{style:p.productRowSection,children:i?.price_excl_vat&&i?.price_incl_vat&&e.jsxs(j,{style:{fontSize:"10px"},children:["€"," ",(i.price_incl_vat-i.price_excl_vat)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price_excl_vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price_incl_vat",0)?.toFixed(2)]})})]})},`invoice-item-${s}`)),i?.admin_items&&Array.isArray(i.admin_items)&&i.admin_items.map((i,s)=>e.jsx(t.Fragment,{children:e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"line_item_number")})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"description")})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontSize:"10px"},children:x(i,"quantity")})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:[x(i,"price.vat_rate")," %"]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{style:{fontSize:"10px"},children:["€ ",x(i,"price.price_incl_vat",0)?.toFixed(2)]})})]})},`invoice-admin-item-${s}`))]}),e.jsxs(h,{style:p.section,children:[e.jsx(j,{style:p.h3,children:"TOTALS"}),e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"Excl. VAT"})}),e.jsx(h,{style:p.productRowSection,children:e.jsx(j,{style:{fontWeight:"bold"},children:"Incl. VAT"})})]}),e.jsxs(h,{style:p.row,children:[e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"VAT_total",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"total_excl_vat",0)?.toFixed(2)]})}),e.jsx(h,{style:p.productRowSection,children:e.jsxs(j,{children:["€ ",x(i,"total_incl_vat",0)?.toFixed(2)]})})]})]}),e.jsx(h,{style:p.section,children:e.jsxs(j,{style:{...p.h3,border:"2px solid black",padding:10},children:["Total Due: € ",x(i,"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,{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.InvoicePDF=h,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,{invoice:x})},Date.now())}),e.jsx(r,{children:e.jsx(o,{variant:"contained",onClick:()=>y(!1),children:"Close"})})]})]})};
|
|
@@ -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"),r=require("react"),t=require("../../../context/common/SnackbarContext.js"),i=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../context/common/SnackbarContext.js"),i=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),n=require("../../SubmitButton.js"),a=require("@mui/material/Typography"),s=require("@mui/material/Grid"),o=require("@mui/material/Box"),u=require("@mui/material/TextField"),l=require("@mui/material/Checkbox"),d=require("@mui/material/Button"),c=require("@mui/material/Alert"),m=require("@mui/material/Stack"),h=require("@mui/material"),x=require("@mui/material/Dialog"),g=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),p=require("@mui/material/DialogContentText"),y=require("@mui/material/DialogTitle"),b=require("../../common/NumberInput.js");require("next/headers");const v={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},f=({items:t,itemsToReturn:i,setItemsToReturn:n,selectedItems:s,setSelectedItems:o})=>{const[d,c]=r.useState(!1),x=(e,r,t)=>{n(i.map((i,n)=>n===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&n(t.map(e=>({line_item_number:e.line_item_number||"",product:e.product?.documentId||"",ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[g,j]=r.useState([]);return r.useEffect(()=>{i&&j((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))(i))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(m,{spacing:2,children:[e.jsx(a,{variant:"h6",children:"Items"}),e.jsx(a,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(g)}),e.jsx(m,{spacing:1,children:t.map((t,n)=>e.jsxs(r.Fragment,{children:[e.jsxs(m,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(l,{checked:s.includes(n),onChange:e=>{e.target.checked?o([...s,n]):o(s.filter(e=>e!==n))}}),e.jsxs(a,{variant:"body1",children:["Line Item Number: ",t.line_item_number]}),e.jsxs(a,{variant:"body1",children:["Part Number: ",t.product?.product_number]}),e.jsxs(a,{variant:"body1",children:["Quantity Ordered: ",t.ordered_quantity]})]}),s.includes(n)&&e.jsxs(e.Fragment,{children:[e.jsxs(m,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(b.default,{label:"Quantity to return",minnewvalue:0,maxnewvalue:t.ordered_quantity,setValueCallback:e=>{x(n,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(h.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(a,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(u,{value:i[n]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;c("other"===r),x(n,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),d&&e.jsx(u,{value:i[n].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;x(n,"other_reason",r)}})]}),e.jsx(h.Divider,{})]},n))})]})})},q=({open:t,onClose:i,items:s,formState:o,submitCallback:u})=>{const[c,m]=r.useState(!0),[b,v]=r.useTransition();return e.jsxs(x,{open:t,onClose:i,children:[e.jsx(y,{children:"Confirm RMA"}),e.jsxs(j,{children:[e.jsx(p,{children:"Summary of items to be returned:"}),e.jsx(h.List,{children:s.map((r,t)=>e.jsx(h.ListItem,{children:`Product with ID ${r.product} - Quantity: ${r.returned_quantity}`},t))}),e.jsx(p,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(l,{onChange:e=>m(!e.target.checked)}),e.jsx(a,{variant:"body1",children:"I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration."})]}),e.jsxs(g,{children:[e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:c,onClick:()=>{u&&v(()=>{u()})},loading:b}),e.jsx(d,{onClick:i,children:"No"})]})]})};exports.default=function({opo:n,sx:u,revalidateCallback:l,handleClose:h}){const[x,g]=r.useActionState(i.requestRmaAction,v),{handleAddMessage:j}=t.useSnackbar(),[p,y]=r.useState(!1),[b,_]=r.useState([]),[C,I]=r.useState([]);return r.useEffect(()=>{x?.message&&(j({message:x.message,severity:x.severity||"error"}),"success"===x.severity&&(l&&l(),h&&h()))},[x?.message]),r.useEffect(()=>{x?.strapiErrors&&j({message:x.strapiErrors.message||"Error requesting RMA",severity:x.severity||"error"})},[x?.strapiErrors]),e.jsx(o,{sx:[...Array.isArray(u)?u:[u]],children:e.jsx("form",{action:g,children:e.jsxs(s,{container:!0,spacing:2,children:[e.jsx(s,{size:12,children:e.jsx(a,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:n.documentId}),e.jsx(s,{size:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(a,{variant:"body1",children:"Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned."}),e.jsx(c,{severity:"warning",children:"We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items."})]})}),e.jsx(s,{size:12,children:n.opo_items?e.jsx(m,{spacing:1,children:n.opo_items&&e.jsx(f,{items:n.opo_items,itemsToReturn:b,setItemsToReturn:_,selectedItems:C,setSelectedItems:I},n.documentId)}):e.jsx(a,{variant:"body1",children:"No items"})}),e.jsx(q,{formState:x,open:p,items:b.filter(e=>e.returned_quantity>0),onClose:()=>y(!p),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");g(e?new FormData(e):new FormData),y(!p)}}),e.jsx(s,{size:12,children:e.jsx(d,{onClick:()=>{console.log(x),y(!p)},disabled:0===C.length||0===C.reduce((e,r)=>e+b[r].returned_quantity,0),children:"Request RMA"})})]})})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.createIroAction=async function(s,a){Object.fromEntries(a);const i=t.parseFormData(a);if(i.data.iro_items&&(i.data.iro_items=JSON.parse(i.data.iro_items)),console.log(i),0===i.data.iro_items.length)return{...s,strapiErrors:null,message:"Please add at least one item to the Iro."};const o=await r.mutateData("POST","/api/iros/createAdmin",i);if(!o)return{...s,strapiErrors:null,severity:"error",message:"Ops! Something went wrong. Please try again."};if(o.error)return{...s,strapiErrors:o.error,severity:"error",message:"Failed to Create Iro."};const n=e.flattenAttributes(o);return{...s,message:"Iro Created Successfully",severity:"success",data:n,strapiErrors:null}};
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.createIroAction=async function(s,a){Object.fromEntries(a);const i=t.parseFormData(a);if(i.data.iro_items&&(i.data.iro_items=JSON.parse(i.data.iro_items)),console.log(i),0===i.data.iro_items.length)return{...s,strapiErrors:null,severity:"error",message:"Please add at least one item to the Iro."};const o=await r.mutateData("POST","/api/iros/createAdmin",i);if(!o)return{...s,strapiErrors:null,severity:"error",message:"Ops! Something went wrong. Please try again."};if(o.error)return{...s,strapiErrors:o.error,severity:"error",message:"Failed to Create Iro."};const n=e.flattenAttributes(o);return{...s,message:"Iro Created Successfully",severity:"success",data:n,strapiErrors:null}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.requestRmaAction=async function(s,a){Object.fromEntries(a);const i=t.parseFormData(a);i.data.iro_items&&(i.data.iro_items=JSON.parse(i.data.iro_items)),i.data.opos&&(i.data.opos=i.data.opos);const o=await r.mutateData("POST","/api/iros",i);if(!o)return{...s,strapiErrors:null,severity:"error",message:"Ops! Something went wrong. Please try again."};if(o.error)return{...s,strapiErrors:o.error,severity:"error",message:"Failed to Create Iro."};const n=e.flattenAttributes(o);return{...s,message:"Iro Created Successfully",severity:"success",data:n,strapiErrors:null}};
|