@sikka/hawa 0.0.8 → 0.0.11
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/es/index.es.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +3 -2
- package/src/blocks/Account/UserProfile.js +55 -50
- package/src/blocks/Account/UserSettings.js +0 -1
- package/src/blocks/AuthForms/NewPasswordForm.js +57 -85
- package/src/blocks/AuthForms/ResetPasswordForm.js +43 -42
- package/src/blocks/AuthForms/SignInForm.js +92 -95
- package/src/blocks/AuthForms/SignUpForm.js +105 -104
- package/src/blocks/Payment/PaymentMethod.js +0 -1
- package/src/blocks/Payment/SelectPayment.js +53 -54
- package/src/index.js +0 -1
- package/src/layout/Box.js +36 -33
- package/src/stories/BlocksStories/AuthForm.stories.js +105 -39
- package/src/stories/BlocksStories/PaymentForm.stories.js +20 -35
- package/src/stories/BlocksStories/UserForm.stories.js +2 -16
- package/src/stories/LayoutStories/Box.stories.js +4 -10
- package/src/stories/UIStories/ActionButton.stories.js +1 -6
- package/src/stories/UIStories/AdaptiveButton.stories.js +1 -6
- package/src/stories/UIStories/Alert.stories.js +2 -3
- package/src/stories/UIStories/LogoButtons.stories.js +2 -6
- package/src/stories/UIStories/RadioSelector.stories.js +0 -3
- package/src/stories/UIStories/SettingsRow.stories.js +3 -16
- package/src/themes/HawaProvider.js +187 -178
- package/src/themes/QawaimTheme.js +199 -0
- package/src/ui/ActionButton.js +32 -35
- package/src/ui/AdaptiveButton.js +3 -8
- package/src/ui/HawaAlert.js +22 -24
- package/src/ui/HawaButton.js +43 -44
- package/src/ui/HawaInputLabel.js +22 -23
- package/src/ui/HawaLogoButton.js +7 -45
- package/src/ui/HawaRadio.js +25 -34
- package/src/ui/HawaSettingsRow.js +1 -27
- package/src/ui/HawaTextArea.js +1 -1
- package/src/ui/HawaTextField.js +146 -93
- package/src/ui/HawaTypography.js +19 -21
- package/src/ui/Row.js +1 -1
- package/src/ui/StyledTooltip.js +1 -1
- package/src/ui/TabPanel.js +1 -1
- package/storybook-static/8.1bf48ea7.iframe.bundle.js +1 -0
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/main.b00949db.iframe.bundle.js +1 -0
- package/storybook-static/{runtime~main.cfefe972.iframe.bundle.js → runtime~main.f1ebae9b.iframe.bundle.js} +1 -1
- package/storybook-static/vendors~main.f8d30727.iframe.bundle.js +76 -0
- package/storybook-static/{vendors~main.aa1d952a.iframe.bundle.js.LICENSE.txt → vendors~main.f8d30727.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/vendors~main.f8d30727.iframe.bundle.js.map +1 -0
- package/src/stories/HawaProvider.stories.js +0 -22
- package/storybook-static/8.c4cb6081.iframe.bundle.js +0 -1
- package/storybook-static/main.5731dbe3.iframe.bundle.js +0 -1
- package/storybook-static/vendors~main.aa1d952a.iframe.bundle.js +0 -76
- package/storybook-static/vendors~main.aa1d952a.iframe.bundle.js.map +0 -1
package/es/index.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as e,useContext as r,useState as t}from"react";import o from"@mui/material/Button";import"@mui/material/Tooltip";import a from"prop-types";import{jsx as n,jsxs as i,Fragment as l}from"react/jsx-runtime";import{darken as d,styled as s}from"@mui/material/styles";import"@mui/material/FormControlLabel";import"@mui/material/Checkbox";import"@mui/material";import"@mui/material/TextField";import u from"@mui/material/Typography";import m from"@mui/icons-material/GitHub";import c from"@mui/icons-material/Twitter";import p from"@mui/icons-material/AccountBalanceWallet";import g from"@mui/material/InputBase";import h from"@mui/material/InputLabel";import{useFormContext as b,Controller as y,useForm as f,FormProvider as w}from"react-hook-form";import v from"@mui/material/Alert";import x from"@mui/material/AlertTitle";import C from"@mui/material/InputAdornment";import k from"@mui/icons-material/HttpsOutlined";import T from"@mui/icons-material/MailOutline";import P from"@mui/icons-material/PermIdentityOutlined";function L(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function S(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?L(Object(t),!0).forEach((function(r){A(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):L(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function A(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function B(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var o,a,n=[],i=!0,l=!1;try{for(t=t.call(e);!(i=(o=t.next()).done)&&(n.push(o.value),!r||n.length!==r);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==t.return||t.return()}finally{if(l)throw a}}return n}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}var W=e({allPrimaryBG:"#f90900",allPrimaryAction:"#138A36",allBorderRadius:10,borderRadius:10,primaryColor:"blue",secondaryColor:"grey",primaryActionColor:"grey",secondaryActionColor:"#4cc9f0",layoutColor:"#d3d4d9",textColor:"black",inputColor:"white",lightBackground:"#FBF5F3",darkBackground:"#0F0E0E",testcolor:"green",margins:10,paddings:10,typography:{fontFamily:["IBMPlex"].join(","),primary:{color:"black"},secondary:{color:"white"}},logoButton:{primary:{borderRadius:10,backgroundColor:"#B20D30",marginTop:10,padding:30,paddingTop:0,paddingBottom:0,border:"1px solid #ced4da",height:50,"&:focus":{borderColor:"#B20D30"}},secondary:{borderRadius:10,backgroundColor:"#f90900",marginTop:10,padding:30,paddingTop:0,paddingBottom:0,border:"1px solid #ced4da",height:50,"&:focus":{borderColor:"green"}}},actionButton:{primary:{borderRadius:10,backgroundColor:"#B20D30",color:"white",margin:10,padding:10,border:"1px solid #ced4da",fontSize:16,height:50,"&:focus":{borderColor:"red"}},secondary:{borderRadius:10,margin:10,padding:10,backgroundColor:"#FF8811",color:"black"}},layout:{primary:{backgroundColor:"#d3d4d9",color:"black",margin:10,padding:10,borderRadius:10},secondary:{backgroundColor:"#001E3C",color:"white",margin:10,padding:10,borderRadius:10}},inputFields:{primary:{backgroundColor:"white",borderRadius:10,"&:focus":{borderColor:"red",borderWidth:1,border:"1px solid black"},"&:hover":{borderColor:"red",borderWidth:1,border:"1px solid black"}},secondary:{backgroundColor:"white",borderRadius:10}},alerts:{primary:{marginBottom:10,padding:10,borderRadius:10},secondary:{marginBottom:10,padding:10,borderRadius:10}},settingsRow:{primary:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"#F5F5F5",margin:0,padding:10,borderRadius:10},secondary:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"blue",margin:0,padding:5,borderRadius:10}},radioSelector:{primary:{padding:10,borderRadius:10},secondary:{padding:10,borderRadius:10}}});a.string,a.bool,a.bool,a.bool;var q=function(e){var t,a=r(W),i=a.hawaTheme,l=a.themeName,u=Object.keys(i.actionButton).find((function(e){return e.toLowerCase()===(null==l?void 0:l.toLowerCase())})),m={};u?m=S(S({},i.actionButton[u]),{},{margin:e.last?0:i.actionButton[u].margin,marginTop:e.last?2*i.actionButton[u].margin:0,"&:hover":{backgroundColor:d(null===(t=i.actionButton[u])||void 0===t?void 0:t.backgroundColor,.1)}}):m={backgroundColor:"black",color:"white",padding:10,marginTop:e.last?20:0,borderRadius:0};var c=s(o)((function(e){return e.theme,S({},m)}));return n(c,S(S({},e),{},{children:e.text}))},E=function(e){var t=r(W),o=t.hawaTheme,a=t.themeName,i={},l=Object.keys(o.layout).find((function(e){return e.toLowerCase()===(null==a?void 0:a.toLowerCase())}));return i=l?S(S({display:"flex",flexDirection:e.horizontal?"row":"column"},o.layout[l]),{},{backgroundColor:e.noColor?"none":o.layout[l].backgroundColor,padding:e.noPadding?0:o.layout[l].padding,margin:e.noMargin?0:o.layout[l].margin,maxWidth:e.maxWidth}):{display:"flex",flexDirection:e.horizontal?"row":"column",color:"white",marginTop:e.last?20:0,backgroundColor:e.noColor?"none":"lightGrey",padding:e.noPadding?0:10,margin:e.noMargin?0:10,maxWidth:e.maxWidth,borderRadius:0},n("div",{style:i,children:e.children})},M=function(e){var t=r(W),o=t.hawaTheme,a=t.themeName,i=Object.keys(o.typography).find((function(e){return e.toLowerCase()===(null==a?void 0:a.toLowerCase())})),l={};l=i?S({},o.typography[i]):{color:"black"};var d=s(u)((function(e){return e.theme,S({},l)}));return n(d,S(S({},e),{},{children:e.children}))};a.oneOf(["text","number","password"]),a.string;var j=function(e){var t,a=r(W),l=a.hawaTheme,u=a.themeName,g={},h=Object.keys(l.logoButton).find((function(e){return e.toLowerCase()===(null==u?void 0:u.toLowerCase())}));g=h?S(S({},l.logoButton[h]),{},{backgroundColor:"white","&:hover":{backgroundColor:d("#ffffff",.1)}}):{cursor:"pointer",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",marginTop:10,height:50,padding:30,paddingTop:0,paddingBottom:0,border:"1px solid #ced4da",backgroundColor:"white","&:hover":{backgroundColor:d("#ffffff",.1)}};var b=s(o)((function(e){return e.theme,S({},g)})),y="";switch(null===(t=e.logo)||void 0===t?void 0:t.toLowerCase()){case"google":y=n("img",{src:"https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"});break;case"github":y=n(m,{});break;case"twitter":y=n(c,{});break;case"mada":y=n("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png",height:20});break;case"stcpay":y=n("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png",height:20});break;case"visa/master":y=n("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png",height:30});break;case"paypal":y=n("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png",height:25});break;case"googlepay":y=n("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png",height:20});break;case"applepay":y=n("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png",height:40});break;case"wallet":y=n(p,{})}return i(b,S(S({},e),{},{children:[y,n("div",{style:{width:10}}),n("p",{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:e.buttonText})]}))},F=function(e){var t=r(W),o=t.hawaTheme,a=t.themeName,i={},l=Object.keys(o.actionButton).find((function(e){return e.toLowerCase()===(null==a?void 0:a.toLowerCase())}));return i=l?{margin:15,marginRight:5,marginLeft:5,color:o.layout[l].color}:{margin:15,marginRight:0,marginLeft:0,color:"black"},n(h,{style:i,children:n("div",{style:{fontSize:15},children:e.label})})},I=function(e){var t=b(),o=t.control,a=t.register,d=r(W),m=d.hawaTheme,c=d.themeName,p=Object.keys(m.inputFields).find((function(e){return e.toLowerCase()===(null==c?void 0:c.toLowerCase())})),h={};h=p?S(S({},m.inputFields[p]),{},{margin:e.last?0:m.inputFields[p].margin,marginTop:e.last?2*m.inputFields[p].margin:0}):{backgroundColor:"white"};var f=s(g)((function(r){return S({"& .MuiInputBase-input":{transition:r.theme.transitions.create(["border-color","background-color","box-shadow"])},border:"1px solid #ced4da",fontSize:16,padding:"10px 12px",marginBottom:e.helperText?5:0,paddingLeft:10,paddingRight:10},h)}));return n(y,{render:function(r){var t;return r.field,i(l,{children:[e.inputLabel&&n(F,{label:e.inputLabel}),n(f,S(S({fullWidth:!0,type:null!==(t=e.type)&&void 0!==t?t:"text",defaultValue:e.defaultValue&&"",value:e.value&&""},e),a(e.name))),n(u,{variant:"caption",style:{margin:5,marginBottom:0,color:"red"},children:e.helperText})]})},name:e.name,rules:e.rules,control:o,shouldUnregister:e.shouldUnregister})};I.propTypes={type:a.oneOf(["text","number","password"]),helperText:a.string};var R=function(e){var t=r(W),o=t.hawaTheme,a=t.themeName,l=Object.keys(o.alerts).find((function(e){return e.toLowerCase()===(null==a?void 0:a.toLowerCase())})),d={};d=l?S({},o.alerts[l]):{marginBottom:10};var u=s(v)((function(e){return e.theme,S({},d)}));return i(u,S(S({},e),{},{children:[e.title&&n(x,{children:e.title}),e.text]}))},N=function(e){var r,t,o,a,l=f(),d=l.formState.errors;return l.handleSubmit,n(E,{maxWidth:400,noMargin:!0,children:n(E,{noMargin:!0,noColor:!0,children:n(w,S(S({},l),{},{children:i("form",{children:[n(I,{type:"text",name:"fullName",inputLabel:"Full Name",placeholder:"Fulan AlFulani",rules:{required:"Email is required"},helperText:null===(r=d.fullName)||void 0===r?void 0:r.message}),n(I,{type:"text",name:"email",inputLabel:"New Email",placeholder:"Enter your new email",rules:{required:"Email is required"},helperText:null===(t=d.email)||void 0===t?void 0:t.message}),n(I,{type:"password",name:"password",inputLabel:"New password",placeholder:"Enter your new password",rules:{required:"Email is required"},helperText:null===(o=d.password)||void 0===o?void 0:o.message}),n(I,{type:"password",name:"confirmPassword",inputLabel:"Confirm new password",placeholder:"Confirm new password",rules:{required:"Email is required"},helperText:null===(a=d.confirmPassword)||void 0===a?void 0:a.message}),n(q,{fullWidth:!0,last:!0,text:"Update Account"})]})}))})})},z=function(e){return i(E,{maxWidth:400,children:[n(I,{type:"text",inputLabel:"First Name"}),n(I,{type:"text",inputLabel:"Last Name"}),n(I,{type:"email",inputLabel:"Email"}),n(I,{type:"password",inputLabel:"Password"}),n(q,{last:!0,text:"Update Account"})]})},G=function(e){var r,o,a=B(t(""),2),l=a[0],d=a[1],s=B(t(""),2);s[0],s[1];var u=B(t(!1),2);u[0],u[1];var m=B(t(""),2);m[0],m[1];var c=B(t(!0),2);c[0],c[1];var p=f(),g=p.formState.errors,h=p.handleSubmit;return p.getValues,p.register,p.watch,p.reset,p.setValue,n(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:i(E,{noMargin:!0,children:[e.error&&n(R,{text:"This is a new password alert",severity:"error"}),e.passwordChanged?n(M,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):n(w,S(S({},p),{},{children:i("form",{onSubmit:h(e.handleNewPassword),children:[n(I,{name:"password",type:"password",inputLabel:"Choose new password",placeholder:"Enter password",onChange:function(e){return d(e.target.value)},value:l,startAdornment:n(C,{position:"start",children:n(k,{})}),rules:{required:"Password is rquired"},helperText:null===(r=g.password)||void 0===r?void 0:r.message}),n(I,{name:"confirmPassword",type:"password",placeholder:"Confirm Password",inputLabel:"Confirm",startAdornment:n(C,{position:"start",children:n(k,{})}),rules:{required:"Password is rquired"},helperText:null===(o=g.confirmPassword)||void 0===o?void 0:o.message}),n(q,{fullWidth:!0,type:"submit",last:!0,text:"Reset Password"})]})}))]})})},D=function(e){var r,t=f(),o=t.formState.errors,a=t.handleSubmit;return t.getValues,t.register,t.watch,t.reset,t.setValue,n(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:i(E,{noMargin:!0,children:[e.error&&n(R,{text:"This is a reset password alert",severity:"error"}),e.sent?n(M,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):n(w,S(S({},t),{},{children:i("form",{onSubmit:a(e.handleResetPassword),children:[n(I,{type:"text",name:"email",inputLabel:"Email",placeholder:"Enter your email",startAdornment:n(C,{position:"start",children:n(T,{})}),rules:{required:"Email is required",pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Invalid email address"}},helperText:null===(r=o.email)||void 0===r?void 0:r.message}),n(q,{fullWidth:!0,last:!0,type:"submit",text:"Reset Password"})]})}))]})})},V=function(e){var r,t,o,a=f(),l=a.formState.errors,d=a.handleSubmit;return a.getValues,a.register,a.watch,a.reset,a.setValue,i(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:[i(E,{noMargin:!0,children:[e.error&&n(R,{text:"This is a sign in alert",severity:"error"}),n(w,S(S({},a),{},{children:i("form",{onSubmit:d(e.handleSignUp),children:[n(I,{name:"fullName",placeholder:"Fulan AlFulani",type:"text",inputLabel:"Full Name",startAdornment:n(C,{position:"start",children:n(P,{})}),rules:{required:"Full name rquired"},helperText:null===(r=l.fullName)||void 0===r?void 0:r.message}),n(I,{type:"text",inputLabel:"Email",placeholder:"Enter your email",name:"email",startAdornment:n(C,{position:"start",children:n(T,{})}),rules:{required:"Email required",pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Invalid email address"}},helperText:null===(t=l.email)||void 0===t?void 0:t.message}),n(I,{name:"password",placeholder:"Minimum 8 characters",type:"password",inputLabel:"Password",startAdornment:n(C,{position:"start",children:n(k,{})}),rules:{required:"Password rquired",minLength:{value:8,message:"Password too short"}},helperText:null===(o=l.password)||void 0===o?void 0:o.message}),n(q,{fullWidth:!0,type:"submit",text:"Sign Up",last:!0})]})}))]}),i(M,{style:{marginTop:5,textAlign:"center",padding:5},children:["Existing user?"," ",n("span",{onClick:function(){return console.log("res")},style:{cursor:"pointer",color:"blue",textAlign:"center"},children:"Sign in"})]}),e.viaGoogle&&n(j,{logo:"google",buttonText:e.googleButtonLabel,handleClick:e.handleGoogleSignIn}),e.viaGithub&&n(j,{logo:"github",buttonText:e.githubButtonLabel,handleClick:e.handleGithubSignIn}),e.viaTwitter&&n(j,{logo:"twitter",buttonText:e.twitterButtonLabel,handleClick:e.handleTwitterSignIn})]})};V.propTypes={theme:a.oneOf(["secondary","primary"])};var U=function(e){var r,t,o=f(),a=o.formState.errors,l=o.handleSubmit;return i(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:[i(E,{noMargin:!0,children:[e.error&&n(R,{text:"This is a sign in alert",severity:"error"}),n(w,S(S({},o),{},{children:i("form",{onSubmit:l(e.handleSignIn),children:[n(I,{type:"text",name:"email",inputLabel:"Email",placeholder:"Enter your email",startAdornment:n(C,{position:"start",children:n(T,{})}),rules:{required:"Email is required",pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Invalid email address"}},helperText:null===(r=a.email)||void 0===r?void 0:r.message}),n(I,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",startAdornment:n(C,{position:"start",children:n(k,{})}),rules:{required:"Password is rquired"},helperText:null===(t=a.password)||void 0===t?void 0:t.message}),n(M,{style:{cursor:"pointer",marginTop:5,width:"max-content",padding:5},onClick:function(){return console.log("res")},children:"Forgot password?"}),n(q,{type:"submit",fullWidth:!0,last:"true",text:"Sign In"})]})}))]}),i(M,{style:{marginTop:5,textAlign:"center",padding:5},children:["New user?"," ",n("span",{onClick:function(){return console.log("res")},style:{cursor:"pointer",color:"blue",textAlign:"center"},children:"Sign up"})]}),e.viaGoogle&&n(j,{logo:"google",buttonText:e.googleButtonLabel,handleClick:e.handleGoogleSignIn}),e.viaGithub&&n(j,{logo:"github",buttonText:e.githubButtonLabel,handleClick:e.handleGithubSignIn}),e.viaTwitter&&n(j,{logo:"twitter",buttonText:e.twitterButtonLabel,handleClick:e.handleTwitterSignIn})]})},Z=function(e){return n(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:i(E,{noMargin:!0,children:[n(M,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&n(j,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&n(j,{logo:"visa/master",buttonText:e.visaMasterLabel,handleClick:e.handleCreditCard}),e.viaMada&&n(j,{logo:"mada",buttonText:e.madaLabel,handleClick:e.handleMada}),e.viaSTCPay&&n(j,{logo:"stcpay",buttonText:e.stcPayLabel,handleClick:e.handleSTCPay}),e.viaPayPal&&n(j,{logo:"paypal",buttonText:e.paypalLabel,handleClick:e.handlePayPal}),e.viaGooglePay&&n(j,{logo:"googlepay",buttonText:e.googlePayLabel,handleClick:e.handleGooglePay}),e.viaApplePay&&n(j,{logo:"applepay",buttonText:e.applePayLabel,handleClick:e.handleApplePay})]})})};I.propTypes={theme:a.oneOf(["secondary","primary"]),viaApplePay:a.bool,viaGooglePay:a.bool,viaSTCPay:a.bool,viaCreditCard:a.bool,viaPayPal:a.bool,handleApplePay:a.func};var $=function(e){var r,t,o=f(),a=o.formState.errors,l=o.handleSubmit;return n(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:n(E,{noMargin:!0,children:n(w,S(S({},o),{},{children:i("form",{onSubmit:l(e.handle),children:[n(I,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(r=a.password)||void 0===r?void 0:r.message}),n(I,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(t=a.password)||void 0===t?void 0:t.message}),n(q,{last:!0,fullWidth:!0,text:"Sign In",onClick:e.handleSignIn})]})}))})})},H=function(e){var r,o=B(t(0),2),a=o[0],l=o[1],d=f(),s=d.formState.errors,u=d.handleSubmit;return n(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:i(E,{noMargin:!0,children:[i(M,{variant:"h2",align:"center",children:[Number(a).toLocaleString("en")," ",n("span",{style:{fontSize:20,letterSpacing:1},children:e.currency})]}),n(w,S(S({},d),{},{children:i("form",{onChange:function(e){e.preventDefault(),l(d.getValues().amount)},style:{marginTop:10},onSubmit:u(e.handleChargeWallet),children:[n(I,{name:"amount",placeholder:"Enter amount",type:"number",value:a,rules:{required:"Password is rquired"},helperText:null===(r=s.amount)||void 0===r?void 0:r.message}),n(q,{last:!0,fullWidth:!0,text:"Charge Wallet",onClick:e.handleSignIn})]})}))]})})},_=function(e){return n(E,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:i(E,{noMargin:!0,children:[n("div",{children:"Wallet Balance"}),n(q,{text:"Pay now"})]})})};export{H as ChargeWalletForm,$ as CreditCardForm,G as NewPasswordForm,_ as PayWithWallet,D as ResetPasswordForm,Z as SelectPayment,U as SignInForm,V as SignUpForm,N as UserProfile,z as UserSettings};
|
|
1
|
+
import{useState as e}from"react";import t from"@mui/material/Button";import"@mui/material/Tooltip";import r from"prop-types";import{jsx as a,jsxs as l,Fragment as i}from"react/jsx-runtime";import"@mui/material/FormControlLabel";import"@mui/material/Checkbox";import{Typography as n,Button as o,Container as s}from"@mui/material";import"@mui/material/TextField";import d from"@mui/material/Typography";import u from"@mui/icons-material/GitHub";import m from"@mui/icons-material/Twitter";import p from"@mui/icons-material/AccountBalanceWallet";import c from"@mui/material/Input";import h from"@mui/material/InputLabel";import g from"@mui/material/Alert";import b from"@mui/material/AlertTitle";import{useForm as f,FormProvider as x}from"react-hook-form";import y from"@mui/material/Container";import v from"@mui/material/InputAdornment";import w from"@mui/icons-material/HttpsOutlined";import T from"@mui/icons-material/MailOutline";import P from"@mui/icons-material/PermIdentityOutlined";function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function k(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var a,l,i=[],n=!0,o=!1;try{for(r=r.call(e);!(n=(a=r.next()).done)&&(i.push(a.value),!t||i.length!==t);n=!0);}catch(e){o=!0,l=e}finally{try{n||null==r.return||r.return()}finally{if(o)throw l}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return L(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return L(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}r.string,r.bool,r.bool,r.bool;var W=function(e){return a(t,k(k({},e),{},{children:e.text}))},q=function(e){return a("div",{children:e.children})},O=function(e){return a(d,k(k({},e),{},{children:e.children}))};r.oneOf(["text","number","password"]),r.string;var I=function(e){var r,i="";switch(null===(r=e.logo)||void 0===r?void 0:r.toLowerCase()){case"google":i=a("img",{src:"https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"});break;case"github":i=a(u,{});break;case"twitter":i=a(m,{});break;case"mada":i=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png",height:20});break;case"stcpay":i=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png",height:20});break;case"visa/master":i=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png",height:30});break;case"paypal":i=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png",height:25});break;case"googlepay":i=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png",height:20});break;case"applepay":i=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png",height:40});break;case"wallet":i=a(p,{})}return l(t,k(k({},e),{},{variant:"withLogo",children:[i,a("div",{style:{width:10}}),a(n,{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:e.buttonText})]}))},j=function(e){return l(i,{children:[a(h,{children:e.label}),a(c,k({disableUnderline:!0},e))]})},E=function(e){return l(g,{children:[e.title&&a(b,{children:e.title}),e.text]})},z=function(e){var t,r,i,n,s=f(),d=s.formState.errors;return s.handleSubmit,a(y,{maxWidth:"xs",children:a(x,k(k({},s),{},{children:l("form",{children:[a(j,{fullWidth:!0,type:"text",name:"fullName",label:"Full Name",placeholder:"Fulan AlFulani",rules:{required:"Email is required"},helperText:null===(t=d.fullName)||void 0===t?void 0:t.message}),a(j,{fullWidth:!0,type:"text",name:"email",label:"New Email",placeholder:"Enter your new email",rules:{required:"Email is required"},helperText:null===(r=d.email)||void 0===r?void 0:r.message}),a(j,{fullWidth:!0,type:"password",name:"password",label:"New password",placeholder:"Enter your new password",rules:{required:"Email is required"},helperText:null===(i=d.password)||void 0===i?void 0:i.message}),a(j,{fullWidth:!0,type:"password",name:"confirmPassword",label:"Confirm new password",placeholder:"Confirm new password",rules:{required:"Email is required"},helperText:null===(n=d.confirmPassword)||void 0===n?void 0:n.message}),a(o,{type:"submit",fullWidth:!0,variant:"last",children:"update profile"})," "]})}))})},G=function(e){return l(q,{maxWidth:400,children:[a(j,{type:"text",inputLabel:"First Name"}),a(j,{type:"text",inputLabel:"Last Name"}),a(j,{type:"email",inputLabel:"Email"}),a(j,{type:"password",inputLabel:"Password"}),a(W,{last:!0,text:"Update Account"})]})},N=function(r){var i,n,o=A(e(""),2),s=o[0],d=o[1],u=f(),m=u.formState.errors,p=u.handleSubmit;return l(y,{maxWidth:"xs",variant:"auth",children:[r.error&&a(E,{text:"This is a new password alert",severity:"error"}),r.passwordChanged?a(O,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a(x,k(k({},u),{},{children:l("form",{onSubmit:p(r.handleNewPassword),children:[a(j,{fullWidth:!0,name:"password",type:"password",label:r.texts.passwordLabel,placeholder:r.texts.passwordPlaceholder,onChange:function(e){return d(e.target.value)},value:s,startAdornment:a(v,{position:"start",children:a(w,{})}),rules:{required:r.texts.passwordRequiredText},helperText:null===(i=m.password)||void 0===i?void 0:i.message}),a(j,{fullWidth:!0,name:"confirmPassword",type:"password",placeholder:r.texts.confirmPasswordPlaceholder,label:r.texts.confirmPasswordLabel,startAdornment:a(v,{position:"start",children:a(w,{})}),rules:{required:"Password is rquired"},helperText:null===(n=m.confirmPassword)||void 0===n?void 0:n.message}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:r.texts.updatePassword})]})}))]})},M=function(e){var r,i=f(),n=i.formState.errors,o=i.handleSubmit;return i.getValues,i.register,i.watch,i.reset,i.setValue,l(y,{maxWidth:"xs",variant:"auth",children:[e.error&&l(Alert,{severity:"error",children:[e.errorTitle&&a(AlertTitle,{children:e.errorTitle}),e.errorText]}),e.sent?a(O,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):a(x,k(k({},i),{},{children:l("form",{onSubmit:o(e.handleResetPassword),children:[a(j,{fullWidth:!0,type:"text",name:"email",label:e.texts.emailLabel,placeholder:e.texts.emailPlaceholder,startAdornment:a(v,{position:"start",children:a(T,{})}),rules:{required:e.texts.emailRequiredText,pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:e.texts.emailInvalidText}},helperText:null===(r=n.email)||void 0===r?void 0:r.message}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.resetPassword})]})}))]})},U=function(e){var r,i,n,o=f(),s=o.formState.errors,u=o.handleSubmit;return l(y,{maxWidth:"xs",variant:"auth",children:[e.error&&l(g,{severity:"error",children:[e.errorTitle&&a(AlertTitle,{children:e.errorTitle}),e.errorText]}),a(x,k(k({},o),{},{children:l("form",{onSubmit:u(e.handleSignUp),children:[a(j,{fullWidth:!0,type:"text",label:e.texts.fullNameLabel,name:"fullName",placeholder:e.texts.fullNamePlaceholder,inputLabel:e.texts.fullNameLabel,startAdornment:a(v,{position:"start",children:a(P,{})}),helperText:null===(r=s.fullName)||void 0===r?void 0:r.message}),a(j,{fullWidth:!0,type:"text",label:e.texts.emailLabel,placeholder:e.texts.emailPlaceholder,name:"email",startAdornment:a(v,{position:"start",children:a(T,{})}),rules:{required:e.texts.emailRequiredText,pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:e.texts.emailInvalidText}},helperText:null===(i=s.email)||void 0===i?void 0:i.message}),a(j,{fullWidth:!0,name:"password",placeholder:e.texts.passwordPlaceholder,type:"password",label:e.texts.passwordLabel,startAdornment:a(v,{position:"start",children:a(w,{})}),rules:{required:e.texts.passwordRequiredText,minLength:{value:8,message:e.texts.passwordTooShortText}},helperText:null===(n=s.password)||void 0===n?void 0:n.message}),a(t,{fullWidth:!0,variant:"last",type:"submit",children:e.texts.signUpText})]})})),l(d,{variant:"subtitle2",style:{marginTop:5,textAlign:"center",padding:5},children:["Existing user?"," ",a("span",{onClick:e.handleRouteToSignIn,style:{cursor:"pointer",color:"blue",textAlign:"center"},children:e.texts.signInText})]}),l("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a(I,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignUp}),e.viaGithub&&a(I,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignUp}),e.viaTwitter&&a(I,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignUp})]})]})};U.propTypes={theme:r.oneOf(["secondary","primary"])};var B=function(e){var r,i,n=f(),o=n.formState.errors,s=n.handleSubmit;return l(y,{maxWidth:"xs",variant:"auth",children:[e.error&&l(g,{severity:"error",children:[e.errorTitle&&a(AlertTitle,{children:e.errorTitle}),e.errorText]}),a(x,k(k({},n),{},{children:l("form",{onSubmit:s(e.handleSignIn),children:[a(j,{fullWidth:!0,type:"text",name:"email",label:e.texts.emailLabel,placeholder:e.texts.emailPlaceholder,startAdornment:a(v,{position:"start",children:a(T,{})}),rules:{required:e.texts.emailRequired,pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:e.texts.emailInvalidText}},helperText:null===(r=o.email)||void 0===r?void 0:r.message}),a(j,{fullWidth:!0,name:"password",placeholder:e.texts.passwordPlaceholder,type:"password",label:e.texts.passwordLabel,startAdornment:a(v,{position:"start",children:a(w,{})}),rules:{required:e.texts.passwordRequired},helperText:null===(i=o.password)||void 0===i?void 0:i.message}),a(O,{style:{cursor:"pointer",marginTop:5,width:"max-content",padding:5},onClick:e.handleForgotPassword,children:e.texts.forgotPasswordText}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.signInText})]})})),l(O,{style:{marginTop:5,textAlign:"center",padding:5},children:[e.texts.newUserText," ",a("span",{onClick:e.handleRouteToSignUp,style:{cursor:"pointer",color:"blue",textAlign:"center"},children:e.texts.signUpText})]}),l("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a(I,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignIn}),e.viaGithub&&a(I,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignIn}),e.viaTwitter&&a(I,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignIn})]})]})},R=function(e){return l(s,{maxWidth:"xs",children:[a(O,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a(I,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a(I,{logo:"visa/master",buttonText:e.visaMasterLabel,handleClick:e.handleCreditCard}),e.viaMada&&a(I,{logo:"mada",buttonText:e.madaLabel,handleClick:e.handleMada}),e.viaSTCPay&&a(I,{logo:"stcpay",buttonText:e.stcPayLabel,handleClick:e.handleSTCPay}),e.viaPayPal&&a(I,{logo:"paypal",buttonText:e.paypalLabel,handleClick:e.handlePayPal}),e.viaGooglePay&&a(I,{logo:"googlepay",buttonText:e.googlePayLabel,handleClick:e.handleGooglePay}),e.viaApplePay&&a(I,{logo:"applepay",buttonText:e.applePayLabel,handleClick:e.handleApplePay})]})};j.propTypes={theme:r.oneOf(["secondary","primary"]),viaApplePay:r.bool,viaGooglePay:r.bool,viaSTCPay:r.bool,viaCreditCard:r.bool,viaPayPal:r.bool,handleApplePay:r.func};var F=function(e){var t,r,i=f(),n=i.formState.errors,o=i.handleSubmit;return a(q,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a(q,{noMargin:!0,children:a(x,k(k({},i),{},{children:l("form",{onSubmit:o(e.handle),children:[a(j,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a(j,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(r=n.password)||void 0===r?void 0:r.message}),a(W,{last:!0,fullWidth:!0,text:"Sign In",onClick:e.handleSignIn})]})}))})})},D=function(t){var r,i=A(e(0),2),n=i[0],o=i[1],s=f(),d=s.formState.errors,u=s.handleSubmit;return a(q,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:l(q,{noMargin:!0,children:[l(O,{variant:"h2",align:"center",children:[Number(n).toLocaleString("en")," ",a("span",{style:{fontSize:20,letterSpacing:1},children:t.currency})]}),a(x,k(k({},s),{},{children:l("form",{onChange:function(e){e.preventDefault(),o(s.getValues().amount)},style:{marginTop:10},onSubmit:u(t.handleChargeWallet),children:[a(j,{name:"amount",placeholder:"Enter amount",type:"number",value:n,rules:{required:"Password is rquired"},helperText:null===(r=d.amount)||void 0===r?void 0:r.message}),a(W,{last:!0,fullWidth:!0,text:"Charge Wallet",onClick:t.handleSignIn})]})}))]})})},Z=function(e){return a(q,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:l(q,{noMargin:!0,children:[a("div",{children:"Wallet Balance"}),a(W,{text:"Pay now"})]})})};export{D as ChargeWalletForm,F as CreditCardForm,N as NewPasswordForm,Z as PayWithWallet,M as ResetPasswordForm,R as SelectPayment,B as SignInForm,U as SignUpForm,z as UserProfile,G as UserSettings};
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@mui/material/Button");require("@mui/material/Tooltip");var t=require("prop-types"),a=require("react/jsx-runtime"),o=require("@mui/material/styles");require("@mui/material/FormControlLabel"),require("@mui/material/Checkbox"),require("@mui/material"),require("@mui/material/TextField");var n=require("@mui/material/Typography"),i=require("@mui/icons-material/GitHub"),l=require("@mui/icons-material/Twitter"),s=require("@mui/icons-material/AccountBalanceWallet"),d=require("@mui/material/InputBase"),u=require("@mui/material/InputLabel"),c=require("react-hook-form"),m=require("@mui/material/Alert"),p=require("@mui/material/AlertTitle"),g=require("@mui/material/InputAdornment"),h=require("@mui/icons-material/HttpsOutlined"),x=require("@mui/icons-material/MailOutline"),f=require("@mui/icons-material/PermIdentityOutlined");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=b(r),j=b(t),w=b(n),v=b(i),C=b(l),k=b(s),P=b(d),T=b(u),S=b(m),L=b(p),q=b(g),F=b(h),A=b(x),B=b(f);function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function W(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?O(Object(t),!0).forEach((function(r){M(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function M(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function E(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var a,o,n=[],i=!0,l=!1;try{for(t=t.call(e);!(i=(a=t.next()).done)&&(n.push(a.value),!r||n.length!==r);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==t.return||t.return()}finally{if(l)throw o}}return n}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return I(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}var R={allPrimaryBG:"#f90900",allPrimaryAction:"#138A36",allBorderRadius:10,borderRadius:10,primaryColor:"blue",secondaryColor:"grey",primaryActionColor:"grey",secondaryActionColor:"#4cc9f0",layoutColor:"#d3d4d9",textColor:"black",inputColor:"white",lightBackground:"#FBF5F3",darkBackground:"#0F0E0E",testcolor:"green",margins:10,paddings:10,typography:{fontFamily:["IBMPlex"].join(","),primary:{color:"black"},secondary:{color:"white"}},logoButton:{primary:{borderRadius:10,backgroundColor:"#B20D30",marginTop:10,padding:30,paddingTop:0,paddingBottom:0,border:"1px solid #ced4da",height:50,"&:focus":{borderColor:"#B20D30"}},secondary:{borderRadius:10,backgroundColor:"#f90900",marginTop:10,padding:30,paddingTop:0,paddingBottom:0,border:"1px solid #ced4da",height:50,"&:focus":{borderColor:"green"}}},actionButton:{primary:{borderRadius:10,backgroundColor:"#B20D30",color:"white",margin:10,padding:10,border:"1px solid #ced4da",fontSize:16,height:50,"&:focus":{borderColor:"red"}},secondary:{borderRadius:10,margin:10,padding:10,backgroundColor:"#FF8811",color:"black"}},layout:{primary:{backgroundColor:"#d3d4d9",color:"black",margin:10,padding:10,borderRadius:10},secondary:{backgroundColor:"#001E3C",color:"white",margin:10,padding:10,borderRadius:10}},inputFields:{primary:{backgroundColor:"white",borderRadius:10,"&:focus":{borderColor:"red",borderWidth:1,border:"1px solid black"},"&:hover":{borderColor:"red",borderWidth:1,border:"1px solid black"}},secondary:{backgroundColor:"white",borderRadius:10}},alerts:{primary:{marginBottom:10,padding:10,borderRadius:10},secondary:{marginBottom:10,padding:10,borderRadius:10}},settingsRow:{primary:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"#F5F5F5",margin:0,padding:10,borderRadius:10},secondary:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"blue",margin:0,padding:5,borderRadius:10}},radioSelector:{primary:{padding:10,borderRadius:10},secondary:{padding:10,borderRadius:10}}},N=e.createContext(R);j.default.string,j.default.bool,j.default.bool,j.default.bool;var z=function(r){var t,n=e.useContext(N),i=n.hawaTheme,l=n.themeName,s=Object.keys(i.actionButton).find((function(e){return e.toLowerCase()===(null==l?void 0:l.toLowerCase())})),d={};s?d=W(W({},i.actionButton[s]),{},{margin:r.last?0:i.actionButton[s].margin,marginTop:r.last?2*i.actionButton[s].margin:0,"&:hover":{backgroundColor:o.darken(null===(t=i.actionButton[s])||void 0===t?void 0:t.backgroundColor,.1)}}):d={backgroundColor:"black",color:"white",padding:10,marginTop:r.last?20:0,borderRadius:0};var u=o.styled(y.default)((function(e){return e.theme,W({},d)}));return a.jsx(u,W(W({},r),{},{children:r.text}))},G=function(r){var t=e.useContext(N),o=t.hawaTheme,n=t.themeName,i={},l=Object.keys(o.layout).find((function(e){return e.toLowerCase()===(null==n?void 0:n.toLowerCase())}));return i=l?W(W({display:"flex",flexDirection:r.horizontal?"row":"column"},o.layout[l]),{},{backgroundColor:r.noColor?"none":o.layout[l].backgroundColor,padding:r.noPadding?0:o.layout[l].padding,margin:r.noMargin?0:o.layout[l].margin,maxWidth:r.maxWidth}):{display:"flex",flexDirection:r.horizontal?"row":"column",color:"white",marginTop:r.last?20:0,backgroundColor:r.noColor?"none":"lightGrey",padding:r.noPadding?0:10,margin:r.noMargin?0:10,maxWidth:r.maxWidth,borderRadius:0},a.jsx("div",{style:i,children:r.children})},D=function(r){var t=e.useContext(N),n=t.hawaTheme,i=t.themeName,l=Object.keys(n.typography).find((function(e){return e.toLowerCase()===(null==i?void 0:i.toLowerCase())})),s={};s=l?W({},n.typography[l]):{color:"black"};var d=o.styled(w.default)((function(e){return e.theme,W({},s)}));return a.jsx(d,W(W({},r),{},{children:r.children}))};j.default.oneOf(["text","number","password"]),j.default.string;var U=function(r){var t,n=e.useContext(N),i=n.hawaTheme,l=n.themeName,s={},d=Object.keys(i.logoButton).find((function(e){return e.toLowerCase()===(null==l?void 0:l.toLowerCase())}));s=d?W(W({},i.logoButton[d]),{},{backgroundColor:"white","&:hover":{backgroundColor:o.darken("#ffffff",.1)}}):{cursor:"pointer",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",marginTop:10,height:50,padding:30,paddingTop:0,paddingBottom:0,border:"1px solid #ced4da",backgroundColor:"white","&:hover":{backgroundColor:o.darken("#ffffff",.1)}};var u=o.styled(y.default)((function(e){return e.theme,W({},s)})),c="";switch(null===(t=r.logo)||void 0===t?void 0:t.toLowerCase()){case"google":c=a.jsx("img",{src:"https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"});break;case"github":c=a.jsx(v.default,{});break;case"twitter":c=a.jsx(C.default,{});break;case"mada":c=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png",height:20});break;case"stcpay":c=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png",height:20});break;case"visa/master":c=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png",height:30});break;case"paypal":c=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png",height:25});break;case"googlepay":c=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png",height:20});break;case"applepay":c=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png",height:40});break;case"wallet":c=a.jsx(k.default,{})}return a.jsxs(u,W(W({},r),{},{children:[c,a.jsx("div",{style:{width:10}}),a.jsx("p",{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:r.buttonText})]}))},V=function(r){var t=e.useContext(N),o=t.hawaTheme,n=t.themeName,i={},l=Object.keys(o.actionButton).find((function(e){return e.toLowerCase()===(null==n?void 0:n.toLowerCase())}));return i=l?{margin:15,marginRight:5,marginLeft:5,color:o.layout[l].color}:{margin:15,marginRight:0,marginLeft:0,color:"black"},a.jsx(T.default,{style:i,children:a.jsx("div",{style:{fontSize:15},children:r.label})})},Z=function(r){var t=c.useFormContext(),n=t.control,i=t.register,l=e.useContext(N),s=l.hawaTheme,d=l.themeName,u=Object.keys(s.inputFields).find((function(e){return e.toLowerCase()===(null==d?void 0:d.toLowerCase())})),m={};m=u?W(W({},s.inputFields[u]),{},{margin:r.last?0:s.inputFields[u].margin,marginTop:r.last?2*s.inputFields[u].margin:0}):{backgroundColor:"white"};var p=o.styled(P.default)((function(e){return W({"& .MuiInputBase-input":{transition:e.theme.transitions.create(["border-color","background-color","box-shadow"])},border:"1px solid #ced4da",fontSize:16,padding:"10px 12px",marginBottom:r.helperText?5:0,paddingLeft:10,paddingRight:10},m)}));return a.jsx(c.Controller,{render:function(e){var t;return e.field,a.jsxs(a.Fragment,{children:[r.inputLabel&&a.jsx(V,{label:r.inputLabel}),a.jsx(p,W(W({fullWidth:!0,type:null!==(t=r.type)&&void 0!==t?t:"text",defaultValue:r.defaultValue&&"",value:r.value&&""},r),i(r.name))),a.jsx(w.default,{variant:"caption",style:{margin:5,marginBottom:0,color:"red"},children:r.helperText})]})},name:r.name,rules:r.rules,control:n,shouldUnregister:r.shouldUnregister})};Z.propTypes={type:j.default.oneOf(["text","number","password"]),helperText:j.default.string};var $=function(r){var t=e.useContext(N),n=t.hawaTheme,i=t.themeName,l=Object.keys(n.alerts).find((function(e){return e.toLowerCase()===(null==i?void 0:i.toLowerCase())})),s={};s=l?W({},n.alerts[l]):{marginBottom:10};var d=o.styled(S.default)((function(e){return e.theme,W({},s)}));return a.jsxs(d,W(W({},r),{},{children:[r.title&&a.jsx(L.default,{children:r.title}),r.text]}))},_=function(e){var r,t,o,n=c.useForm(),i=n.formState.errors,l=n.handleSubmit;return n.getValues,n.register,n.watch,n.reset,n.setValue,a.jsxs(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:[a.jsxs(G,{noMargin:!0,children:[e.error&&a.jsx($,{text:"This is a sign in alert",severity:"error"}),a.jsx(c.FormProvider,W(W({},n),{},{children:a.jsxs("form",{onSubmit:l(e.handleSignUp),children:[a.jsx(Z,{name:"fullName",placeholder:"Fulan AlFulani",type:"text",inputLabel:"Full Name",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(B.default,{})}),rules:{required:"Full name rquired"},helperText:null===(r=i.fullName)||void 0===r?void 0:r.message}),a.jsx(Z,{type:"text",inputLabel:"Email",placeholder:"Enter your email",name:"email",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(A.default,{})}),rules:{required:"Email required",pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Invalid email address"}},helperText:null===(t=i.email)||void 0===t?void 0:t.message}),a.jsx(Z,{name:"password",placeholder:"Minimum 8 characters",type:"password",inputLabel:"Password",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:"Password rquired",minLength:{value:8,message:"Password too short"}},helperText:null===(o=i.password)||void 0===o?void 0:o.message}),a.jsx(z,{fullWidth:!0,type:"submit",text:"Sign Up",last:!0})]})}))]}),a.jsxs(D,{style:{marginTop:5,textAlign:"center",padding:5},children:["Existing user?"," ",a.jsx("span",{onClick:function(){return console.log("res")},style:{cursor:"pointer",color:"blue",textAlign:"center"},children:"Sign in"})]}),e.viaGoogle&&a.jsx(U,{logo:"google",buttonText:e.googleButtonLabel,handleClick:e.handleGoogleSignIn}),e.viaGithub&&a.jsx(U,{logo:"github",buttonText:e.githubButtonLabel,handleClick:e.handleGithubSignIn}),e.viaTwitter&&a.jsx(U,{logo:"twitter",buttonText:e.twitterButtonLabel,handleClick:e.handleTwitterSignIn})]})};_.propTypes={theme:j.default.oneOf(["secondary","primary"])};Z.propTypes={theme:j.default.oneOf(["secondary","primary"]),viaApplePay:j.default.bool,viaGooglePay:j.default.bool,viaSTCPay:j.default.bool,viaCreditCard:j.default.bool,viaPayPal:j.default.bool,handleApplePay:j.default.func};exports.ChargeWalletForm=function(r){var t,o=E(e.useState(0),2),n=o[0],i=o[1],l=c.useForm(),s=l.formState.errors,d=l.handleSubmit;return a.jsx(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(G,{noMargin:!0,children:[a.jsxs(D,{variant:"h2",align:"center",children:[Number(n).toLocaleString("en")," ",a.jsx("span",{style:{fontSize:20,letterSpacing:1},children:r.currency})]}),a.jsx(c.FormProvider,W(W({},l),{},{children:a.jsxs("form",{onChange:function(e){e.preventDefault(),i(l.getValues().amount)},style:{marginTop:10},onSubmit:d(r.handleChargeWallet),children:[a.jsx(Z,{name:"amount",placeholder:"Enter amount",type:"number",value:n,rules:{required:"Password is rquired"},helperText:null===(t=s.amount)||void 0===t?void 0:t.message}),a.jsx(z,{last:!0,fullWidth:!0,text:"Charge Wallet",onClick:r.handleSignIn})]})}))]})})},exports.CreditCardForm=function(e){var r,t,o=c.useForm(),n=o.formState.errors,i=o.handleSubmit;return a.jsx(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsx(G,{noMargin:!0,children:a.jsx(c.FormProvider,W(W({},o),{},{children:a.jsxs("form",{onSubmit:i(e.handle),children:[a.jsx(Z,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(r=n.password)||void 0===r?void 0:r.message}),a.jsx(Z,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a.jsx(z,{last:!0,fullWidth:!0,text:"Sign In",onClick:e.handleSignIn})]})}))})})},exports.NewPasswordForm=function(r){var t,o,n=E(e.useState(""),2),i=n[0],l=n[1],s=E(e.useState(""),2);s[0],s[1];var d=E(e.useState(!1),2);d[0],d[1];var u=E(e.useState(""),2);u[0],u[1];var m=E(e.useState(!0),2);m[0],m[1];var p=c.useForm(),g=p.formState.errors,h=p.handleSubmit;return p.getValues,p.register,p.watch,p.reset,p.setValue,a.jsx(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(G,{noMargin:!0,children:[r.error&&a.jsx($,{text:"This is a new password alert",severity:"error"}),r.passwordChanged?a.jsx(D,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a.jsx(c.FormProvider,W(W({},p),{},{children:a.jsxs("form",{onSubmit:h(r.handleNewPassword),children:[a.jsx(Z,{name:"password",type:"password",inputLabel:"Choose new password",placeholder:"Enter password",onChange:function(e){return l(e.target.value)},value:i,startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:"Password is rquired"},helperText:null===(t=g.password)||void 0===t?void 0:t.message}),a.jsx(Z,{name:"confirmPassword",type:"password",placeholder:"Confirm Password",inputLabel:"Confirm",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:"Password is rquired"},helperText:null===(o=g.confirmPassword)||void 0===o?void 0:o.message}),a.jsx(z,{fullWidth:!0,type:"submit",last:!0,text:"Reset Password"})]})}))]})})},exports.PayWithWallet=function(e){return a.jsx(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(G,{noMargin:!0,children:[a.jsx("div",{children:"Wallet Balance"}),a.jsx(z,{text:"Pay now"})]})})},exports.ResetPasswordForm=function(e){var r,t=c.useForm(),o=t.formState.errors,n=t.handleSubmit;return t.getValues,t.register,t.watch,t.reset,t.setValue,a.jsx(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(G,{noMargin:!0,children:[e.error&&a.jsx($,{text:"This is a reset password alert",severity:"error"}),e.sent?a.jsx(D,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):a.jsx(c.FormProvider,W(W({},t),{},{children:a.jsxs("form",{onSubmit:n(e.handleResetPassword),children:[a.jsx(Z,{type:"text",name:"email",inputLabel:"Email",placeholder:"Enter your email",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(A.default,{})}),rules:{required:"Email is required",pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Invalid email address"}},helperText:null===(r=o.email)||void 0===r?void 0:r.message}),a.jsx(z,{fullWidth:!0,last:!0,type:"submit",text:"Reset Password"})]})}))]})})},exports.SelectPayment=function(e){return a.jsx(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(G,{noMargin:!0,children:[a.jsx(D,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a.jsx(U,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a.jsx(U,{logo:"visa/master",buttonText:e.visaMasterLabel,handleClick:e.handleCreditCard}),e.viaMada&&a.jsx(U,{logo:"mada",buttonText:e.madaLabel,handleClick:e.handleMada}),e.viaSTCPay&&a.jsx(U,{logo:"stcpay",buttonText:e.stcPayLabel,handleClick:e.handleSTCPay}),e.viaPayPal&&a.jsx(U,{logo:"paypal",buttonText:e.paypalLabel,handleClick:e.handlePayPal}),e.viaGooglePay&&a.jsx(U,{logo:"googlepay",buttonText:e.googlePayLabel,handleClick:e.handleGooglePay}),e.viaApplePay&&a.jsx(U,{logo:"applepay",buttonText:e.applePayLabel,handleClick:e.handleApplePay})]})})},exports.SignInForm=function(e){var r,t,o=c.useForm(),n=o.formState.errors,i=o.handleSubmit;return a.jsxs(G,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:[a.jsxs(G,{noMargin:!0,children:[e.error&&a.jsx($,{text:"This is a sign in alert",severity:"error"}),a.jsx(c.FormProvider,W(W({},o),{},{children:a.jsxs("form",{onSubmit:i(e.handleSignIn),children:[a.jsx(Z,{type:"text",name:"email",inputLabel:"Email",placeholder:"Enter your email",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(A.default,{})}),rules:{required:"Email is required",pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Invalid email address"}},helperText:null===(r=n.email)||void 0===r?void 0:r.message}),a.jsx(Z,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",startAdornment:a.jsx(q.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a.jsx(D,{style:{cursor:"pointer",marginTop:5,width:"max-content",padding:5},onClick:function(){return console.log("res")},children:"Forgot password?"}),a.jsx(z,{type:"submit",fullWidth:!0,last:"true",text:"Sign In"})]})}))]}),a.jsxs(D,{style:{marginTop:5,textAlign:"center",padding:5},children:["New user?"," ",a.jsx("span",{onClick:function(){return console.log("res")},style:{cursor:"pointer",color:"blue",textAlign:"center"},children:"Sign up"})]}),e.viaGoogle&&a.jsx(U,{logo:"google",buttonText:e.googleButtonLabel,handleClick:e.handleGoogleSignIn}),e.viaGithub&&a.jsx(U,{logo:"github",buttonText:e.githubButtonLabel,handleClick:e.handleGithubSignIn}),e.viaTwitter&&a.jsx(U,{logo:"twitter",buttonText:e.twitterButtonLabel,handleClick:e.handleTwitterSignIn})]})},exports.SignUpForm=_,exports.UserProfile=function(e){var r,t,o,n,i=c.useForm(),l=i.formState.errors;return i.handleSubmit,a.jsx(G,{maxWidth:400,noMargin:!0,children:a.jsx(G,{noMargin:!0,noColor:!0,children:a.jsx(c.FormProvider,W(W({},i),{},{children:a.jsxs("form",{children:[a.jsx(Z,{type:"text",name:"fullName",inputLabel:"Full Name",placeholder:"Fulan AlFulani",rules:{required:"Email is required"},helperText:null===(r=l.fullName)||void 0===r?void 0:r.message}),a.jsx(Z,{type:"text",name:"email",inputLabel:"New Email",placeholder:"Enter your new email",rules:{required:"Email is required"},helperText:null===(t=l.email)||void 0===t?void 0:t.message}),a.jsx(Z,{type:"password",name:"password",inputLabel:"New password",placeholder:"Enter your new password",rules:{required:"Email is required"},helperText:null===(o=l.password)||void 0===o?void 0:o.message}),a.jsx(Z,{type:"password",name:"confirmPassword",inputLabel:"Confirm new password",placeholder:"Confirm new password",rules:{required:"Email is required"},helperText:null===(n=l.confirmPassword)||void 0===n?void 0:n.message}),a.jsx(z,{fullWidth:!0,last:!0,text:"Update Account"})]})}))})})},exports.UserSettings=function(e){return a.jsxs(G,{maxWidth:400,children:[a.jsx(Z,{type:"text",inputLabel:"First Name"}),a.jsx(Z,{type:"text",inputLabel:"Last Name"}),a.jsx(Z,{type:"email",inputLabel:"Email"}),a.jsx(Z,{type:"password",inputLabel:"Password"}),a.jsx(z,{last:!0,text:"Update Account"})]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@mui/material/Button");require("@mui/material/Tooltip");var r=require("prop-types"),a=require("react/jsx-runtime");require("@mui/material/FormControlLabel"),require("@mui/material/Checkbox");var l=require("@mui/material");require("@mui/material/TextField");var s=require("@mui/material/Typography"),i=require("@mui/icons-material/GitHub"),n=require("@mui/icons-material/Twitter"),o=require("@mui/icons-material/AccountBalanceWallet"),d=require("@mui/material/Input"),u=require("@mui/material/InputLabel"),m=require("@mui/material/Alert"),x=require("@mui/material/AlertTitle"),p=require("react-hook-form"),c=require("@mui/material/Container"),h=require("@mui/material/InputAdornment"),g=require("@mui/icons-material/HttpsOutlined"),f=require("@mui/icons-material/MailOutline"),b=require("@mui/icons-material/PermIdentityOutlined");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=j(t),v=j(r),w=j(s),T=j(i),P=j(n),S=j(o),q=j(d),C=j(u),k=j(m),A=j(x),W=j(c),L=j(h),F=j(g),O=j(f),I=j(b);function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function z(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function G(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var a,l,s=[],i=!0,n=!1;try{for(r=r.call(e);!(i=(a=r.next()).done)&&(s.push(a.value),!t||s.length!==t);i=!0);}catch(e){n=!0,l=e}finally{try{i||null==r.return||r.return()}finally{if(n)throw l}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return U(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return U(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}v.default.string,v.default.bool,v.default.bool,v.default.bool;var M=function(e){return a.jsx(y.default,N(N({},e),{},{children:e.text}))},R=function(e){return a.jsx("div",{children:e.children})},B=function(e){return a.jsx(w.default,N(N({},e),{},{children:e.children}))};v.default.oneOf(["text","number","password"]),v.default.string;var D=function(e){var t,r="";switch(null===(t=e.logo)||void 0===t?void 0:t.toLowerCase()){case"google":r=a.jsx("img",{src:"https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"});break;case"github":r=a.jsx(T.default,{});break;case"twitter":r=a.jsx(P.default,{});break;case"mada":r=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png",height:20});break;case"stcpay":r=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png",height:20});break;case"visa/master":r=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png",height:30});break;case"paypal":r=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png",height:25});break;case"googlepay":r=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png",height:20});break;case"applepay":r=a.jsx("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png",height:40});break;case"wallet":r=a.jsx(S.default,{})}return a.jsxs(y.default,N(N({},e),{},{variant:"withLogo",children:[r,a.jsx("div",{style:{width:10}}),a.jsx(l.Typography,{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:e.buttonText})]}))},Z=function(e){return a.jsxs(a.Fragment,{children:[a.jsx(C.default,{children:e.label}),a.jsx(q.default,N({disableUnderline:!0},e))]})},$=function(e){return a.jsxs(k.default,{children:[e.title&&a.jsx(A.default,{children:e.title}),e.text]})},_=function(e){var t,r,l,s=p.useForm(),i=s.formState.errors,n=s.handleSubmit;return a.jsxs(W.default,{maxWidth:"xs",variant:"auth",children:[e.error&&a.jsxs(k.default,{severity:"error",children:[e.errorTitle&&a.jsx(AlertTitle,{children:e.errorTitle}),e.errorText]}),a.jsx(p.FormProvider,N(N({},s),{},{children:a.jsxs("form",{onSubmit:n(e.handleSignUp),children:[a.jsx(Z,{fullWidth:!0,type:"text",label:e.texts.fullNameLabel,name:"fullName",placeholder:e.texts.fullNamePlaceholder,inputLabel:e.texts.fullNameLabel,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(I.default,{})}),helperText:null===(t=i.fullName)||void 0===t?void 0:t.message}),a.jsx(Z,{fullWidth:!0,type:"text",label:e.texts.emailLabel,placeholder:e.texts.emailPlaceholder,name:"email",startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(O.default,{})}),rules:{required:e.texts.emailRequiredText,pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:e.texts.emailInvalidText}},helperText:null===(r=i.email)||void 0===r?void 0:r.message}),a.jsx(Z,{fullWidth:!0,name:"password",placeholder:e.texts.passwordPlaceholder,type:"password",label:e.texts.passwordLabel,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:e.texts.passwordRequiredText,minLength:{value:8,message:e.texts.passwordTooShortText}},helperText:null===(l=i.password)||void 0===l?void 0:l.message}),a.jsx(y.default,{fullWidth:!0,variant:"last",type:"submit",children:e.texts.signUpText})]})})),a.jsxs(w.default,{variant:"subtitle2",style:{marginTop:5,textAlign:"center",padding:5},children:["Existing user?"," ",a.jsx("span",{onClick:e.handleRouteToSignIn,style:{cursor:"pointer",color:"blue",textAlign:"center"},children:e.texts.signInText})]}),a.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a.jsx(D,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignUp}),e.viaGithub&&a.jsx(D,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignUp}),e.viaTwitter&&a.jsx(D,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignUp})]})]})};_.propTypes={theme:v.default.oneOf(["secondary","primary"])};Z.propTypes={theme:v.default.oneOf(["secondary","primary"]),viaApplePay:v.default.bool,viaGooglePay:v.default.bool,viaSTCPay:v.default.bool,viaCreditCard:v.default.bool,viaPayPal:v.default.bool,handleApplePay:v.default.func};exports.ChargeWalletForm=function(t){var r,l=G(e.useState(0),2),s=l[0],i=l[1],n=p.useForm(),o=n.formState.errors,d=n.handleSubmit;return a.jsx(R,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(R,{noMargin:!0,children:[a.jsxs(B,{variant:"h2",align:"center",children:[Number(s).toLocaleString("en")," ",a.jsx("span",{style:{fontSize:20,letterSpacing:1},children:t.currency})]}),a.jsx(p.FormProvider,N(N({},n),{},{children:a.jsxs("form",{onChange:function(e){e.preventDefault(),i(n.getValues().amount)},style:{marginTop:10},onSubmit:d(t.handleChargeWallet),children:[a.jsx(Z,{name:"amount",placeholder:"Enter amount",type:"number",value:s,rules:{required:"Password is rquired"},helperText:null===(r=o.amount)||void 0===r?void 0:r.message}),a.jsx(M,{last:!0,fullWidth:!0,text:"Charge Wallet",onClick:t.handleSignIn})]})}))]})})},exports.CreditCardForm=function(e){var t,r,l=p.useForm(),s=l.formState.errors,i=l.handleSubmit;return a.jsx(R,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsx(R,{noMargin:!0,children:a.jsx(p.FormProvider,N(N({},l),{},{children:a.jsxs("form",{onSubmit:i(e.handle),children:[a.jsx(Z,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(t=s.password)||void 0===t?void 0:t.message}),a.jsx(Z,{name:"password",placeholder:"Enter password",type:"password",inputLabel:"Password",rules:{required:"Password is rquired"},helperText:null===(r=s.password)||void 0===r?void 0:r.message}),a.jsx(M,{last:!0,fullWidth:!0,text:"Sign In",onClick:e.handleSignIn})]})}))})})},exports.NewPasswordForm=function(t){var r,l,s=G(e.useState(""),2),i=s[0],n=s[1],o=p.useForm(),d=o.formState.errors,u=o.handleSubmit;return a.jsxs(W.default,{maxWidth:"xs",variant:"auth",children:[t.error&&a.jsx($,{text:"This is a new password alert",severity:"error"}),t.passwordChanged?a.jsx(B,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a.jsx(p.FormProvider,N(N({},o),{},{children:a.jsxs("form",{onSubmit:u(t.handleNewPassword),children:[a.jsx(Z,{fullWidth:!0,name:"password",type:"password",label:t.texts.passwordLabel,placeholder:t.texts.passwordPlaceholder,onChange:function(e){return n(e.target.value)},value:i,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:t.texts.passwordRequiredText},helperText:null===(r=d.password)||void 0===r?void 0:r.message}),a.jsx(Z,{fullWidth:!0,name:"confirmPassword",type:"password",placeholder:t.texts.confirmPasswordPlaceholder,label:t.texts.confirmPasswordLabel,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:"Password is rquired"},helperText:null===(l=d.confirmPassword)||void 0===l?void 0:l.message}),a.jsx(y.default,{type:"submit",fullWidth:!0,variant:"last",children:t.texts.updatePassword})]})}))]})},exports.PayWithWallet=function(e){return a.jsx(R,{maxWidth:400,noColor:!0,noMargin:!0,noPadding:!0,children:a.jsxs(R,{noMargin:!0,children:[a.jsx("div",{children:"Wallet Balance"}),a.jsx(M,{text:"Pay now"})]})})},exports.ResetPasswordForm=function(e){var t,r=p.useForm(),l=r.formState.errors,s=r.handleSubmit;return r.getValues,r.register,r.watch,r.reset,r.setValue,a.jsxs(W.default,{maxWidth:"xs",variant:"auth",children:[e.error&&a.jsxs(Alert,{severity:"error",children:[e.errorTitle&&a.jsx(AlertTitle,{children:e.errorTitle}),e.errorText]}),e.sent?a.jsx(B,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):a.jsx(p.FormProvider,N(N({},r),{},{children:a.jsxs("form",{onSubmit:s(e.handleResetPassword),children:[a.jsx(Z,{fullWidth:!0,type:"text",name:"email",label:e.texts.emailLabel,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(O.default,{})}),rules:{required:e.texts.emailRequiredText,pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:e.texts.emailInvalidText}},helperText:null===(t=l.email)||void 0===t?void 0:t.message}),a.jsx(y.default,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.resetPassword})]})}))]})},exports.SelectPayment=function(e){return a.jsxs(l.Container,{maxWidth:"xs",children:[a.jsx(B,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a.jsx(D,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a.jsx(D,{logo:"visa/master",buttonText:e.visaMasterLabel,handleClick:e.handleCreditCard}),e.viaMada&&a.jsx(D,{logo:"mada",buttonText:e.madaLabel,handleClick:e.handleMada}),e.viaSTCPay&&a.jsx(D,{logo:"stcpay",buttonText:e.stcPayLabel,handleClick:e.handleSTCPay}),e.viaPayPal&&a.jsx(D,{logo:"paypal",buttonText:e.paypalLabel,handleClick:e.handlePayPal}),e.viaGooglePay&&a.jsx(D,{logo:"googlepay",buttonText:e.googlePayLabel,handleClick:e.handleGooglePay}),e.viaApplePay&&a.jsx(D,{logo:"applepay",buttonText:e.applePayLabel,handleClick:e.handleApplePay})]})},exports.SignInForm=function(e){var t,r,l=p.useForm(),s=l.formState.errors,i=l.handleSubmit;return a.jsxs(W.default,{maxWidth:"xs",variant:"auth",children:[e.error&&a.jsxs(k.default,{severity:"error",children:[e.errorTitle&&a.jsx(AlertTitle,{children:e.errorTitle}),e.errorText]}),a.jsx(p.FormProvider,N(N({},l),{},{children:a.jsxs("form",{onSubmit:i(e.handleSignIn),children:[a.jsx(Z,{fullWidth:!0,type:"text",name:"email",label:e.texts.emailLabel,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(O.default,{})}),rules:{required:e.texts.emailRequired,pattern:{value:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:e.texts.emailInvalidText}},helperText:null===(t=s.email)||void 0===t?void 0:t.message}),a.jsx(Z,{fullWidth:!0,name:"password",placeholder:e.texts.passwordPlaceholder,type:"password",label:e.texts.passwordLabel,startAdornment:a.jsx(L.default,{position:"start",children:a.jsx(F.default,{})}),rules:{required:e.texts.passwordRequired},helperText:null===(r=s.password)||void 0===r?void 0:r.message}),a.jsx(B,{style:{cursor:"pointer",marginTop:5,width:"max-content",padding:5},onClick:e.handleForgotPassword,children:e.texts.forgotPasswordText}),a.jsx(y.default,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.signInText})]})})),a.jsxs(B,{style:{marginTop:5,textAlign:"center",padding:5},children:[e.texts.newUserText," ",a.jsx("span",{onClick:e.handleRouteToSignUp,style:{cursor:"pointer",color:"blue",textAlign:"center"},children:e.texts.signUpText})]}),a.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a.jsx(D,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignIn}),e.viaGithub&&a.jsx(D,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignIn}),e.viaTwitter&&a.jsx(D,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignIn})]})]})},exports.SignUpForm=_,exports.UserProfile=function(e){var t,r,s,i,n=p.useForm(),o=n.formState.errors;return n.handleSubmit,a.jsx(W.default,{maxWidth:"xs",children:a.jsx(p.FormProvider,N(N({},n),{},{children:a.jsxs("form",{children:[a.jsx(Z,{fullWidth:!0,type:"text",name:"fullName",label:"Full Name",placeholder:"Fulan AlFulani",rules:{required:"Email is required"},helperText:null===(t=o.fullName)||void 0===t?void 0:t.message}),a.jsx(Z,{fullWidth:!0,type:"text",name:"email",label:"New Email",placeholder:"Enter your new email",rules:{required:"Email is required"},helperText:null===(r=o.email)||void 0===r?void 0:r.message}),a.jsx(Z,{fullWidth:!0,type:"password",name:"password",label:"New password",placeholder:"Enter your new password",rules:{required:"Email is required"},helperText:null===(s=o.password)||void 0===s?void 0:s.message}),a.jsx(Z,{fullWidth:!0,type:"password",name:"confirmPassword",label:"Confirm new password",placeholder:"Confirm new password",rules:{required:"Email is required"},helperText:null===(i=o.confirmPassword)||void 0===i?void 0:i.message}),a.jsx(l.Button,{type:"submit",fullWidth:!0,variant:"last",children:"update profile"})," "]})}))})},exports.UserSettings=function(e){return a.jsxs(R,{maxWidth:400,children:[a.jsx(Z,{type:"text",inputLabel:"First Name"}),a.jsx(Z,{type:"text",inputLabel:"Last Name"}),a.jsx(Z,{type:"email",inputLabel:"Email"}),a.jsx(Z,{type:"password",inputLabel:"Password"}),a.jsx(M,{last:!0,text:"Update Account"})]})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sikka/hawa",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "UI Kit",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.es.js",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"rollup-plugin-babel": "^4.4.0",
|
|
43
43
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
44
44
|
"rollup-plugin-postcss": "^4.0.0",
|
|
45
|
-
"rollup-plugin-terser": "^7.0.2"
|
|
45
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
46
|
+
"emotion-theming": "^11.0.0"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"@emotion/react": "^11.8.2",
|
|
@@ -2,6 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { HawaInputLabel, ActionButton, HawaTextField } from "../../ui";
|
|
3
3
|
import { Box } from "../../layout";
|
|
4
4
|
import { FormProvider, useForm } from "react-hook-form";
|
|
5
|
+
import Container from "@mui/material/Container";
|
|
6
|
+
import { Button } from "@mui/material";
|
|
5
7
|
|
|
6
8
|
export const UserProfile = (props) => {
|
|
7
9
|
const methods = useForm();
|
|
@@ -11,55 +13,58 @@ export const UserProfile = (props) => {
|
|
|
11
13
|
} = methods;
|
|
12
14
|
|
|
13
15
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
16
|
+
<Container maxWidth="xs">
|
|
17
|
+
<FormProvider {...methods}>
|
|
18
|
+
<form>
|
|
19
|
+
<HawaTextField
|
|
20
|
+
fullWidth
|
|
21
|
+
type="text"
|
|
22
|
+
name="fullName"
|
|
23
|
+
label="Full Name"
|
|
24
|
+
placeholder="Fulan AlFulani"
|
|
25
|
+
rules={{
|
|
26
|
+
required: "Email is required"
|
|
27
|
+
}}
|
|
28
|
+
helperText={errors.fullName?.message}
|
|
29
|
+
/>
|
|
30
|
+
<HawaTextField
|
|
31
|
+
fullWidth
|
|
32
|
+
type="text"
|
|
33
|
+
name="email"
|
|
34
|
+
label="New Email"
|
|
35
|
+
placeholder="Enter your new email"
|
|
36
|
+
rules={{
|
|
37
|
+
required: "Email is required"
|
|
38
|
+
}}
|
|
39
|
+
helperText={errors.email?.message}
|
|
40
|
+
/>
|
|
41
|
+
<HawaTextField
|
|
42
|
+
fullWidth
|
|
43
|
+
type="password"
|
|
44
|
+
name="password"
|
|
45
|
+
label="New password"
|
|
46
|
+
placeholder="Enter your new password"
|
|
47
|
+
rules={{
|
|
48
|
+
required: "Email is required"
|
|
49
|
+
}}
|
|
50
|
+
helperText={errors.password?.message}
|
|
51
|
+
/>
|
|
52
|
+
<HawaTextField
|
|
53
|
+
fullWidth
|
|
54
|
+
type="password"
|
|
55
|
+
name="confirmPassword"
|
|
56
|
+
label="Confirm new password"
|
|
57
|
+
placeholder="Confirm new password"
|
|
58
|
+
rules={{
|
|
59
|
+
required: "Email is required"
|
|
60
|
+
}}
|
|
61
|
+
helperText={errors.confirmPassword?.message}
|
|
62
|
+
/>
|
|
63
|
+
<Button type="submit" fullWidth variant="last">
|
|
64
|
+
update profile
|
|
65
|
+
</Button>{" "}
|
|
66
|
+
</form>
|
|
67
|
+
</FormProvider>
|
|
68
|
+
</Container>
|
|
64
69
|
);
|
|
65
70
|
};
|
|
@@ -9,99 +9,71 @@ import {
|
|
|
9
9
|
import { FormProvider, useForm } from "react-hook-form";
|
|
10
10
|
import InputAdornment from "@mui/material/InputAdornment";
|
|
11
11
|
import PasswordIcon from "@mui/icons-material/HttpsOutlined";
|
|
12
|
+
import Container from "@mui/material/Container";
|
|
13
|
+
import Button from "@mui/material/Button";
|
|
14
|
+
import Alert from "@mui/material/Alert";
|
|
12
15
|
|
|
13
16
|
export const NewPasswordForm = (props) => {
|
|
14
17
|
const [newPassword, setNewPassword] = useState("");
|
|
15
|
-
const [confirmNewPassword, setConfirmNewPassword] = useState("");
|
|
16
|
-
const [error, setError] = useState(false);
|
|
17
|
-
const [errorMessage, setErrorMessage] = useState("");
|
|
18
|
-
const [loading, setLoading] = useState(true);
|
|
19
|
-
|
|
20
18
|
const methods = useForm();
|
|
21
19
|
const {
|
|
22
20
|
formState: { errors },
|
|
23
|
-
handleSubmit
|
|
24
|
-
getValues,
|
|
25
|
-
register,
|
|
26
|
-
watch,
|
|
27
|
-
reset,
|
|
28
|
-
setValue
|
|
21
|
+
handleSubmit
|
|
29
22
|
} = methods;
|
|
30
23
|
|
|
31
|
-
const handleNewPassword = (e) => {
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
console.log("submitting fom", e.target);
|
|
34
|
-
// setLoading(true);
|
|
35
|
-
// e.preventDefault();
|
|
36
|
-
// if (newPassword == "" || confirmNewPassword == "") {
|
|
37
|
-
// setLoading(false);
|
|
38
|
-
// return;
|
|
39
|
-
// }
|
|
40
|
-
// if (newPassword != confirmNewPassword) {
|
|
41
|
-
// setError(true);
|
|
42
|
-
// setLoading(false);
|
|
43
|
-
// // setErrorMessage(t("password-no-match"));
|
|
44
|
-
// return;
|
|
45
|
-
// }
|
|
46
|
-
// if (newPassword == confirmNewPassword) {
|
|
47
|
-
// //mutation to reset password here
|
|
48
|
-
// }
|
|
49
|
-
};
|
|
50
24
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
</Box>
|
|
105
|
-
</Box>
|
|
25
|
+
<Container maxWidth="xs" variant="auth">
|
|
26
|
+
{props.error && (
|
|
27
|
+
<HawaAlert text="This is a new password alert" severity="error" />
|
|
28
|
+
)}
|
|
29
|
+
{props.passwordChanged ? (
|
|
30
|
+
<HawaTypography style={{ textAlign: "center", margin: 5 }}>
|
|
31
|
+
Your password has been changed, you'll be redirected to sign in page
|
|
32
|
+
</HawaTypography>
|
|
33
|
+
) : (
|
|
34
|
+
<FormProvider {...methods}>
|
|
35
|
+
<form onSubmit={handleSubmit(props.handleNewPassword)}>
|
|
36
|
+
<HawaTextField
|
|
37
|
+
fullWidth
|
|
38
|
+
name="password"
|
|
39
|
+
type="password"
|
|
40
|
+
label={props.texts.passwordLabel}
|
|
41
|
+
placeholder={props.texts.passwordPlaceholder}
|
|
42
|
+
onChange={(e) => setNewPassword(e.target.value)}
|
|
43
|
+
value={newPassword}
|
|
44
|
+
startAdornment={
|
|
45
|
+
<InputAdornment position="start">
|
|
46
|
+
<PasswordIcon />
|
|
47
|
+
</InputAdornment>
|
|
48
|
+
}
|
|
49
|
+
rules={{
|
|
50
|
+
required: props.texts.passwordRequiredText
|
|
51
|
+
}}
|
|
52
|
+
helperText={errors.password?.message}
|
|
53
|
+
/>
|
|
54
|
+
<HawaTextField
|
|
55
|
+
fullWidth
|
|
56
|
+
name="confirmPassword"
|
|
57
|
+
type="password"
|
|
58
|
+
placeholder={props.texts.confirmPasswordPlaceholder}
|
|
59
|
+
label={props.texts.confirmPasswordLabel}
|
|
60
|
+
startAdornment={
|
|
61
|
+
<InputAdornment position="start">
|
|
62
|
+
<PasswordIcon />
|
|
63
|
+
</InputAdornment>
|
|
64
|
+
}
|
|
65
|
+
rules={{
|
|
66
|
+
required: "Password is rquired"
|
|
67
|
+
}}
|
|
68
|
+
helperText={errors.confirmPassword?.message}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
<Button type="submit" fullWidth variant="last">
|
|
72
|
+
{props.texts.updatePassword}
|
|
73
|
+
</Button>
|
|
74
|
+
</form>
|
|
75
|
+
</FormProvider>
|
|
76
|
+
)}
|
|
77
|
+
</Container>
|
|
106
78
|
);
|
|
107
79
|
};
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from "../../ui";
|
|
10
10
|
import InputAdornment from "@mui/material/InputAdornment";
|
|
11
11
|
import EmailIcon from "@mui/icons-material/MailOutline";
|
|
12
|
+
import Container from "@mui/material/Container";
|
|
13
|
+
import Button from "@mui/material/Button";
|
|
12
14
|
|
|
13
15
|
export const ResetPasswordForm = (props) => {
|
|
14
16
|
const methods = useForm();
|
|
@@ -22,48 +24,47 @@ export const ResetPasswordForm = (props) => {
|
|
|
22
24
|
setValue
|
|
23
25
|
} = methods;
|
|
24
26
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
<Container maxWidth="xs" variant="auth">
|
|
28
|
+
{props.error && (
|
|
29
|
+
<Alert severity="error">
|
|
30
|
+
{props.errorTitle && <AlertTitle>{props.errorTitle}</AlertTitle>}
|
|
31
|
+
{props.errorText}
|
|
32
|
+
</Alert>
|
|
33
|
+
)}
|
|
34
|
+
{!props.sent ? (
|
|
35
|
+
<FormProvider {...methods}>
|
|
36
|
+
<form onSubmit={handleSubmit(props.handleResetPassword)}>
|
|
37
|
+
<HawaTextField
|
|
38
|
+
fullWidth
|
|
39
|
+
type="text"
|
|
40
|
+
name="email"
|
|
41
|
+
label={props.texts.emailLabel}
|
|
42
|
+
placeholder={props.texts.emailPlaceholder}
|
|
43
|
+
startAdornment={
|
|
44
|
+
<InputAdornment position="start">
|
|
45
|
+
<EmailIcon />
|
|
46
|
+
</InputAdornment>
|
|
47
|
+
}
|
|
48
|
+
rules={{
|
|
49
|
+
required: props.texts.emailRequiredText,
|
|
50
|
+
pattern: {
|
|
51
|
+
value:
|
|
52
|
+
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
53
|
+
message: props.texts.emailInvalidText
|
|
42
54
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
text="Reset Password"
|
|
58
|
-
/>
|
|
59
|
-
</form>
|
|
60
|
-
</FormProvider>
|
|
61
|
-
) : (
|
|
62
|
-
<HawaTypography style={{ textAlign: "center", margin: 5 }}>
|
|
63
|
-
An link was sent to your email to reset the password.
|
|
64
|
-
</HawaTypography>
|
|
65
|
-
)}
|
|
66
|
-
</Box>
|
|
67
|
-
</Box>
|
|
55
|
+
}}
|
|
56
|
+
helperText={errors.email?.message}
|
|
57
|
+
/>
|
|
58
|
+
<Button type="submit" fullWidth variant="last">
|
|
59
|
+
{props.texts.resetPassword}
|
|
60
|
+
</Button>
|
|
61
|
+
</form>
|
|
62
|
+
</FormProvider>
|
|
63
|
+
) : (
|
|
64
|
+
<HawaTypography style={{ textAlign: "center", margin: 5 }}>
|
|
65
|
+
An link was sent to your email to reset the password.
|
|
66
|
+
</HawaTypography>
|
|
67
|
+
)}
|
|
68
|
+
</Container>
|
|
68
69
|
);
|
|
69
70
|
};
|