umwd-components 0.1.424 → 0.1.426

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.
Files changed (25) hide show
  1. package/dist/src/components/e-commerce/checkout/CheckoutForm.js +1 -1
  2. package/dist/src/components/e-commerce/checkout/Step1.js +1 -1
  3. package/dist/src/components/e-commerce/checkout/Step2.js +1 -1
  4. package/dist/src/context/e-commerce/checkout/CheckoutContext.js +1 -1
  5. package/dist/tsconfig.build.tsbuildinfo +1 -1
  6. package/dist/types/components/e-commerce/checkout/Step1.d.ts +5 -1
  7. package/dist/types/types/e-commerce/checkout/types.d.ts +10 -8
  8. package/package.json +1 -1
  9. package/src/components/e-commerce/checkout/CheckoutForm.tsx +7 -6
  10. package/src/components/e-commerce/checkout/Step1.tsx +8 -3
  11. package/src/components/e-commerce/checkout/Step2.tsx +8 -9
  12. package/src/context/e-commerce/checkout/CheckoutContext.tsx +20 -16
  13. package/src/types/e-commerce/checkout/types.ts +10 -8
  14. package/dist/types/components/e-commerce/checkoutV2/CheckoutForm.d.ts +0 -6
  15. package/dist/types/components/e-commerce/checkoutV2/Step1.d.ts +0 -8
  16. package/dist/types/components/e-commerce/checkoutV2/Step2.d.ts +0 -3
  17. package/dist/types/components/e-commerce/checkoutV2/Step3.d.ts +0 -3
  18. package/dist/types/components/e-commerce/checkoutV2/Step4.d.ts +0 -3
  19. package/dist/types/components/e-commerce/checkoutV2/Step5.d.ts +0 -3
  20. package/src/components/e-commerce/checkoutV2/CheckoutForm.tsx +0 -345
  21. package/src/components/e-commerce/checkoutV2/Step1.tsx +0 -122
  22. package/src/components/e-commerce/checkoutV2/Step2.tsx +0 -83
  23. package/src/components/e-commerce/checkoutV2/Step3.tsx +0 -478
  24. package/src/components/e-commerce/checkoutV2/Step4.tsx +0 -184
  25. package/src/components/e-commerce/checkoutV2/Step5.tsx +0 -81
