umwd-components 0.1.412 → 0.1.413

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{__exports as r}from"../../_virtual/index8.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
6
+ import{__exports as r}from"../../_virtual/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
@@ -3,5 +3,5 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as a}from"../../_virtual/index7.js";
6
+ import{__exports as a}from"../../_virtual/index8.js";
7
7
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
@@ -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 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};
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};
@@ -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 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};
7
+ import{extends as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{__read as t}from"../../../../node_modules/tslib/tslib.es6.js";import r from"@mui/material/Typography";import n 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 y from"./Step1.js";import C 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";import{useCart as z}from"../../../context/e-commerce/cart/CartContext.js";function _(_){var D=_.shopUrl,O=void 0===D?"/shop":D,P=x(),T=d(P.breakpoints.down("sm")),A=w(),H=A.state,I=A.runAllChecks,L=z().dispatch,M=t(f(0),2),V=M[0],F=M[1],K=function(){F((function(e){return e+1}))},G=function(){F((function(e){return e-1}))},Q=v(),R=Q.loading;Q.error;var U=Q.user,q=k();b((function(){null!==q&&(q.get("order")&&(F(4),L({type:"SET_ITEMS",payload:[]})))}),[q]),b((function(){I()}),[U]);var J=!H.itemsInCart,W=!H.customerProfileComplete,X=[{label:"Login or register",children:E.createElement(y,null),backButton:E.createElement(m,{variant:T?"text":"outlined",disabled:0===V,onClick:G,sx:{mr:1}},"Back",T&&E.createElement(g,null)),nextButton:E.createElement(m,{variant:T?"text":"contained",onClick:K,sx:{ml:1},disabled:(!U||J)&&"production"===process.env.NODE_ENV,size:T?"small":"large"},"Next",T&&E.createElement(B,null))},{label:"Provide us with your address",children:E.createElement(C,null),backButton:E.createElement(m,{size:T?"small":"large",onClick:G,disabled:0===V,variant:T?"text":"outlined"},"Back",T&&E.createElement(g,null)),nextButton:E.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){K()},disabled:(!U||J||W)&&"production"===process.env.NODE_ENV},"Next",T&&E.createElement(B,null))},{label:"Set up mailing options",children:E.createElement(S,null),backButton:E.createElement(m,{size:T?"small":"large",variant:T?"text":"outlined",onClick:G,disabled:0===V},"Back",T&&E.createElement(g,null)),nextButton:E.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){K()},disabled:(!U||J||W)&&"production"===process.env.NODE_ENV},"Next",T&&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:T?"small":"large",variant:T?"text":"contained",onClick:function(){K()},disabled:!0},"Next",T&&E.createElement(B,null))),backButton:E.createElement(m,{size:T?"small":"large",variant:T?"text":"outlined",onClick:G,disabled:0===V},"Back",T&&E.createElement(g,null))},{label:"Done!",children:E.createElement(j,null)}];return E.createElement(n,{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(r,{variant:"h4",align:"center"},"Check Out")),J&&4!=V&&E.createElement(l,{item:!0,xs:12},E.createElement(o,{sx:{color:"red",border:"2px solid red",p:2}},E.createElement(r,{variant:"h5"},"No products in cart"),E.createElement(r,{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(r,{variant:"body2"},"".concat(V+1," / ").concat(X.length)),E.createElement(r,null,"".concat(X[V].label)))),E.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},E.createElement(c,{activeStep:V},X.map((function(t,r){var n={};return E.createElement(s,e({key:r},{},{sx:{pb:"20px"}}),E.createElement(u,n,t.label))})))),!R&&E.createElement(E.Fragment,null,X[V].children,E.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},E.createElement(a,{direction:"row",spacing:2},X[V].backButton,E.createElement(m,{variant:"outlined",sx:{ml:1}},E.createElement(h,{href:O},"continue shopping")),E.createElement(o,{sx:{flex:"1 1 auto"}}),X[V].nextButton))))),E.createElement(l,{item:!0,xs:12},E.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:X.length,position:"static",activeStep:V,nextButton:X[V].nextButton,backButton:X[V].backButton}))))}export{_ 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 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};
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};
@@ -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(){},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};
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};
@@ -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 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};
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};