umwd-components 0.1.515 → 0.1.517
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.
- package/dist/src/components/e-commerce/cart/CartWidget.js +1 -1
- package/dist/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
- package/dist/src/context/e-commerce/checkout/CheckoutContext.js +1 -1
- package/dist/src/data/actions/auth-actions.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/types/e-commerce/checkout/types.d.ts +4 -0
- package/package.json +1 -1
- package/src/components/e-commerce/cart/CartWidget.tsx +1 -1
- package/src/components/e-commerce/customer/CustomerProfileDisplay.tsx +2 -2
- package/src/context/e-commerce/checkout/CheckoutContext.tsx +16 -4
- package/src/data/actions/auth-actions.ts +1 -1
- package/src/types/e-commerce/checkout/types.ts +4 -0
|
@@ -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
|
|
7
|
+
import{extends as e}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{__read as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as o}from"react";import a from"@mui/material/Box";import i from"@mui/material/Stack";import m from"@mui/material/Button";import n from"@mui/material/Badge";import l from"@mui/material/IconButton";import p from"@mui/material/CircularProgress";import c from"@mui/material/useMediaQuery";import{useTheme as s}from"@mui/material/styles";import u from"next/link";import x from"@mui/icons-material/ShoppingCart";import d from"./CartSummary.js";import{useClientSideCart as f}from"./hooks.js";import{Grow as g}from"@mui/material";function h(h){var b=h.data,E=b.cartUrl,k=void 0===E?"/shop/cart":E,v=b.checkoutUrl,C=void 0===v?"/shop/check-out":v,y=f(),B=y.state,w=y.isClient,S=t(o(null),2),j=S[0],M=S[1],T=function(e){M(e.currentTarget)},_=function(){M(null)},z=Boolean(j),P=z?"cart-widget-popover":void 0,U=s(),A=c(U.breakpoints.down("sm"));return w?r.createElement(a,{component:"div",sx:{position:"relative",width:"40px",height:"40px",mr:"10px"},onMouseEnter:T,onMouseLeave:_},r.createElement(n,{badgeContent:B.totalAmount,color:"primary"},r.createElement(l,{"aria-describedby":P,onClick:function(e){j?_():T(e)},sx:{color:"primary.contrastText",boxShadow:"0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)","&:hover":{backgroundColor:"primary.dark"}}},r.createElement(x,{sx:{color:"primary.contrastText"}}))),r.createElement(g,e({in:z},z?{}:{timeout:1e3}),r.createElement(a,{id:P,sx:[{position:"absolute",top:"65px",right:0,backgroundColor:"background.paper",boxShadow:2,width:"max-content"}]},r.createElement(d,null),r.createElement(i,{spacing:{xs:1,sm:2},sx:{p:{xs:1,sm:2}}},r.createElement(u,{href:k,legacyBehavior:!0},r.createElement(m,{size:A?"small":"large",variant:"outlined",onClick:function(){_()}},r.createElement(x,null))),r.createElement(u,{href:C,legacyBehavior:!0},r.createElement(m,{size:A?"small":"large",variant:"contained",onClick:function(){_()}},"Check Out")))))):r.createElement(p,null)}export{h as default};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__assign as e}from"../../../../node_modules/tslib/tslib.es6.js";import t from"react";import r from"@mui/material/Paper";import a from"@mui/material/Stack";import
|
|
6
|
+
import{__assign as e}from"../../../../node_modules/tslib/tslib.es6.js";import t from"react";import r from"@mui/material/Paper";import a from"@mui/material/Stack";import m from"@mui/material/Box";import n from"@mui/material/Typography";import i from"@mui/material/Button";import l from"@mui/material/Divider";import o from"@mui/material/Grid";import s from"@mui/icons-material/Person";import c from"@mui/icons-material/Email";import d from"@mui/icons-material/Phone";import p from"../../common/Address.js";import E from"./BusinessCredentials.js";import{StyledLink as u}from"../../StyledLink.js";import{Alert as f}from"@mui/material";import{isCustomerProfileComplete as v}from"../../../lib/isCustomerProfileComplete.js";function y(y){var b=y.data;console.log(b);var _=b.first_name,g=b.last_name,h=b.email,x=b.phone,A=b.company_address,j=b.billing_address,w=b.delivery_address,B=b.business_credentials,C=b.editProfileUrl,P=void 0===C?"/user/profile/edit":C;return t.createElement(r,{sx:{p:2}},t.createElement(a,{spacing:2},v({first_name:_,last_name:g,email:h,phone:x,company_address:A,billing_address:j,delivery_address:w,business_credentials:B})?t.createElement(a,{direction:"row",justifyContent:"flex-end"},t.createElement(u,{href:P,target:"_self"},t.createElement(i,{variant:"contained"},"edit profile"))):t.createElement(f,{severity:"warning",action:t.createElement(u,{href:P,target:"_self"},t.createElement(i,{variant:"contained"},"complete profile"))},"After completion of your profile you can enjoy all the benefits of your services."),B?t.createElement(E,{data:B}):t.createElement(n,null,"Business credentials not available"),t.createElement(l,null),t.createElement(a,{spacing:2,direction:"row"},t.createElement(s,null),t.createElement(m,null,t.createElement(n,{variant:"body1",component:"p"},_," ",g," ",!_&&!g&&"N/A"))),t.createElement(a,{spacing:2,direction:"row"},t.createElement(c,null),t.createElement(m,null,t.createElement(n,{variant:"body1",component:"p"},h," ",!h&&"N/A"))),t.createElement(a,{spacing:2,direction:"row"},t.createElement(d,null),t.createElement(m,null,t.createElement(n,{variant:"body1",component:"p"},x," ",!x&&"N/A"))),t.createElement(l,null),t.createElement(o,{container:!0,sx:{width:"100%"}},A?t.createElement(o,{item:!0,xs:12,md:4},t.createElement(n,{variant:"h6"},"Company Address"),t.createElement(p,{data:e({},A)})):t.createElement(o,{item:!0,xs:12,md:4},t.createElement(n,null,"Company address not available")),w?t.createElement(o,{item:!0,xs:12,md:4},t.createElement(n,{variant:"h6"},"Delivery Address"),t.createElement(p,{data:e({},w)})):t.createElement(o,{item:!0,xs:12,md:4},t.createElement(n,null,"Delivery address not available")),j?t.createElement(o,{item:!0,xs:12,md:4},t.createElement(n,{variant:"h6"},"Billing Address"),t.createElement(p,{data:e({},j)})):t.createElement(o,{item:!0,xs:12,md:4},t.createElement(n,null,"Billing address not available")))))}export{y as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import s,{useReducer as
|
|
7
|
+
import{__read as e,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import s,{useReducer as l,useEffect as i,useContext as o,createContext as n}from"react";import{isCustomerProfileCompleteV2 as t}from"../../../lib/isCustomerProfileCompleteV2.js";import{isAddressComplete as d}from"../../../lib/isAddressComplete.js";import{areBusinessCredentailsComplete as a}from"../../../lib/areBusinessCredentialsComplete.js";import{useClientSideCart as u}from"../../../components/e-commerce/cart/hooks.js";import{useSession as m}from"../../auth/SessionContext.js";import p from"../../../lib/isVATValid.js";import c from"../../../lib/isEORIValid.js";var f={confirmations:{itemsInCart:!1,customerProfileComplete:!1,companyAddressComplete:!1,deliveryAddressComplete:!1,billingAddressComplete:!1,businessCredentailsComplete:!1,hasVAT:!1,hasEORI:!1,hasValidatedVAT:!1,hasValidatedEORI:!1},delivery_options:[{id:1,label:"ptt"}],payment_options:[{id:1,label:"ideal"}],prefersBillingAddress:!0,prefersDeliveryAddress:!0,customer_internal_reference:""},_=n({state:f,runAllChecks:function(){},togglePrefersBillingAddress:function(){},togglePrefersDeliveryAddress:function(){},setCustomerInternalReference:function(){}}),v=function(e,s){switch(s.type){case"UPDATE_CONFIRMATIONS":return r(r({},e),{confirmations:r(r({},e.confirmations),s.payload)});case"SET_PREFERS_BILLING_ADDRESS":return r(r({},e),{prefersBillingAddress:s.payload.prefersBillingAddress});case"SET_PREFERS_DELIVERY_ADDRESS":return r(r({},e),{prefersDeliveryAddress:s.payload.prefersDeliveryAddress});case"SET_CUSTOMER_INTERNAL_REFERENCE":return r(r({},e),{customer_internal_reference:s.payload.customer_internal_reference});default:return e}},E=function(r){var o=r.children,n=e(l(v,f),2),E=n[0],A=n[1],R=m(),C=R.user;R.loading,R.error;var y=u(),S=function(){var e,r,s,l,i,o,n,u,m,f,_=y.state.items.length>0,v=Object.values(t(null==C?void 0:C.customer_profile)).every((function(e){return!0===e})),E=d(null===(e=null==C?void 0:C.customer_profile)||void 0===e?void 0:e.company_address),R=d(null===(r=null==C?void 0:C.customer_profile)||void 0===r?void 0:r.delivery_address),S=d(null===(s=null==C?void 0:C.customer_profile)||void 0===s?void 0:s.billing_address),b=a(null===(l=null==C?void 0:C.customer_profile)||void 0===l?void 0:l.business_credentials),I=Boolean(null===(o=null===(i=null==C?void 0:C.customer_profile)||void 0===i?void 0:i.business_credentials)||void 0===o?void 0:o.VAT_number),g=Boolean(null===(u=null===(n=null==C?void 0:C.customer_profile)||void 0===n?void 0:n.business_credentials)||void 0===u?void 0:u.EORI_number),T=p(null===(m=null==C?void 0:C.customer_profile)||void 0===m?void 0:m.business_credentials),D=c(null===(f=null==C?void 0:C.customer_profile)||void 0===f?void 0:f.business_credentials);A({type:"UPDATE_CONFIRMATIONS",payload:{itemsInCart:_,customerProfileComplete:v,companyAddressComplete:E,deliveryAddressComplete:R,billingAddressComplete:S,businessCredentailsComplete:b,hasVAT:I,hasEORI:g,hasValidatedVAT:T,hasValidatedEORI:D}})};i((function(){C&&S()}),[C]);var b={state:E,runAllChecks:S,togglePrefersBillingAddress:function(){A({type:"SET_PREFERS_BILLING_ADDRESS",payload:{prefersBillingAddress:!E.prefersBillingAddress}})},togglePrefersDeliveryAddress:function(){A({type:"SET_PREFERS_DELIVERY_ADDRESS",payload:{prefersDeliveryAddress:!E.prefersDeliveryAddress}})},setCustomerInternalReference:function(e){A({type:"SET_CUSTOMER_INTERNAL_REFERENCE",payload:{customer_internal_reference:e}})}};return s.createElement(_.Provider,{value:b},o)},A=function(){return o(_)};export{E as CheckoutProvider,A as useCheckout};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as e,__generator as r,__assign as s}from"../../../node_modules/tslib/tslib.es6.js";import{z as a}from"zod";import{cookies as t}from"next/headers";import{redirect as o}from"next/navigation";import{registerUserService as n,loginUserService as i,forgotPasswordService as l,resetPasswordService as d}from"../services/auth-service.js";var m,c={maxAge:604800,path:"/",domain:null!==(m=process.env.HOST)&&void 0!==m?m:"localhost",httpOnly:!0,secure:"production"===process.env.NODE_ENV},u=a.object({username:a.string().min(3).max(20,{message:"Username must be between 3 and 20 characters"}),password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),email:a.string().email({message:"Please enter a valid email address"}),redirect:a.string().optional()});function g(a,i){return e(this,void 0,void 0,(function(){var e,l,d,m,g,v,p;return r(this,(function(r){switch(r.label){case 0:return(e=u.safeParse({username:i.get("username"),password:i.get("password"),email:i.get("email")})).success?[4,n(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,strapiErrors:null,message:"Missing Fields. Failed to Register."})];case 1:return!(l=r.sent())||l.error?[2,s(s({},a),{strapiErrors:(null===(v=null==l?void 0:l.error)||void 0===v?void 0:v.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Register.":"Ops! Something went wrong. Please try again."})]:(t().set("jwt",l.jwt,c),i.get("redirect")?(d=i.get("redirect"),console.log("redirectValue",d),(m=new URLSearchParams).append("message","Please complete your profile. We've send you an email with a confirmation link."),m.append("severity","info"),g="".concat(null!==(p=null==d?void 0:d.toString())&&void 0!==p?p:"/dashboard","?").concat(m.toString()),o(g),[2]):[2,o("/dashboard")])}}))}))}var v=a.object({identifier:a.string().min(3,{message:"Identifier must have at least 3 or more characters"}).max(
|
|
7
|
+
import{__awaiter as e,__generator as r,__assign as s}from"../../../node_modules/tslib/tslib.es6.js";import{z as a}from"zod";import{cookies as t}from"next/headers";import{redirect as o}from"next/navigation";import{registerUserService as n,loginUserService as i,forgotPasswordService as l,resetPasswordService as d}from"../services/auth-service.js";var m,c={maxAge:604800,path:"/",domain:null!==(m=process.env.HOST)&&void 0!==m?m:"localhost",httpOnly:!0,secure:"production"===process.env.NODE_ENV},u=a.object({username:a.string().min(3).max(20,{message:"Username must be between 3 and 20 characters"}),password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),email:a.string().email({message:"Please enter a valid email address"}),redirect:a.string().optional()});function g(a,i){return e(this,void 0,void 0,(function(){var e,l,d,m,g,v,p;return r(this,(function(r){switch(r.label){case 0:return(e=u.safeParse({username:i.get("username"),password:i.get("password"),email:i.get("email")})).success?[4,n(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,strapiErrors:null,message:"Missing Fields. Failed to Register."})];case 1:return!(l=r.sent())||l.error?[2,s(s({},a),{strapiErrors:(null===(v=null==l?void 0:l.error)||void 0===v?void 0:v.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Register.":"Ops! Something went wrong. Please try again."})]:(t().set("jwt",l.jwt,c),i.get("redirect")?(d=i.get("redirect"),console.log("redirectValue",d),(m=new URLSearchParams).append("message","Please complete your profile. We've send you an email with a confirmation link."),m.append("severity","info"),g="".concat(null!==(p=null==d?void 0:d.toString())&&void 0!==p?p:"/dashboard","?").concat(m.toString()),o(g),[2]):[2,o("/dashboard")])}}))}))}var v=a.object({identifier:a.string().min(3,{message:"Identifier must have at least 3 or more characters"}).max(80,{message:"Please enter a valid username or email address"}),password:a.string().min(6,{message:"Password must have at least 6 or more characters"}).max(100,{message:"Password must be between 6 and 100 characters"}),redirect:a.string().optional()});function p(a,n){return e(this,void 0,void 0,(function(){var e,l,d,m,u,g,p;return r(this,(function(r){switch(r.label){case 0:return(e=v.safeParse({identifier:n.get("identifier"),password:n.get("password")})).success?[4,i(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Missing Fields. Failed to Login."})];case 1:return!(l=r.sent())||l.error?(console.log("Login Error:",l),[2,s(s({},a),{strapiErrors:(null===(u=null==l?void 0:l.error)||void 0===u?void 0:u.message)||null,zodErrors:null,message:(null==l?void 0:l.error)?"Failed to Login.":"Ops! Something went wrong. Please try again."})]):(t().set("jwt",l.jwt,c),d=null!==(p=null===(g=n.get("redirect"))||void 0===g?void 0:g.toString())&&void 0!==p?p:null,m="".concat(d||"/dashboard","?login=success"),o(m),[2])}}))}))}var w=a.object({email:a.string().email({message:"Please enter a valid email address"})});function f(a,t){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return(e=w.safeParse({email:t.get("email")})).success?[4,l(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Invalid email address."})];case 1:return o=r.sent(),console.log("Forgot Password Response:",o),o?o.error?[2,s(s({},a),{strapiErrors:o.error,zodErrors:null,message:"Failed to send reset email."})]:[2,s(s({},a),{message:"Password reset email sent successfully."})]:[2,s(s({},a),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}var h=a.object({password:a.string().min(6).max(100,{message:"Password must be between 6 and 100 characters"}),passwordConfirmation:a.string().min(6).max(100,{message:"Password confirmation must be between 6 and 100 characters"}),code:a.string()});function E(a,t){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e=h.safeParse({password:t.get("password"),passwordConfirmation:t.get("passwordConfirmation"),code:t.get("code")}),console.log("validatedFields",e),e.success?[4,d(e.data)]:[2,s(s({},a),{zodErrors:e.error.flatten().fieldErrors,message:"Invalid input."})];case 1:return o=r.sent(),console.log("Reset Password Response:",o),o?o.error?[2,s(s({},a),{strapiErrors:o.error,zodErrors:null,message:"Failed to reset password."})]:[2,s(s({},a),{message:"Password reset successfully."})]:[2,s(s({},a),{strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}function b(){return e(this,void 0,void 0,(function(){return r(this,(function(e){return t().set("jwt","",s(s({},c),{maxAge:0})),o("/"),[2]}))}))}export{f as forgotPasswordAction,p as loginUserAction,b as logoutAction,g as registerUserAction,E as resetPasswordAction};
|