@@ -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 r from"@mui/material/Typography";import n from"@mui/material/Container";import a from"@mui/material/Stack";import l from"@mui/material/Grid";import o from"@mui/material/Paper";import i 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,I=void 0===D?"/shop":D,O=x(),P=d(O.breakpoints.down("sm")),T=w(),A=T.state,H=T.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),localStorage.removeItem("cart"),L({type:"SET_ITEMS",payload:[]})))}),[q]),b((function(){H()}),[U]);var J=!A.itemsInCart,W=!A.customerProfileComplete,X=[{label:"Login or register",children:E.createElement(y,null),backButton:E.createElement(m,{variant:P?"text":"outlined",disabled:0===V,onClick:G,sx:{mr:1}},"Back",P&&E.createElement(g,null)),nextButton:E.createElement(m,{variant:P?"text":"contained",onClick:K,sx:{ml:1},disabled:(!U||J)&&"production"===process.env.NODE_ENV,size:P?"small":"large"},"Next",P&&E.createElement(B,null))},{label:"Provide us with your address",children:E.createElement(C,null),backButton:E.createElement(m,{size:P?"small":"large",onClick:G,disabled:0===V,variant:P?"text":"outlined"},"Back",P&&E.createElement(g,null)),nextButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){K()},disabled:(!U||J||W)&&"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:G,disabled:0===V},"Back",P&&E.createElement(g,null)),nextButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){K()},disabled:(!U||J||W)&&"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(){K()},disabled:!0},"Next",P&&E.createElement(B,null))),backButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"outlined",onClick:G,disabled:0===V},"Back",P&&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(i,{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(i,{width:"100%"},E.createElement(o,{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(o,{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(o,{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:I},"continue shopping")),E.createElement(i,{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};
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 o from"@mui/material/Paper";import i 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 g from"next/link";import{useSearchParams as v}from"next/navigation";import{useSession as h}from"../../../context/auth/SessionContext.js";import k 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,I=void 0===D?"/shop":D,O=x(),P=d(O.breakpoints.down("sm")),T=w(),A=T.state,H=T.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=h(),R=Q.loading;Q.error;var U=Q.user;Q.login;var q=Q.logout,J=v();b((function(){null!==J&&(J.get("order")&&(F(4),localStorage.removeItem("cart"),L({type:"SET_ITEMS",payload:[]})))}),[J,L]),b((function(){H()}),[U,H]);var W=!A.confirmations.itemsInCart,X=!A.confirmations.customerProfileComplete,Y=[{label:"Login or register",children:E.createElement(y,{user:U,logout:q}),backButton:E.createElement(m,{variant:P?"text":"outlined",disabled:0===V,onClick:G,sx:{mr:1}},"Back",P&&E.createElement(k,null)),nextButton:E.createElement(m,{variant:P?"text":"contained",onClick:K,sx:{ml:1},disabled:(!U||W)&&"production"===process.env.NODE_ENV,size:P?"small":"large"},"Next",P&&E.createElement(B,null))},{label:"Provide us with your address",children:E.createElement(C,null),backButton:E.createElement(m,{size:P?"small":"large",onClick:G,disabled:0===V,variant:P?"text":"outlined"},"Back",P&&E.createElement(k,null)),nextButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){K()},disabled:(!U||W||X)&&"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:G,disabled:0===V},"Back",P&&E.createElement(k,null)),nextButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"contained",onClick:function(){K()},disabled:(!U||W||X)&&"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(){K()},disabled:!0},"Next",P&&E.createElement(B,null))),backButton:E.createElement(m,{size:P?"small":"large",variant:P?"text":"outlined",onClick:G,disabled:0===V},"Back",P&&E.createElement(k,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")),W&&4!=V&&E.createElement(l,{item:!0,xs:12},E.createElement(i,{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(i,{width:"100%"},E.createElement(o,{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(Y.length)),E.createElement(r,null,"".concat(Y[V].label)))),E.createElement(o,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},E.createElement(c,{activeStep:V},Y.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,Y[V].children,E.createElement(o,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},E.createElement(a,{direction:"row",spacing:2},Y[V].backButton,E.createElement(m,{variant:"outlined",sx:{ml:1}},E.createElement(g,{href:I},"continue shopping")),E.createElement(i,{sx:{flex:"1 1 auto"}}),Y[V].nextButton))))),E.createElement(l,{item:!0,xs:12},E.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:Y.length,position:"static",activeStep:V,nextButton:Y[V].nextButton,backButton:Y[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 from"react";import r from"@mui/material/Box";import n from"@mui/material/CircularProgress";import a from"@mui/material/Paper";import i from"@mui/material/Typography";import o from"@mui/material/Button";import m from"@mui/material/Stack";import{useSession as l}from"../../../context/auth/SessionContext.js";import c from"../../auth/DenseSigninForm.js";import u from"../../auth/DenseRegisterForm.js";function s(){var s=l(),p=s.user,E=s.loading,d=s.error,f=s.logout;if(E)return t.createElement(r,{sx:{display:{xs:"none",md:"flex"},flexGrow:0,position:"relative",width:"40px",height:"40px"}},t.createElement(n,null));if(d)return t.createElement("p",null,"Error: ",d);var g=(null==p?void 0:p.customer_profile)?p.customer_profile:null,h=e(t.useState(!1),2),v=h[0],y=h[1];return t.createElement(a,{sx:{p:2}},p?t.createElement(t.Fragment,null,g?t.createElement(t.Fragment,null,t.createElement(i,{variant:"h6"},"Dearest ",g.first_name," ",g.last_name,", are you ready to checkout?"),t.createElement(m,{spacing:2,direction:"row",alignItems:"center"},t.createElement(i,{variant:"body1"},"Not ",g.first_name," ",g.last_name,"?"),t.createElement(o,{variant:"outlined",onClick:function(){return f()}},"sign in as somebody else"))):t.createElement(t.Fragment,null,t.createElement(i,{variant:"h6"},"Dearest ",p.username,", ",p.email,", are you ready to checkout?"),t.createElement(m,{spacing:2,direction:"row",alignItems:"center"},t.createElement(i,{variant:"body1"},"Not"," ",p.username&&p.email?"".concat(p.username," ").concat(p.email):"".concat(p.username),"?"),t.createElement(o,{variant:"outlined",onClick:function(){return f()}},"sign in as somebody else")))):t.createElement(t.Fragment,null,v?t.createElement(m,{spacing:2},t.createElement(i,{variant:"h6"},"Register to continue"),t.createElement(i,{variant:"body1"},"Enter your details to register an account"),t.createElement(u,{data:{redirect_url:"/shop/check-out"}}),t.createElement(o,{variant:"outlined",onClick:function(){return y(!1)}},"Sign in")):t.createElement(m,{spacing:2},t.createElement(i,{variant:"h6"},"Sign in to continue"),t.createElement(i,{variant:"body1"},"Enter your details to sign in to your account"),t.createElement(c,{data:{redirect_url:"/shop/check-out"}}),t.createElement(o,{variant:"outlined",onClick:function(){return y(!0)}},"Register"))))}export{s as default};
7
+ import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t from"react";import r from"@mui/material/Paper";import n from"@mui/material/Typography";import a from"@mui/material/Button";import i from"@mui/material/Stack";import o from"../../auth/DenseSigninForm.js";import m from"../../auth/DenseRegisterForm.js";function l(l){var c=l.user,u=l.logout,s=(null==c?void 0:c.customer_profile)?c.customer_profile:null,E=e(t.useState(!1),2),d=E[0],g=E[1];return t.createElement(r,{sx:{p:2}},c?t.createElement(t.Fragment,null,s?t.createElement(t.Fragment,null,t.createElement(n,{variant:"h6"},"Dearest ",s.first_name," ",s.last_name,", are you ready to checkout?"),t.createElement(i,{spacing:2,direction:"row",alignItems:"center"},t.createElement(n,{variant:"body1"},"Not ",s.first_name," ",s.last_name,"?"),t.createElement(a,{variant:"outlined",onClick:function(){return u()}},"sign in as somebody else"))):t.createElement(t.Fragment,null,t.createElement(n,{variant:"h6"},"Dearest ",c.username,", ",c.email,", are you ready to checkout?"),t.createElement(i,{spacing:2,direction:"row",alignItems:"center"},t.createElement(n,{variant:"body1"},"Not"," ",c.username&&c.email?"".concat(c.username," ").concat(c.email):"".concat(c.username),"?"),t.createElement(a,{variant:"outlined",onClick:function(){return u()}},"sign in as somebody else")))):t.createElement(t.Fragment,null,d?t.createElement(i,{spacing:2},t.createElement(n,{variant:"h6"},"Register to continue"),t.createElement(n,{variant:"body1"},"Enter your details to register an account"),t.createElement(m,{data:{redirect_url:"/shop/check-out"}}),t.createElement(a,{variant:"outlined",onClick:function(){return g(!1)}},"Sign in")):t.createElement(i,{spacing:2},t.createElement(n,{variant:"h6"},"Sign in to continue"),t.createElement(n,{variant:"body1"},"Enter your details to sign in to your account"),t.createElement(o,{data:{redirect_url:"/shop/check-out"}}),t.createElement(a,{variant:"outlined",onClick:function(){return g(!0)}},"Register"))))}export{l 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 r,{useState as t,useEffect as o}from"react";import i from"@mui/material/Button";import m from"@mui/material/Paper";import a from"@mui/material/Stack";import l from"@mui/material/Box";import n from"@mui/material/CircularProgress";import{useSession as s}from"../../../context/auth/SessionContext.js";import{isCustomerProfileComplete as c}from"../../../lib/isCustomerProfileComplete.js";import u from"../customer/DenseCustomerProfileDisplay.js";import f from"../customer/CustomerProfileEditForm.js";function p(){var p=s(),d=p.user,E=p.loading,x=p.error,C=e(t(null),2),g=C[0];C[1];var v=e(t(!(g&&c(g))),2),h=v[0],j=v[1];if(E||!d)return r.createElement(l,{sx:{display:{xs:"none",md:"flex"},flexGrow:0,position:"relative",width:"40px",height:"40px"}},r.createElement(n,null));if(x)return r.createElement("p",null,"Error: ",x);var P=(null==d?void 0:d.customer_profile)?d.customer_profile:null;return o((function(){console.log("user",d)}),[d]),r.createElement(m,{sx:{p:2}},h?r.createElement(a,{spacing:2},r.createElement(f,{data:P}),r.createElement(i,{variant:"contained",onClick:function(){j(!1)},disabled:!c(P)},"cancel")):r.createElement(a,{spacing:2},r.createElement(u,{data:P}),r.createElement(i,{variant:"contained",onClick:function(){j(!0)}},"Change address")))}export{p as default};
7
+ import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as t,useEffect as o}from"react";import i from"@mui/material/Button";import m from"@mui/material/Paper";import l from"@mui/material/Stack";import a from"@mui/material/Box";import n from"@mui/material/CircularProgress";import{useSession as s}from"../../../context/auth/SessionContext.js";import{isCustomerProfileComplete as c}from"../../../lib/isCustomerProfileComplete.js";import u from"../customer/DenseCustomerProfileDisplay.js";import p from"../customer/CustomerProfileEditForm.js";function f(){var f=s(),d=f.user,E=f.loading,x=f.error,C=e(t((null==d?void 0:d.customer_profile)?d.customer_profile:null),2),g=C[0],h=C[1],v=e(t(!(g&&c(g))),2),j=v[0],P=v[1];return E||!d?r.createElement(a,{sx:{display:{xs:"none",md:"flex"},flexGrow:0,position:"relative",width:"40px",height:"40px"}},r.createElement(n,null)):x?r.createElement("p",null,"Error: ",x):(o((function(){console.log("user changed",d),h((null==d?void 0:d.customer_profile)?d.customer_profile:null)}),[d]),r.createElement(m,{sx:{p:2}},j?r.createElement(l,{spacing:2},r.createElement(p,{data:g}),r.createElement(i,{variant:"contained",onClick:function(){P(!1)},disabled:!c(g)},"cancel")):r.createElement(l,{spacing:2},r.createElement(u,{data:g}),r.createElement(i,{variant:"contained",onClick:function(){P(!0)}},"Change address"))))}export{f as default};
@@ -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={confirmations:{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,n=o.payload.hasValidatedVAT,m=o.payload.hasValidatedEORI;return l(l({},e),{confirmations:{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 _=n(),V={state:f,runAllChecks:function(){var e,l,o,s,i,r,n=_.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),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:n,customerProfileComplete:m,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};