umwd-components 0.1.409 → 0.1.411

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.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__read as t}from"../../../../node_modules/tslib/tslib.es6.js";import{useState as r,useEffect as e}from"react";import{useCart as o}from"../../../context/e-commerce/cart/CartContext.js";var i=function(){var i=t(r(!1),2),s=i[0],a=i[1],c=o(),m=c.state,n=c.dispatch;return e((function(){a(!0)}),[]),{state:m,dispatch:n,isClient:s}};export{i as useClientSideCart};
6
+ import{__read as t}from"../../../../node_modules/tslib/tslib.es6.js";import{useState as r,useEffect as e}from"react";import{useCart as o}from"../../../context/e-commerce/cart/CartContext.js";var a=function(){var a=t(r(!1),2),c=a[0],i=a[1],s=o(),m=s.state,n=s.dispatch,l=s.clearCart;return e((function(){i(!0)}),[]),{state:m,dispatch:n,isClient:c,clearCart:l}};export{a as useClientSideCart};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{extends as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{__read as t}from"../../../../node_modules/tslib/tslib.es6.js";import n from"@mui/material/Typography";import r from"@mui/material/Container";import a from"@mui/material/Stack";import l from"@mui/material/Grid";import i from"@mui/material/Paper";import o from"@mui/material/Box";import m from"@mui/material/Button";import c from"@mui/material/Stepper";import s from"@mui/material/Step";import u from"@mui/material/StepLabel";import p from"@mui/material/MobileStepper";import d from"@mui/material/useMediaQuery";import{useTheme as x}from"@mui/material/styles";import E,{useState as f,useEffect as b}from"react";import k from"next/link";import{useSearchParams as h}from"next/navigation";import{useSession as g}from"../../../context/auth/SessionContext.js";import v from"@mui/icons-material/KeyboardArrowLeft";import B from"@mui/icons-material/KeyboardArrowRight";import y from"./Step1.js";import C from"./Step2.js";import S from"./Step3.js";import j from"./Step4.js";import N from"./Step5.js";import{useCheckout as w}from"../../../context/e-commerce/checkout/CheckoutContext.js";function z(z){var _=z.shopUrl,P=void 0===_?"/shop":_,A=x(),D=d(A.breakpoints.down("sm")),H=w(),L=H.state,O=H.runAllChecks,F=t(f(0),2),I=F[0],K=F[1],M=function(){K((function(e){return e+1}))},T=function(){K((function(e){return e-1}))},V=g(),G=V.loading;V.error;var Q=V.user,R=h();b((function(){null!==R&&(R.get("order")&&K(4))}),[R]),b((function(){O()}),[Q]);var U=!L.itemsInCart,q=!L.customerProfileComplete,J=[{label:"Login or register",children:E.createElement(y,null),backButton:E.createElement(m,{variant:D?"text":"outlined",disabled:0===I,onClick:T,sx:{mr:1}},"Back",D&&E.createElement(v,null)),nextButton:E.createElement(m,{variant:D?"text":"contained",onClick:M,sx:{ml:1},size:D?"small":"large"},"Next",D&&E.createElement(B,null))},{label:"Provide us with your address",children:E.createElement(C,null),backButton:E.createElement(m,{size:D?"small":"large",onClick:T,disabled:0===I,variant:D?"text":"outlined"},"Back",D&&E.createElement(v,null)),nextButton:E.createElement(m,{size:D?"small":"large",variant:D?"text":"contained",onClick:function(){M()},disabled:(!Q||U||q)&&"production"===process.env.NODE_ENV},"Next",D&&E.createElement(B,null))},{label:"Set up mailing options",children:E.createElement(S,null),backButton:E.createElement(m,{size:D?"small":"large",variant:D?"text":"outlined",onClick:T,disabled:0===I},"Back",D&&E.createElement(v,null)),nextButton:E.createElement(m,{size:D?"small":"large",variant:D?"text":"contained",onClick:function(){M()},disabled:(!Q||U||q)&&"production"===process.env.NODE_ENV},"Next",D&&E.createElement(B,null))},{label:"Confirm and make a payment",children:E.createElement(j,null),nextButton:E.createElement(E.Fragment,null,E.createElement(m,{size:D?"small":"large",variant:D?"text":"contained",onClick:function(){M()},disabled:!0},"Next",D&&E.createElement(B,null))),backButton:E.createElement(m,{size:D?"small":"large",variant:D?"text":"outlined",onClick:T,disabled:0===I},"Back",D&&E.createElement(v,null))},{label:"Done!",children:E.createElement(N,null)}];return E.createElement(r,{sx:{py:2,minHeight:"100vh"}},E.createElement(l,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"}},E.createElement(l,{item:!0,xs:12},E.createElement(n,{variant:"h4",align:"center"},"Check Out")),U&&4!=I&&E.createElement(l,{item:!0,xs:12},E.createElement(o,{sx:{color:"red",border:"2px solid red",p:2}},E.createElement(n,{variant:"h5"},"No products in cart"),E.createElement(n,{variant:"body1"},"There are no products selected to order, please visit the shop befor continuing"))),E.createElement(l,{item:!0,xs:12},E.createElement(o,{width:"100%"},E.createElement(i,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}}},E.createElement(a,{direction:"row",spacing:2,alignItems:"center"},E.createElement(n,{variant:"body2"},"".concat(I+1," / ").concat(J.length)),E.createElement(n,null,"".concat(J[I].label)))),E.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},E.createElement(c,{activeStep:I},J.map((function(t,n){var r={};return E.createElement(s,e({key:n},{},{sx:{pb:"20px"}}),E.createElement(u,r,t.label))})))),!G&&E.createElement(E.Fragment,null,J[I].children,E.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},E.createElement(a,{direction:"row",spacing:2},J[I].backButton,E.createElement(m,{variant:"outlined",sx:{ml:1}},E.createElement(k,{href:P},"continue shopping")),E.createElement(o,{sx:{flex:"1 1 auto"}}),J[I].nextButton))))),E.createElement(l,{item:!0,xs:12},E.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:J.length,position:"static",activeStep:I,nextButton:J[I].nextButton,backButton:J[I].backButton}))))}export{z as default};
7
+ import{extends as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{__read as t}from"../../../../node_modules/tslib/tslib.es6.js";import n from"@mui/material/Typography";import r from"@mui/material/Container";import a from"@mui/material/Stack";import l from"@mui/material/Grid";import i from"@mui/material/Paper";import o from"@mui/material/Box";import m from"@mui/material/Button";import c from"@mui/material/Stepper";import s from"@mui/material/Step";import u from"@mui/material/StepLabel";import p from"@mui/material/MobileStepper";import d from"@mui/material/useMediaQuery";import{useTheme as x}from"@mui/material/styles";import E,{useState as f,useEffect as b}from"react";import h from"next/link";import{useSearchParams as k}from"next/navigation";import{useSession as v}from"../../../context/auth/SessionContext.js";import g from"@mui/icons-material/KeyboardArrowLeft";import B from"@mui/icons-material/KeyboardArrowRight";import C from"./Step1.js";import y from"./Step2.js";import S from"./Step3.js";import N from"./Step4.js";import j from"./Step5.js";import{useCheckout as w}from"../../../context/e-commerce/checkout/CheckoutContext.js";function z(z){var _=z.shopUrl,D=void 0===_?"/shop":_,O=x(),P=d(O.breakpoints.down("sm")),A=w(),H=A.state,L=A.runAllChecks,V=A.handleClearCart,F=t(f(0),2),I=F[0],K=F[1],M=function(){K((function(e){return e+1}))},T=function(){K((function(e){return e-1}))},G=v(),Q=G.loading;G.error;var R=G.user,U=k();b((function(){null!==U&&(U.get("order")&&(K(4),V()))}),[U]),b((function(){L()}),[R]);var q=!H.itemsInCart,J=!H.customerProfileComplete,W=[{label:"Login or register",children:E.createElement(C,null),backButton:E.createElement(m,{variant:P?"text":"outlined",disabled:0===I,onClick:T,sx:{mr:1}},"Back",P&&E.createElement(g,null)),nextButton:E.createElement(m,{variant:P?"text":"contained",onClick:M,sx:{ml:1},disabled:(!R||q)&&"production"===process.env.NODE_ENV,size:P?"small":"large"},"Next",P&&E.createElement(B,null))},{label:"Provide us with your address",children:E.createElement(y,null),backButton:E.createElement(m,{size:P?"small":"large",onClick:T,disabled:0===I,variant:P?"text":"outlined"},"Back",P&&E.createElement(g,null)),nextButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){M()},disabled:(!R||q||J)&&"production"===process.env.NODE_ENV},"Next",P&&E.createElement(B,null))},{label:"Set up mailing options",children:E.createElement(S,null),backButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"outlined",onClick:T,disabled:0===I},"Back",P&&E.createElement(g,null)),nextButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){M()},disabled:(!R||q||J)&&"production"===process.env.NODE_ENV},"Next",P&&E.createElement(B,null))},{label:"Confirm and make a payment",children:E.createElement(N,null),nextButton:E.createElement(E.Fragment,null,E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){M()},disabled:!0},"Next",P&&E.createElement(B,null))),backButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"outlined",onClick:T,disabled:0===I},"Back",P&&E.createElement(g,null))},{label:"Done!",children:E.createElement(j,null)}];return E.createElement(r,{sx:{py:2,minHeight:"100vh"}},E.createElement(l,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"}},E.createElement(l,{item:!0,xs:12},E.createElement(n,{variant:"h4",align:"center"},"Check Out")),q&&4!=I&&E.createElement(l,{item:!0,xs:12},E.createElement(o,{sx:{color:"red",border:"2px solid red",p:2}},E.createElement(n,{variant:"h5"},"No products in cart"),E.createElement(n,{variant:"body1"},"There are no products selected to order, please visit the shop befor continuing"))),E.createElement(l,{item:!0,xs:12},E.createElement(o,{width:"100%"},E.createElement(i,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}}},E.createElement(a,{direction:"row",spacing:2,alignItems:"center"},E.createElement(n,{variant:"body2"},"".concat(I+1," / ").concat(W.length)),E.createElement(n,null,"".concat(W[I].label)))),E.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},E.createElement(c,{activeStep:I},W.map((function(t,n){var r={};return E.createElement(s,e({key:n},{},{sx:{pb:"20px"}}),E.createElement(u,r,t.label))})))),!Q&&E.createElement(E.Fragment,null,W[I].children,E.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},E.createElement(a,{direction:"row",spacing:2},W[I].backButton,E.createElement(m,{variant:"outlined",sx:{ml:1}},E.createElement(h,{href:D},"continue shopping")),E.createElement(o,{sx:{flex:"1 1 auto"}}),W[I].nextButton))))),E.createElement(l,{item:!0,xs:12},E.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:W.length,position:"static",activeStep:I,nextButton:W[I].nextButton,backButton:W[I].backButton}))))}export{z as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{Fragment as r}from"react";import o from"@mui/material/Paper";import a from"@mui/material/Stack";import m from"@mui/material/Alert";import n from"@mui/material/Button";import i from"@mui/material/Typography";import{useClientSideCart as l}from"../cart/hooks.js";import c from"../cart/CartSummary.js";import{useFormState as s}from"react-dom";import{checkoutAction as p}from"../../../data/actions/e-commerce/checkout-action.js";import{StrapiErrors as u}from"../../StrapiErrors.js";function d(){var d=l().state,y=e(s(p,{zodErrors:null,strapiErrors:null,data:null,message:null}),2),f=y[0],E=y[1];return t.createElement(o,{sx:{p:2}},t.createElement(a,{spacing:2},t.createElement(c,null),t.createElement(u,{error:null==f?void 0:f.strapiErrors}),(null==f?void 0:f.message)&&t.createElement(m,{severity:"error"},null==f?void 0:f.message),t.createElement(i,null,"Please double check all details prior to payment."),t.createElement(i,null,"Is this order compleet?"),t.createElement("form",{id:"paymentform",action:E},d.items&&d.items.map((function(e,o){return t.createElement(r,{key:o},t.createElement("input",{type:"hidden",name:"opo_items[".concat(o,"].product"),value:e.id}),t.createElement("input",{type:"hidden",name:"opo_items[".concat(o,"].ordered_quantity"),value:e.quantity}))})),t.createElement(i,null,"Please click 'Proceed to payment' to proceed to the secure payment page. After completing the payment, you will automatically return to our shop. For any updates on this order, you can always access the latest information in your personal details."),t.createElement(n,{variant:"contained",form:"paymentform",type:"submit"},"Proceed to payment"))))}export{d as default};
7
+ import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{Fragment as r}from"react";import a from"@mui/material/Paper";import o from"@mui/material/Stack";import m from"@mui/material/Alert";import i from"@mui/material/Button";import n from"@mui/material/Typography";import{useClientSideCart as l}from"../cart/hooks.js";import s from"../cart/CartSummary.js";import{useFormState as c}from"react-dom";import{checkoutAction as p}from"../../../data/actions/e-commerce/checkout-action.js";import{StrapiErrors as u}from"../../StrapiErrors.js";function d(){var d=l(),y=d.state;d.isClient;var f=e(c(p,{zodErrors:null,strapiErrors:null,data:null,message:null}),2),E=f[0],h=f[1];return t.createElement(a,{sx:{p:2}},t.createElement(o,{spacing:2},t.createElement(s,null),t.createElement(u,{error:null==E?void 0:E.strapiErrors}),(null==E?void 0:E.message)&&t.createElement(m,{severity:"error"},null==E?void 0:E.message),t.createElement(n,null,"Please double check all details prior to payment."),t.createElement(n,null,"Is this order compleet?"),t.createElement("form",{id:"paymentform",action:h},y.items&&y.items.map((function(e,a){return t.createElement(r,{key:a},t.createElement("input",{type:"hidden",name:"opo_items[".concat(a,"].product"),value:e.id}),t.createElement("input",{type:"hidden",name:"opo_items[".concat(a,"].ordered_quantity"),value:e.quantity}))})),t.createElement(n,null,"Please click 'Proceed to payment' to proceed to the secure payment page. After completing the payment, you will automatically return to our shop. For any updates on this order, you can always access the latest information in your personal details."),t.createElement(i,{variant:"contained",form:"paymentform",type:"submit"},"Proceed to payment"))))}export{d as default};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as r,useEffect as o}from"react";import{getSingleOrder as i}from"../../../data/loaders/e-commerce-loaders.js";import{useSearchParams as l}from"next/navigation";import n from"../opo/OpoDisplay.js";import m from"@mui/material/Paper";import a from"@mui/material/Stack";import c from"@mui/material/Typography";import s from"@mui/material/useMediaQuery";import u from"@mui/icons-material/MoreVert";import p from"@mui/icons-material/ListAlt";import d from"@mui/icons-material/AccountCircle";import{useTheme as f}from"@mui/material/styles";function h(){var h=l(),E=e(r(null),2),g=E[0],v=E[1],y=null!==h?h.get("order"):null,x=f(),k=s(x.breakpoints.down("md"));return o((function(){y&&i(y).then((function(e){e.error?v(null):v(e)}))}),[y]),y&&null!==g?g?t.createElement(m,{sx:{p:2}},t.createElement(a,{spacing:2},g&&t.createElement(n,{opo:g}),t.createElement(c,{variant:"h6"},"Thank you for shopping with us!"),t.createElement(c,null,"You are always able to access your information and documents in your personal details."),k?t.createElement(c,null,"Click on the ",t.createElement(u,{sx:{verticalAlign:"middle"}})," icon in the top-right bottom of the screen, then click on"," ",t.createElement(p,{sx:{verticalAlign:"middle"}})," Orders"):t.createElement(c,null,"Hover over the"," ",t.createElement(d,{sx:{verticalAlign:"middle"}})," icon in the top-right corner of the screen, then click on"," ",t.createElement(p,{sx:{verticalAlign:"middle"}})," Orders"))):t.createElement("div",null,"Loading..."):t.createElement("div",null,"No order to display...")}export{h as default};
6
+ import{__read as e,__awaiter as r,__generator as t}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useState as i,useEffect as l}from"react";import{getSingleOrder as n}from"../../../data/loaders/e-commerce-loaders.js";import{useSearchParams as a}from"next/navigation";import m from"../opo/OpoDisplay.js";import c from"@mui/material/Paper";import s from"@mui/material/Stack";import u from"@mui/material/Typography";import d from"@mui/material/useMediaQuery";import p from"@mui/icons-material/MoreVert";import f from"@mui/icons-material/ListAlt";import h from"@mui/icons-material/AccountCircle";import{useTheme as v}from"@mui/material/styles";function g(){var g=a(),E=e(i(null),2),y=E[0],b=E[1],x=null!==g?g.get("order"):null,k=v(),A=d(k.breakpoints.down("md"));return l((function(){!function(){r(this,void 0,void 0,(function(){var e;return t(this,(function(r){switch(r.label){case 0:return console.log("orderUuid",x),x?[4,n(x)]:[3,2];case 1:(e=r.sent()).error?b(null):b(e),r.label=2;case 2:return[2]}}))}))}()}),[x]),x&&null!==y?y?o.createElement(c,{sx:{p:2}},o.createElement(s,{spacing:2},y&&o.createElement(m,{opo:y}),o.createElement(u,{variant:"h6"},"Thank you for shopping with us!"),o.createElement(u,null,"You are always able to access your information and documents in your personal details."),A?o.createElement(u,null,"Click on the ",o.createElement(p,{sx:{verticalAlign:"middle"}})," icon in the top-right bottom of the screen, then click on"," ",o.createElement(f,{sx:{verticalAlign:"middle"}})," Orders"):o.createElement(u,null,"Hover over the"," ",o.createElement(h,{sx:{verticalAlign:"middle"}})," icon in the top-right corner of the screen, then click on"," ",o.createElement(f,{sx:{verticalAlign:"middle"}})," Orders"))):o.createElement("div",null,"Loading..."):o.createElement("div",null,"No order to display...")}export{g as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as t,__assign as a,__spreadArray as e}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useReducer as i,useEffect as r,useContext as o,createContext as u}from"react";var c={items:[],totalExVAT:0,totalVAT:0,totalInclVAT:0,totalAmount:0},l=u({state:c,dispatch:function(){}}),s=function(n,i){switch(i.type){case"ADD_ITEM":var r=n.items.findIndex((function(t){return t.id===i.payload.id}));if(r>-1){var o=n.items.map((function(t,e){return e===r?a(a({},t),{quantity:t.quantity+i.payload.quantity}):t}));return a(a({},n),{items:o})}return a(a({},n),{items:e(e([],t(n.items),!1),[i.payload],!1)});case"REMOVE_ITEM":var u=n.items.findIndex((function(t){return t.id===i.payload.id}));if(u>-1){o=n.items.map((function(t,e){return e===u?a(a({},t),{quantity:t.quantity-1}):t})).filter((function(t){return t.quantity>0}));return a(a({},n),{items:o})}return n;case"SET_ITEMS":return a(a({},n),{items:i.payload});case"UPDATE_TOTALS":return a(a({},n),i.payload);default:return n}},m=function(a){var e=a.children,o=t(i(s,c),2),u=o[0],m=o[1];return r((function(){var t=localStorage.getItem("cart");t&&m({type:"SET_ITEMS",payload:JSON.parse(t)})}),[]),r((function(){localStorage.setItem("cart",JSON.stringify(u.items))}),[u.items]),r((function(){var t,a,e,n;t=0,a=0,e=0,n=0,u.items.forEach((function(i){t+=i.price_excl_vat*i.quantity,a+=i.price_excl_vat*(i.vat_rate/100)*i.quantity,e+=i.price_incl_vat*i.quantity,n+=i.quantity})),m({type:"UPDATE_TOTALS",payload:{totalExVAT:t,totalVAT:a,totalInclVAT:e,totalAmount:n}})}),[u.items]),n.createElement(l.Provider,{value:{state:u,dispatch:m}},e)},d=function(){return o(l)};export{m as CartProvider,d as useCart};
7
+ import{__read as t,__assign as a,__spreadArray as e}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useReducer as i,useEffect as r,useContext as o,createContext as u}from"react";var c={items:[],totalExVAT:0,totalVAT:0,totalInclVAT:0,totalAmount:0},l=u({state:c,dispatch:function(){},clearCart:function(){}}),s=function(n,i){switch(i.type){case"ADD_ITEM":var r=n.items.findIndex((function(t){return t.id===i.payload.id}));if(r>-1){var o=n.items.map((function(t,e){return e===r?a(a({},t),{quantity:t.quantity+i.payload.quantity}):t}));return a(a({},n),{items:o})}return a(a({},n),{items:e(e([],t(n.items),!1),[i.payload],!1)});case"REMOVE_ITEM":var u=n.items.findIndex((function(t){return t.id===i.payload.id}));if(u>-1){o=n.items.map((function(t,e){return e===u?a(a({},t),{quantity:t.quantity-1}):t})).filter((function(t){return t.quantity>0}));return a(a({},n),{items:o})}return n;case"SET_ITEMS":return a(a({},n),{items:i.payload});case"UPDATE_TOTALS":return a(a({},n),i.payload);default:return n}},m=function(a){var e=a.children,o=t(i(s,c),2),u=o[0],m=o[1];return r((function(){var t=localStorage.getItem("cart");t&&m({type:"SET_ITEMS",payload:JSON.parse(t)})}),[]),r((function(){localStorage.setItem("cart",JSON.stringify(u.items))}),[u.items]),r((function(){var t,a,e,n;t=0,a=0,e=0,n=0,u.items.forEach((function(i){t+=i.price_excl_vat*i.quantity,a+=i.price_excl_vat*(i.vat_rate/100)*i.quantity,e+=i.price_incl_vat*i.quantity,n+=i.quantity})),m({type:"UPDATE_TOTALS",payload:{totalExVAT:t,totalVAT:a,totalInclVAT:e,totalAmount:n}})}),[u.items]),n.createElement(l.Provider,{value:{state:u,dispatch:m,clearCart:function(){m({type:"SET_ITEMS",payload:[]})}}},e)},f=function(){return o(l)};export{m as CartProvider,f as useCart};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__assign as l}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useReducer as s,useContext as i,createContext as r}from"react";import{isCustomerProfileComplete as t}from"../../../lib/isCustomerProfileComplete.js";import{isAddressComplete as d}from"../../../lib/isAddressComplete.js";import{areBusinessCredentailsComplete as a}from"../../../lib/areBusinessCredentialsComplete.js";import{useClientSideCart as m}from"../../../components/e-commerce/cart/hooks.js";import{useSession as n}from"../../auth/SessionContext.js";import p from"../../../lib/isVATValid.js";import u from"../../../lib/isEORIValid.js";var C={itemsInCart:!1,customerProfileComplete:!1,companyAddressComplete:!1,deliveryAddressComplete:!1,billingAddressComplete:!1,businessCredentailsComplete:!1,hasValidatedVAT:!1,hasValidatedEORI:!1},c=r({state:C,runAllChecks:function(){}}),v=function(e,o){if("UPDATE_CONFIRMATIONS"===o.type){var s=o.payload.itemsInCart,i=o.payload.customerProfileComplete,r=o.payload.companyAddressComplete,t=o.payload.deliveryAddressComplete,d=o.payload.billingAddressComplete,a=o.payload.businessCredentailsComplete,m=o.payload.hasValidatedVAT,n=o.payload.hasValidatedEORI;return l(l({},e),{itemsInCart:s,customerProfileComplete:i,companyAddressComplete:r,deliveryAddressComplete:t,billingAddressComplete:d,businessCredentailsComplete:a,hasValidatedVAT:m,hasValidatedEORI:n})}return e},f=function(l){var i=l.children,r=e(s(v,C),2),f=r[0],A=r[1],y=n(),b=y.user;y.loading,y.error;var _=m(),V={state:f,runAllChecks:function(){var e,l,o,s,i,r,m=_.state.items.length>0,n=t(null==b?void 0:b.customer_profile),C=d(null===(e=null==b?void 0:b.customer_profile)||void 0===e?void 0:e.company_address),c=d(null===(l=null==b?void 0:b.customer_profile)||void 0===l?void 0:l.delivery_address),v=d(null===(o=null==b?void 0:b.customer_profile)||void 0===o?void 0:o.billing_address),f=a(null===(s=null==b?void 0:b.customer_profile)||void 0===s?void 0:s.business_credentials),y=p(null===(i=null==b?void 0:b.customer_profile)||void 0===i?void 0:i.business_credentials),V=u(null===(r=null==b?void 0:b.customer_profile)||void 0===r?void 0:r.business_credentials);A({type:"UPDATE_CONFIRMATIONS",payload:{itemsInCart:m,customerProfileComplete:n,companyAddressComplete:C,deliveryAddressComplete:c,billingAddressComplete:v,businessCredentailsComplete:f,hasValidatedVAT:y,hasValidatedEORI:V}})}};return o.createElement(c.Provider,{value:V},i)},A=function(){return i(c)};export{f as CheckoutProvider,A as useCheckout};
7
+ import{__read as e,__assign as l}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useReducer as s,useContext as i,createContext as r}from"react";import{isCustomerProfileComplete as t}from"../../../lib/isCustomerProfileComplete.js";import{isAddressComplete as d}from"../../../lib/isAddressComplete.js";import{areBusinessCredentailsComplete as a}from"../../../lib/areBusinessCredentialsComplete.js";import{useClientSideCart as n}from"../../../components/e-commerce/cart/hooks.js";import{useSession as m}from"../../auth/SessionContext.js";import p from"../../../lib/isVATValid.js";import u from"../../../lib/isEORIValid.js";var C={itemsInCart:!1,customerProfileComplete:!1,companyAddressComplete:!1,deliveryAddressComplete:!1,billingAddressComplete:!1,businessCredentailsComplete:!1,hasValidatedVAT:!1,hasValidatedEORI:!1},c=r({state:C,runAllChecks:function(){},handleClearCart:function(){}}),v=function(e,o){if("UPDATE_CONFIRMATIONS"===o.type){var s=o.payload.itemsInCart,i=o.payload.customerProfileComplete,r=o.payload.companyAddressComplete,t=o.payload.deliveryAddressComplete,d=o.payload.billingAddressComplete,a=o.payload.businessCredentailsComplete,n=o.payload.hasValidatedVAT,m=o.payload.hasValidatedEORI;return l(l({},e),{itemsInCart:s,customerProfileComplete:i,companyAddressComplete:r,deliveryAddressComplete:t,billingAddressComplete:d,businessCredentailsComplete:a,hasValidatedVAT:n,hasValidatedEORI:m})}return e},f=function(l){var i=l.children,r=e(s(v,C),2),f=r[0],A=r[1],y=m(),b=y.user;y.loading,y.error;var h=n(),_={state:f,runAllChecks:function(){var e,l,o,s,i,r,n=h.state.items.length>0,m=t(null==b?void 0:b.customer_profile),C=d(null===(e=null==b?void 0:b.customer_profile)||void 0===e?void 0:e.company_address),c=d(null===(l=null==b?void 0:b.customer_profile)||void 0===l?void 0:l.delivery_address),v=d(null===(o=null==b?void 0:b.customer_profile)||void 0===o?void 0:o.billing_address),f=a(null===(s=null==b?void 0:b.customer_profile)||void 0===s?void 0:s.business_credentials),y=p(null===(i=null==b?void 0:b.customer_profile)||void 0===i?void 0:i.business_credentials),_=u(null===(r=null==b?void 0:b.customer_profile)||void 0===r?void 0:r.business_credentials);A({type:"UPDATE_CONFIRMATIONS",payload:{itemsInCart:n,customerProfileComplete:m,companyAddressComplete:C,deliveryAddressComplete:c,billingAddressComplete:v,businessCredentailsComplete:f,hasValidatedVAT:y,hasValidatedEORI:_}})},handleClearCart:function(){h.clearCart()}};return o.createElement(c.Provider,{value:_},i)},A=function(){return i(c)};export{f as CheckoutProvider,A as useCheckout};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- function s(s){if(s.eori_number){var e=(null==s?void 0:s.eori_validate_response)||{status:"1",statusDescr:"Valid"},t=Boolean("0"===e.status&&"Valid"===e.statusDescr);return console.log("isEORIValid",t),t}return!1}export{s as default};
6
+ function s(s){if(null==s?void 0:s.eori_number){var e=(null==s?void 0:s.eori_validate_response)||{status:"1",statusDescr:"Valid"},t=Boolean("0"===e.status&&"Valid"===e.statusDescr);return console.log("isEORIValid",t),t}return!1}export{s as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__awaiter as e,__generator as o}from"../../node_modules/tslib/tslib.es6.js";import{createMollieClient as r}from"../../node_modules/@mollie/api-client/dist/mollie.esm.js";var t=r({apiKey:"".concat(process.env.MOLLIE_KEY)});function n(r){return e(this,void 0,void 0,(function(){var e,n,c,i,a;return o(this,(function(o){switch(o.label){case 0:return e=r.id,n=r.opo_number,c=r.total_incl_vat,i=r.order_currency,a=r.uuid,console.log(r),e&&n&&c&&i&&a?[4,t.payments.create({amount:{currency:i,value:c.toFixed(2)},description:"Order #".concat(n),redirectUrl:"".concat(process.env.FRONTEND_URL,"/shop/check-out?order=").concat(a),webhookUrl:"".concat(process.env.FRONTEND_URL,"/api/mollie"),metadata:{id:e,opo_number:n}}).catch((function(e){return"error from payment creation: ".concat(e)}))]:[2,"missing order data"];case 1:return[2,o.sent()]}}))}))}export{n as createMolliePayment};
7
+ import{__awaiter as e,__generator as o}from"../../node_modules/tslib/tslib.es6.js";import{createMollieClient as r}from"../../node_modules/@mollie/api-client/dist/mollie.esm.js";var t=r({apiKey:"".concat(process.env.MOLLIE_KEY)});function n(r){return e(this,void 0,void 0,(function(){var e,n,c,i,a;return o(this,(function(o){switch(o.label){case 0:return e=r.id,n=r.opo_number,c=r.total_incl_vat,i=r.order_currency,a=r.uuid,e&&n&&c&&i&&a?[4,t.payments.create({amount:{currency:i,value:c.toFixed(2)},description:"Order #".concat(n),redirectUrl:"".concat(process.env.FRONTEND_URL,"/shop/check-out?order=").concat(a),webhookUrl:"".concat(process.env.FRONTEND_URL,"/api/mollie"),metadata:{id:e,opo_number:n}}).catch((function(e){return"error from payment creation: ".concat(e)}))]:[2,"missing order data"];case 1:return[2,o.sent()]}}))}))}export{n as createMolliePayment};