umwd-components 0.1.590 → 0.1.591

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- 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 l from"@mui/material/Stack";import a from"@mui/material/Grid";import i from"@mui/material/Paper";import o from"@mui/material/Box";import m from"@mui/material/Button";import s from"@mui/material/Stepper";import c from"@mui/material/Step";import u from"@mui/material/StepLabel";import p from"@mui/material/MobileStepper";import d from"@mui/material/Alert";import f from"@mui/material/useMediaQuery";import{useTheme as E}from"@mui/material/styles";import x,{useState as g,useEffect as v,useMemo as b}from"react";import h from"next/link";import{useSearchParams as y}from"next/navigation";import{useSession as k}from"../../../context/auth/SessionContext.js";import B from"@mui/icons-material/KeyboardArrowLeft";import C from"@mui/icons-material/KeyboardArrowRight";import S from"./Step1.js";import _ from"./Step2.js";import A from"./Step3.js";import j from"./Step4.js";import N from"./Step5.js";import{useCheckout as D}from"../../../context/e-commerce/checkout/CheckoutContext.js";import{useCart as P}from"../../../context/e-commerce/cart/CartContext.js";import w from"../../../lib/isCustomerProfileCompleteEnough.js";function z(z){var I=z.shopUrl,O=void 0===I?"/shop":I,T=E(),H=f(T.breakpoints.down("sm")),L=D(),M=L.state,R=L.runAllChecks,V=L.togglePrefersBillingAddress,F=L.togglePrefersDeliveryAddress,K=L.setCustomerInternalReference,G=P().dispatch,Q=k(),U=Q.loading;Q.error;var q=Q.user;Q.login;var J=Q.logout,W=t(g(0),2),X=W[0],Y=W[1],Z=t(g(null),2),$=Z[0],ee=Z[1],te=t(g(null),2),re=te[0],ne=te[1],le=function(){Y((function(e){return e+1}))},ae=function(){Y((function(e){return e-1}))},ie=y();v((function(){if(null!==ie){var e=ie.get("order");e&&ee(e);var t=ie.get("message"),r=ie.get("severity");t&&r&&ne({message:t,severity:r})}}),[ie]),v((function(){$&&(Y(4),localStorage.removeItem("cart"),G({type:"SET_ITEMS",payload:[]}))}),[$]),v((function(){q&&(console.log("checkout change in user"),R())}),[q]);var oe=!M.confirmations.itemsInCart,me=null!==(null==q?void 0:q.customer_profile)&&w(null==q?void 0:q.customer_profile),se=b((function(){return[{label:"Login or register",children:x.createElement(S,{user:q,logout:J}),backButton:x.createElement(m,{variant:H?"text":"outlined",disabled:0===X,onClick:ae,sx:{mr:1}},"Back",H&&x.createElement(B,null)),nextButton:x.createElement(m,{variant:H?"text":"contained",onClick:le,sx:{ml:1},disabled:(!q||oe)&&"production"===process.env.NODE_ENV,size:H?"small":"large"},"Next",H&&x.createElement(C,null))},{label:"Provide us with your address",children:x.createElement(_,null),backButton:x.createElement(m,{size:H?"small":"large",onClick:ae,disabled:0===X,variant:H?"text":"outlined"},"Back",H&&x.createElement(B,null)),nextButton:x.createElement(m,{size:H?"small":"large",variant:H?"text":"contained",onClick:function(){le()},disabled:(!q||oe||me)&&"production"===process.env.NODE_ENV},"Next",H&&x.createElement(C,null))},{label:"Set up mailing options",children:x.createElement(A,{user:q,prefersBillingAddress:M.prefersBillingAddress,prefersDeliveryAddress:M.prefersDeliveryAddress,delivery_options:M.delivery_options,payment_options:M.payment_options,togglePrefersBillingAddress:V,togglePrefersDeliveryAddress:F,setCustomerInternalReference:K}),backButton:x.createElement(m,{size:H?"small":"large",variant:H?"text":"outlined",onClick:ae,disabled:0===X},"Back",H&&x.createElement(B,null)),nextButton:x.createElement(m,{size:H?"small":"large",variant:H?"text":"contained",onClick:function(){le()},disabled:(!q||oe||me)&&"production"===process.env.NODE_ENV},"Next",H&&x.createElement(C,null))},{label:"Confirm and make a payment",children:x.createElement(j,{customer_internal_reference:M.customer_internal_reference}),nextButton:x.createElement(x.Fragment,null,x.createElement(m,{size:H?"small":"large",variant:H?"text":"contained",onClick:function(){le()},disabled:!0},"Next",H&&x.createElement(C,null))),backButton:x.createElement(m,{size:H?"small":"large",variant:H?"text":"outlined",onClick:ae,disabled:0===X},"Back",H&&x.createElement(B,null))},{label:"Done!",children:x.createElement(N,null)}]}),[q,oe,me,M,H,X]);return x.createElement(n,{sx:{py:2,minHeight:"100vh"}},x.createElement(a,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"}},x.createElement(a,{item:!0,xs:12},x.createElement(r,{variant:"h4",align:"center"},"Check Out")),oe&&4!=X&&x.createElement(a,{item:!0,xs:12},x.createElement(d,{severity:"error"},x.createElement(r,{variant:"h5"},"No products in cart"),x.createElement(r,{variant:"body1"},"There are no products selected to order, please visit the shop befor continuing"))),null!=re&&x.createElement(a,{item:!0,xs:12},x.createElement(d,{severity:re.severity},x.createElement(r,{variant:"body1"},re.message))),x.createElement(a,{item:!0,xs:12},x.createElement(o,{width:"100%"},x.createElement(i,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}}},x.createElement(l,{direction:"row",spacing:2,alignItems:"center"},x.createElement(r,{variant:"body2"},"".concat(X+1," / ").concat(se.length)),x.createElement(r,null,"".concat(se[X].label)))),x.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},x.createElement(s,{activeStep:X},se.map((function(t,r){var n={};return x.createElement(c,e({key:r},{},{sx:{pb:"20px"}}),x.createElement(u,n,t.label))})))),!U&&x.createElement(x.Fragment,null,se[X].children,x.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},x.createElement(l,{direction:"row",spacing:2},se[X].backButton,x.createElement(m,{variant:"outlined",sx:{ml:1}},x.createElement(h,{href:O},"continue shopping")),x.createElement(o,{sx:{flex:"1 1 auto"}}),se[X].nextButton))))),x.createElement(a,{item:!0,xs:12},x.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:se.length,position:"static",activeStep:X,nextButton:se[X].nextButton,backButton:se[X].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 l from"@mui/material/Stack";import o from"@mui/material/Grid";import i from"@mui/material/Paper";import a from"@mui/material/Box";import m from"@mui/material/Button";import s from"@mui/material/Stepper";import c from"@mui/material/Step";import u from"@mui/material/StepLabel";import p from"@mui/material/MobileStepper";import d from"@mui/material/Alert";import f from"@mui/material/useMediaQuery";import{useTheme as E}from"@mui/material/styles";import g,{useState as x,useEffect as v,useMemo as b}from"react";import h from"next/link";import{useSearchParams as y}from"next/navigation";import{useSession as k}from"../../../context/auth/SessionContext.js";import B from"@mui/icons-material/KeyboardArrowLeft";import C from"@mui/icons-material/KeyboardArrowRight";import _ from"./Step1.js";import S from"./Step2.js";import A from"./Step3.js";import j from"./Step4.js";import N from"./Step5.js";import{useCheckout as D}from"../../../context/e-commerce/checkout/CheckoutContext.js";import{useCart as P}from"../../../context/e-commerce/cart/CartContext.js";import w from"../../../lib/isCustomerProfileCompleteEnough.js";function z(z){var I=z.shopUrl,O=void 0===I?"/shop":I,T=E(),H=f(T.breakpoints.down("sm")),L=D(),M=L.state,R=L.runAllChecks,V=L.togglePrefersBillingAddress,F=L.togglePrefersDeliveryAddress,K=L.setCustomerInternalReference,G=P().dispatch,Q=k(),U=Q.loading;Q.error;var q=Q.user;Q.login;var J=Q.logout,W=t(x(0),2),X=W[0],Y=W[1],Z=t(x(null),2),$=Z[0],ee=Z[1],te=t(x(null),2),re=te[0],ne=te[1],le=function(){Y((function(e){return e+1}))},oe=function(){Y((function(e){return e-1}))},ie=y();v((function(){if(null!==ie){var e=ie.get("order");e&&ee(e);var t=ie.get("message"),r=ie.get("severity");t&&r&&ne({message:t,severity:r})}}),[ie]),v((function(){$&&(Y(4),localStorage.removeItem("cart"),G({type:"SET_ITEMS",payload:[]}))}),[$]),v((function(){q&&(console.log("checkout change in user"),R())}),[q]);var ae=!M.confirmations.itemsInCart,me=b((function(){return console.log("completeEnough",w(null==q?void 0:q.customer_profile)),null!==(null==q?void 0:q.customer_profile)&&w(null==q?void 0:q.customer_profile)}),[null==q?void 0:q.customer_profile]),se=b((function(){return[{label:"Login or register",children:g.createElement(_,{user:q,logout:J}),backButton:g.createElement(m,{variant:H?"text":"outlined",disabled:0===X,onClick:oe,sx:{mr:1}},"Back",H&&g.createElement(B,null)),nextButton:g.createElement(m,{variant:H?"text":"contained",onClick:le,sx:{ml:1},disabled:(!q||ae)&&"production"===process.env.NODE_ENV,size:H?"small":"large"},"Next",H&&g.createElement(C,null))},{label:"Provide us with your address",children:g.createElement(S,null),backButton:g.createElement(m,{size:H?"small":"large",onClick:oe,disabled:0===X,variant:H?"text":"outlined"},"Back",H&&g.createElement(B,null)),nextButton:g.createElement(m,{size:H?"small":"large",variant:H?"text":"contained",onClick:function(){le()},disabled:(!q||ae||!me)&&"production"===process.env.NODE_ENV},"Next",H&&g.createElement(C,null))},{label:"Set up mailing options",children:g.createElement(A,{user:q,prefersBillingAddress:M.prefersBillingAddress,prefersDeliveryAddress:M.prefersDeliveryAddress,delivery_options:M.delivery_options,payment_options:M.payment_options,togglePrefersBillingAddress:V,togglePrefersDeliveryAddress:F,setCustomerInternalReference:K}),backButton:g.createElement(m,{size:H?"small":"large",variant:H?"text":"outlined",onClick:oe,disabled:0===X},"Back",H&&g.createElement(B,null)),nextButton:g.createElement(m,{size:H?"small":"large",variant:H?"text":"contained",onClick:function(){le()},disabled:(!q||ae||!me)&&"production"===process.env.NODE_ENV},"Next",H&&g.createElement(C,null))},{label:"Confirm and make a payment",children:g.createElement(j,{customer_internal_reference:M.customer_internal_reference}),nextButton:g.createElement(g.Fragment,null,g.createElement(m,{size:H?"small":"large",variant:H?"text":"contained",onClick:function(){le()},disabled:!0},"Next",H&&g.createElement(C,null))),backButton:g.createElement(m,{size:H?"small":"large",variant:H?"text":"outlined",onClick:oe,disabled:0===X},"Back",H&&g.createElement(B,null))},{label:"Done!",children:g.createElement(N,null)}]}),[q,ae,me,M,H,X]);return g.createElement(n,{sx:{py:2,minHeight:"100vh"}},g.createElement(o,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"}},g.createElement(o,{item:!0,xs:12},g.createElement(r,{variant:"h4",align:"center"},"Check Out")),ae&&4!=X&&g.createElement(o,{item:!0,xs:12},g.createElement(d,{severity:"error"},g.createElement(r,{variant:"h5"},"No products in cart"),g.createElement(r,{variant:"body1"},"There are no products selected to order, please visit the shop befor continuing"))),null!=re&&g.createElement(o,{item:!0,xs:12},g.createElement(d,{severity:re.severity},g.createElement(r,{variant:"body1"},re.message))),g.createElement(o,{item:!0,xs:12},g.createElement(a,{width:"100%"},g.createElement(i,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}}},g.createElement(l,{direction:"row",spacing:2,alignItems:"center"},g.createElement(r,{variant:"body2"},"".concat(X+1," / ").concat(se.length)),g.createElement(r,null,"".concat(se[X].label)))),g.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},g.createElement(s,{activeStep:X},se.map((function(t,r){var n={};return g.createElement(c,e({key:r},{},{sx:{pb:"20px"}}),g.createElement(u,n,t.label))})))),!U&&g.createElement(g.Fragment,null,se[X].children,g.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},g.createElement(l,{direction:"row",spacing:2},se[X].backButton,g.createElement(m,{variant:"outlined",sx:{ml:1}},g.createElement(h,{href:O},"continue shopping")),g.createElement(a,{sx:{flex:"1 1 auto"}}),se[X].nextButton))))),g.createElement(o,{item:!0,xs:12},g.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:se.length,position:"static",activeStep:X,nextButton:se[X].nextButton,backButton:se[X].backButton}))))}export{z as default};