umwd-components 0.1.494 → 0.1.495

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 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/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 k}from"next/navigation";import{useSession as y}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 N from"./Step4.js";import j 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";function w(w){var z=w.shopUrl,I=void 0===z?"/shop":z,O=E(),T=f(O.breakpoints.down("sm")),H=D(),L=H.state,M=H.runAllChecks,R=H.togglePrefersBillingAddress,V=H.togglePrefersDeliveryAddress,F=H.setCustomerInternalReference,K=P().dispatch,G=y(),Q=G.loading;G.error;var U=G.user;G.login;var q=G.logout,J=t(g(0),2),W=J[0],X=J[1],Y=t(g(null),2),Z=Y[0],$=Y[1],ee=function(){X((function(e){return e+1}))},te=function(){X((function(e){return e-1}))},re=k();v((function(){if(null!==re){var e=re.get("order");e&&$(e)}}),[re]),v((function(){Z&&(X(4),localStorage.removeItem("cart"),K({type:"SET_ITEMS",payload:[]}))}),[Z]),v((function(){M()}),[U]);var ne=!L.confirmations.itemsInCart,ae=!L.confirmations.customerProfileComplete,le=b((function(){return[{label:"Login or register",children:x.createElement(S,{user:U,logout:q}),backButton:x.createElement(m,{variant:T?"text":"outlined",disabled:0===W,onClick:te,sx:{mr:1}},"Back",T&&x.createElement(B,null)),nextButton:x.createElement(m,{variant:T?"text":"contained",onClick:ee,sx:{ml:1},disabled:(!U||ne)&&"production"===process.env.NODE_ENV,size:T?"small":"large"},"Next",T&&x.createElement(C,null))},{label:"Provide us with your address",children:x.createElement(_,null),backButton:x.createElement(m,{size:T?"small":"large",onClick:te,disabled:0===W,variant:T?"text":"outlined"},"Back",T&&x.createElement(B,null)),nextButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){ee()},disabled:(!U||ne||ae)&&"production"===process.env.NODE_ENV},"Next",T&&x.createElement(C,null))},{label:"Set up mailing options",children:x.createElement(A,{user:U,prefersBillingAddress:L.prefersBillingAddress,prefersDeliveryAddress:L.prefersDeliveryAddress,delivery_options:L.delivery_options,payment_options:L.payment_options,togglePrefersBillingAddress:R,togglePrefersDeliveryAddress:V,setCustomerInternalReference:F}),backButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"outlined",onClick:te,disabled:0===W},"Back",T&&x.createElement(B,null)),nextButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){ee()},disabled:(!U||ne||ae)&&"production"===process.env.NODE_ENV},"Next",T&&x.createElement(C,null))},{label:"Confirm and make a payment",children:x.createElement(N,{customer_internal_reference:L.customer_internal_reference}),nextButton:x.createElement(x.Fragment,null,x.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){ee()},disabled:!0},"Next",T&&x.createElement(C,null))),backButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"outlined",onClick:te,disabled:0===W},"Back",T&&x.createElement(B,null))},{label:"Done!",children:x.createElement(j,null)}]}),[U,ne,ae,L,T,W]);return x.createElement(n,{sx:{py:2,minHeight:"100vh"}},x.createElement(l,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"}},x.createElement(l,{item:!0,xs:12},x.createElement(r,{variant:"h4",align:"center"},"Check Out")),ne&&4!=W&&x.createElement(l,{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"))),x.createElement(l,{item:!0,xs:12},x.createElement(o,{width:"100%"},x.createElement(i,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}}},x.createElement(a,{direction:"row",spacing:2,alignItems:"center"},x.createElement(r,{variant:"body2"},"".concat(W+1," / ").concat(le.length)),x.createElement(r,null,"".concat(le[W].label)))),x.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},x.createElement(c,{activeStep:W},le.map((function(t,r){var n={};return x.createElement(s,e({key:r},{},{sx:{pb:"20px"}}),x.createElement(u,n,t.label))})))),!Q&&x.createElement(x.Fragment,null,le[W].children,x.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},x.createElement(a,{direction:"row",spacing:2},le[W].backButton,x.createElement(m,{variant:"outlined",sx:{ml:1}},x.createElement(h,{href:I},"continue shopping")),x.createElement(o,{sx:{flex:"1 1 auto"}}),le[W].nextButton))))),x.createElement(l,{item:!0,xs:12},x.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:le.length,position:"static",activeStep:W,nextButton:le[W].nextButton,backButton:le[W].backButton}))))}export{w 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 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 y from"next/link";import{useSearchParams as h}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 N from"./Step4.js";import j 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";function w(w){var z=w.shopUrl,I=void 0===z?"/shop":z,O=E(),T=f(O.breakpoints.down("sm")),H=D(),L=H.state,M=H.runAllChecks,R=H.togglePrefersBillingAddress,V=H.togglePrefersDeliveryAddress,F=H.setCustomerInternalReference,K=P().dispatch,G=k(),Q=G.loading;G.error;var U=G.user;G.login;var q=G.logout,J=t(g(0),2),W=J[0],X=J[1],Y=t(g(null),2),Z=Y[0],$=Y[1],ee=t(g(null),2),te=ee[0],re=ee[1],ne=function(){X((function(e){return e+1}))},ae=function(){X((function(e){return e-1}))},le=h();v((function(){if(null!==le){var e=le.get("order");e&&$(e);var t=le.get("message"),r=le.get("severity");t&&r&&re({message:t,severity:r})}}),[le]),v((function(){Z&&(X(4),localStorage.removeItem("cart"),K({type:"SET_ITEMS",payload:[]}))}),[Z]),v((function(){M()}),[U]);var ie=!L.confirmations.itemsInCart,oe=!L.confirmations.customerProfileComplete,me=b((function(){return[{label:"Login or register",children:x.createElement(S,{user:U,logout:q}),backButton:x.createElement(m,{variant:T?"text":"outlined",disabled:0===W,onClick:ae,sx:{mr:1}},"Back",T&&x.createElement(B,null)),nextButton:x.createElement(m,{variant:T?"text":"contained",onClick:ne,sx:{ml:1},disabled:(!U||ie)&&"production"===process.env.NODE_ENV,size:T?"small":"large"},"Next",T&&x.createElement(C,null))},{label:"Provide us with your address",children:x.createElement(_,null),backButton:x.createElement(m,{size:T?"small":"large",onClick:ae,disabled:0===W,variant:T?"text":"outlined"},"Back",T&&x.createElement(B,null)),nextButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){ne()},disabled:(!U||ie||oe)&&"production"===process.env.NODE_ENV},"Next",T&&x.createElement(C,null))},{label:"Set up mailing options",children:x.createElement(A,{user:U,prefersBillingAddress:L.prefersBillingAddress,prefersDeliveryAddress:L.prefersDeliveryAddress,delivery_options:L.delivery_options,payment_options:L.payment_options,togglePrefersBillingAddress:R,togglePrefersDeliveryAddress:V,setCustomerInternalReference:F}),backButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"outlined",onClick:ae,disabled:0===W},"Back",T&&x.createElement(B,null)),nextButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){ne()},disabled:(!U||ie||oe)&&"production"===process.env.NODE_ENV},"Next",T&&x.createElement(C,null))},{label:"Confirm and make a payment",children:x.createElement(N,{customer_internal_reference:L.customer_internal_reference}),nextButton:x.createElement(x.Fragment,null,x.createElement(m,{size:T?"small":"large",variant:T?"text":"contained",onClick:function(){ne()},disabled:!0},"Next",T&&x.createElement(C,null))),backButton:x.createElement(m,{size:T?"small":"large",variant:T?"text":"outlined",onClick:ae,disabled:0===W},"Back",T&&x.createElement(B,null))},{label:"Done!",children:x.createElement(j,null)}]}),[U,ie,oe,L,T,W]);return x.createElement(n,{sx:{py:2,minHeight:"100vh"}},x.createElement(l,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"}},x.createElement(l,{item:!0,xs:12},x.createElement(r,{variant:"h4",align:"center"},"Check Out")),ie&&4!=W&&x.createElement(l,{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!=te&&x.createElement(l,{item:!0,xs:12},x.createElement(d,{severity:te.severity},x.createElement(r,{variant:"body1"},te.message))),x.createElement(l,{item:!0,xs:12},x.createElement(o,{width:"100%"},x.createElement(i,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}}},x.createElement(a,{direction:"row",spacing:2,alignItems:"center"},x.createElement(r,{variant:"body2"},"".concat(W+1," / ").concat(me.length)),x.createElement(r,null,"".concat(me[W].label)))),x.createElement(i,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}}},x.createElement(s,{activeStep:W},me.map((function(t,r){var n={};return x.createElement(c,e({key:r},{},{sx:{pb:"20px"}}),x.createElement(u,n,t.label))})))),!Q&&x.createElement(x.Fragment,null,me[W].children,x.createElement(i,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}}},x.createElement(a,{direction:"row",spacing:2},me[W].backButton,x.createElement(m,{variant:"outlined",sx:{ml:1}},x.createElement(y,{href:I},"continue shopping")),x.createElement(o,{sx:{flex:"1 1 auto"}}),me[W].nextButton))))),x.createElement(l,{item:!0,xs:12},x.createElement(p,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:me.length,position:"static",activeStep:W,nextButton:me[W].nextButton,backButton:me[W].backButton}))))}export{w as default};