umwd-components 0.1.452 → 0.1.454

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