@sikka/hawa 0.0.15 → 0.0.18

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.
Files changed (66) hide show
  1. package/.github/workflows/hawa-publish-push.yml +1 -0
  2. package/es/index.es.js +1 -1
  3. package/lib/index.js +1 -1
  4. package/package.json +1 -1
  5. package/src/blocks/Account/UserProfileForm.js +79 -43
  6. package/src/blocks/Account/UserSettingsForm.js +7 -2
  7. package/src/blocks/AuthForms/SignInForm.js +5 -1
  8. package/src/blocks/AuthForms/SignUpForm.js +6 -2
  9. package/src/blocks/Payment/ChargeWalletForm.js +29 -20
  10. package/src/elements/HawaAlert.js +1 -24
  11. package/src/elements/HawaTable.js +39 -0
  12. package/src/elements/HawaTypography.js +0 -19
  13. package/src/elements/OfflineBanner.js +20 -0
  14. package/src/elements/index.js +2 -0
  15. package/src/layout/HawaDialog.js +45 -0
  16. package/src/layout/index.js +1 -0
  17. package/storybook-static/{0.f47eb24a4893a96ec307.manager.bundle.js → 0.42b12e88e2d7c13fc83c.manager.bundle.js} +1 -1
  18. package/storybook-static/{4.0fcda1281dc1961dbe94.manager.bundle.js → 4.6efb4495a449edfbd0b0.manager.bundle.js} +2 -2
  19. package/storybook-static/{4.0fcda1281dc1961dbe94.manager.bundle.js.LICENSE.txt → 4.6efb4495a449edfbd0b0.manager.bundle.js.LICENSE.txt} +0 -0
  20. package/storybook-static/{5.63ab4f94d50a3acf080d.manager.bundle.js → 5.fdf5c7287259585b43a3.manager.bundle.js} +1 -1
  21. package/storybook-static/{6.704d1e8d.iframe.bundle.js → 6.19c48a8c.iframe.bundle.js} +1 -1
  22. package/storybook-static/{6.a6d45262f7e98f3f18d3.manager.bundle.js → 6.8f7b9049856bdace5643.manager.bundle.js} +2 -2
  23. package/storybook-static/{6.a6d45262f7e98f3f18d3.manager.bundle.js.LICENSE.txt → 6.8f7b9049856bdace5643.manager.bundle.js.LICENSE.txt} +0 -0
  24. package/storybook-static/{7.097710753af9a1c41b80.manager.bundle.js → 7.dfc01154563c92ef9ccf.manager.bundle.js} +1 -1
  25. package/storybook-static/{8.76c3cbf398692028e834.manager.bundle.js → 8.c1928a9f13347c159613.manager.bundle.js} +1 -1
  26. package/storybook-static/iframe.html +1 -1
  27. package/storybook-static/index.html +1 -1
  28. package/storybook-static/main.c1b22dad.iframe.bundle.js +1 -0
  29. package/storybook-static/main.d9e1c87c8c22202eed3c.manager.bundle.js +1 -0
  30. package/storybook-static/{runtime~main.c8dac23bc753439736f0.manager.bundle.js → runtime~main.1373976137528887a7ad.manager.bundle.js} +1 -1
  31. package/storybook-static/{runtime~main.f1ebae9b.iframe.bundle.js → runtime~main.2c77505f.iframe.bundle.js} +1 -1
  32. package/storybook-static/vendors~main.41b22d5a0c6132a028f1.manager.bundle.js +2 -0
  33. package/storybook-static/{vendors~main.a697e07137d366f95f76.manager.bundle.js.LICENSE.txt → vendors~main.41b22d5a0c6132a028f1.manager.bundle.js.LICENSE.txt} +0 -0
  34. package/storybook-static/vendors~main.78f2cf4f.iframe.bundle.js +76 -0
  35. package/storybook-static/{vendors~main.b4186832.iframe.bundle.js.LICENSE.txt → vendors~main.78f2cf4f.iframe.bundle.js.LICENSE.txt} +0 -0
  36. package/storybook-static/vendors~main.78f2cf4f.iframe.bundle.js.map +1 -0
  37. package/src/stories/BlocksStories/Account/UserProfile.stories.js +0 -21
  38. package/src/stories/BlocksStories/Account/UserSettings.stories.js +0 -55
  39. package/src/stories/BlocksStories/Auth/NewPassword.stories.js +0 -61
  40. package/src/stories/BlocksStories/Auth/ResetPassword.stories.js +0 -58
  41. package/src/stories/BlocksStories/Auth/SignIn.stories.js +0 -89
  42. package/src/stories/BlocksStories/Auth/SignUp.stories.js +0 -91
  43. package/src/stories/BlocksStories/Payment/ChargeWallet.stories.js +0 -30
  44. package/src/stories/BlocksStories/Payment/PayWithCreditCard.stories.js +0 -37
  45. package/src/stories/BlocksStories/Payment/PayWithWallet.stories.js +0 -17
  46. package/src/stories/BlocksStories/Payment/PaymentSelection.stories.js +0 -60
  47. package/src/stories/BlocksStories/Pricing/BillingPlans.stories.js +0 -63
  48. package/src/stories/BlocksStories/Pricing/LandingPlans.stories.js +0 -63
  49. package/src/stories/ElementsStories/AdaptiveButton.stories.js +0 -51
  50. package/src/stories/ElementsStories/Alert.stories.js +0 -41
  51. package/src/stories/ElementsStories/InputLabel.stories.js +0 -13
  52. package/src/stories/ElementsStories/ItemCard.stories.js +0 -18
  53. package/src/stories/ElementsStories/LogoButtons.stories.js +0 -73
  54. package/src/stories/ElementsStories/PricingCard.stories.js +0 -91
  55. package/src/stories/ElementsStories/RadioSelector.stories.js +0 -36
  56. package/src/stories/ElementsStories/SettingsRow.stories.js +0 -63
  57. package/src/stories/ElementsStories/TextField.stories.js +0 -49
  58. package/src/stories/Introduction.stories.mdx +0 -229
  59. package/src/stories/LayoutStories/AppBar.stories.js +0 -29
  60. package/src/stories/LayoutStories/AppLayout.stories.js +0 -52
  61. package/src/stories/LayoutStories/Box.stories.js +0 -36
  62. package/storybook-static/main.66955578.iframe.bundle.js +0 -1
  63. package/storybook-static/main.ac6e4b72b033097dad76.manager.bundle.js +0 -1
  64. package/storybook-static/vendors~main.a697e07137d366f95f76.manager.bundle.js +0 -2
  65. package/storybook-static/vendors~main.b4186832.iframe.bundle.js +0 -76
  66. package/storybook-static/vendors~main.b4186832.iframe.bundle.js.map +0 -1
@@ -38,6 +38,7 @@ jobs:
38
38
  else
39
39
  npm install
40
40
  fi
41
+ - run: npm run build-storybook
41
42
  - run: npm run build-lib
42
43
  - run: npm run build:styles
43
44
  - run: npm publish
package/es/index.es.js CHANGED
@@ -1 +1 @@
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 i,Fragment as l}from"react/jsx-runtime";import{Typography as n,Container as o,Button as s}from"@mui/material";import"@mui/icons-material/MoveToInbox";import d from"@mui/material/AppBar";import"@mui/material/Box";import"@mui/material/Toolbar";import"@mui/material/IconButton";import u from"@mui/material/Typography";import"@mui/material/Menu";import"@mui/icons-material/Menu";import m from"@mui/material/Container";import"@mui/material/Avatar";import"@mui/material/MenuItem";import"@mui/material/FormControlLabel";import"@mui/material/Checkbox";import"@mui/icons-material/CheckCircleOutlined";import c from"@mui/material/Input";import p from"@mui/material/InputLabel";import h from"@mui/icons-material/GitHub";import g from"@mui/icons-material/Twitter";import f from"@mui/icons-material/AccountBalanceWallet";import v from"@mui/material/Alert";import x from"@mui/material/AlertTitle";import{useForm as b,FormProvider as y,Controller as w}from"react-hook-form";import T from"@mui/material/InputAdornment";import P from"@mui/icons-material/HttpsOutlined";import S from"@mui/icons-material/MailOutline";import C from"@mui/icons-material/PermIdentityOutlined";import{styled as k}from"@mui/material/styles";import W from"@mui/material/Drawer";import"@mui/material/List";import"@mui/material/Divider";import"@mui/icons-material/ChevronLeft";import"@mui/icons-material/ChevronRight";import"@mui/material/ListItemButton";import"@mui/material/ListItemIcon";import"@mui/material/ListItemText";import"@mui/icons-material/Mail";function A(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 L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach((function(t){q(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function I(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,i,l=[],n=!0,o=!1;try{for(r=r.call(e);!(n=(a=r.next()).done)&&(l.push(a.value),!t||l.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==r.return||r.return()}finally{if(o)throw i}}return l}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return O(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 O(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 O(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;var j=function(e){return a(u,L(L({},e),{},{children:e.children}))},z=function(e){return i(l,{children:[i("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[a(p,{children:e.label}),e.helperText&&a(n,{variant:"validation",children:e.helperText})]}),a(c,L({disableUnderline:!0},e))]})};r.oneOf(["text","number","password"]),r.string;var N=function(e){var r,l="";switch(null===(r=e.logo)||void 0===r?void 0:r.toLowerCase()){case"google":l=a("img",{src:"https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"});break;case"github":l=a(h,{});break;case"twitter":l=a(g,{});break;case"mada":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png",height:20});break;case"stcpay":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png",height:20});break;case"visa/master":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png",height:30});break;case"paypal":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png",height:25});break;case"googlepay":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png",height:20});break;case"applepay":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png",height:40});break;case"wallet":l=a(f,{})}return i(t,L(L({},e),{},{variant:"withLogo",children:[l,a("div",{style:{width:10}}),a(n,{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:e.buttonText})]}))},E=function(e){return i(v,L(L({},e),{},{children:[e.title&&a(x,{children:e.title}),e.text]}))},B=function(e){var r,l,n,o,s=b(),d=s.formState.errors;return a(m,{maxWidth:"sm",children:a(y,L(L({},s),{},{children:i("form",{children:[a(z,{fullWidth:!0,type:"text",name:"fullName",label:"Full Name",placeholder:"Fulan AlFulani",rules:{required:"Email is required"},helperText:null===(r=d.fullName)||void 0===r?void 0:r.message}),a(z,{fullWidth:!0,type:"text",name:"fullName",label:"Phone Number",placeholder:"+966",rules:{required:"Email is required"}}),a(z,{fullWidth:!0,type:"text",name:"email",label:"New Email",placeholder:"Enter your new email",rules:{required:"Email is required"},helperText:null===(l=d.email)||void 0===l?void 0:l.message}),a(z,{fullWidth:!0,type:"password",name:"password",label:"New password",placeholder:"Enter your new password",rules:{required:"Email is required"},helperText:null===(n=d.password)||void 0===n?void 0:n.message}),a(z,{fullWidth:!0,type:"password",name:"confirmPassword",label:"Confirm new password",placeholder:"Confirm new password",rules:{required:"Email is required"},helperText:null===(o=d.confirmPassword)||void 0===o?void 0:o.message}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:"update profile"})," "]})}))})},R=function(e){return i(o,{maxWidth:"sm",children:[e.children,a(s,{type:"submit",fullWidth:!0,variant:"last",children:"Save Settings"})]})},G=function(r){var l=I(e(""),2);l[0],l[1];var n=I(e(""),2);n[0],n[1];var o=I(e(!1),2),s=o[0],d=o[1],u=b(),c=u.formState.errors,p=u.handleSubmit,h=u.control;return i(m,{maxWidth:"xs",variant:"auth",children:[s&&a(E,{text:r.texts.passwordMatchError,severity:"error"}),r.passwordChanged?a(j,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a(y,L(L({},u),{},{children:i("form",{onSubmit:p((function(e){console.log("handling subb",e),e.password===e.confirmPassword?r.handleNewPassword():d(!0)})),children:[a(w,{control:h,name:"password",render:function(e){var t,i,l=e.field;return a(z,L({fullWidth:!0,type:"password",value:null!==(t=l.value)&&void 0!==t?t:"",label:r.texts.passwordLabel,placeholder:r.texts.passwordPlaceholder,helperText:null===(i=c.password)||void 0===i?void 0:i.message,startAdornment:a(T,{position:"start",children:a(P,{})})},l))},rules:{required:r.texts.passwordRequiredText}}),a(w,{control:h,name:"confirmPassword",render:function(e){var t,i,l=e.field;return a(z,L({fullWidth:!0,type:"password",value:null!==(t=l.value)&&void 0!==t?t:"",label:r.texts.confirmPasswordLabel,placeholder:r.texts.confirmPasswordPlaceholder,helperText:null===(i=c.confirmPassword)||void 0===i?void 0:i.message,startAdornment:a(T,{position:"start",children:a(P,{})})},l))},rules:{required:r.texts.confirmPasswordRequiredText}}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:r.texts.updatePassword})]})}))]})},M=function(e){var r,l=b(),n=l.formState.errors,o=l.handleSubmit;l.register;var s=l.control;return i(m,{maxWidth:"xs",variant:"auth",children:[e.error&&i(Alert,{severity:"error",children:[e.errorTitle&&a(AlertTitle,{children:e.errorTitle}),e.errorText]}),e.sent?a(j,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):i("form",{onSubmit:o(e.handleResetPassword),children:[console.log("eror ",null===(r=n.email)||void 0===r?void 0:r.message),a(w,{control:s,name:"email",render:function(t){var r,i,l=t.field;return a(z,L({fullWidth:!0,type:"text",value:null!==(r=l.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=n.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a(T,{position:"start",children:a(S,{})})},l))},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}}}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.resetPassword})]})]})},D=function(e){var r=b(),l=r.formState.errors,n=r.handleSubmit,o=r.control;return i(m,{maxWidth:"xs",variant:"auth",children:[e.error&&i(v,{severity:"error",children:[e.errorTitle&&a(x,{children:e.errorTitle}),e.errorText]}),a(y,L(L({},r),{},{children:i("form",{onSubmit:n(e.handleSignUp),children:[a(w,{control:o,name:"fullName",render:function(t){var r,i,n=t.field;return a(z,{fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.fullNameLabel,placeholder:e.texts.fullNamePlaceholder,helperText:null===(i=l.fullName)||void 0===i?void 0:i.message,startAdornment:a(T,{position:"start",children:a(C,{})})})},rules:{required:e.texts.fullNameRequiredText}}),a(w,{control:o,name:"email",render:function(t){var r,i,n=t.field;return a(z,{fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=l.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a(T,{position:"start",children:a(S,{})})})},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}}}),a(w,{control:o,name:"password",render:function(t){var r,i,n,o=t.field;return a(z,L({fullWidth:!0,type:"password",defaultValue:null!==(r=o.value)&&void 0!==r?r:"",value:null!==(i=o.value)&&void 0!==i?i:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=l.password)||void 0===n?void 0:n.message,startAdornment:a(T,{position:"start",children:a(P,{})})},o))},rules:{required:e.texts.passwordRequiredText}}),a(t,{fullWidth:!0,variant:"last",type:"submit",children:e.texts.signUpText})]})})),i(u,{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})]}),i("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a(N,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignUp}),e.viaGithub&&a(N,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignUp}),e.viaTwitter&&a(N,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignUp})]})]})};D.propTypes={theme:r.oneOf(["secondary","primary"])};var U=function(e){var r=b(),l=r.formState.errors,n=r.handleSubmit;r.register;var o=r.control;return i(m,{maxWidth:"xs",variant:"auth",children:[e.error&&i(v,{severity:"error",children:[e.errorTitle&&a(x,{children:e.errorTitle}),e.errorText]}),i("form",{onSubmit:n(e.handleSignIn),children:[a(w,{control:o,name:"email",render:function(t){var r,i,n=t.field;return a(z,L({fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=l.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a(T,{position:"start",children:a(S,{})})},n))},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}}}),a(w,{control:o,name:"password",render:function(t){var r,i,n,o=t.field;return a(z,L({fullWidth:!0,type:"password",defaultValue:null!==(r=o.value)&&void 0!==r?r:"",value:null!==(i=o.value)&&void 0!==i?i:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=l.password)||void 0===n?void 0:n.message,startAdornment:a(T,{position:"start",children:a(P,{})})},o))},rules:{required:e.texts.passwordRequiredText}}),a(u,{style:{cursor:"pointer",marginTop:5,width:"max-content",fontSize:15,padding:5},onClick:e.handleForgotPassword,children:e.texts.forgotPasswordText}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.signInText})]}),i(u,{variant:"subtitle2",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})]}),i("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a(N,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignIn}),e.viaGithub&&a(N,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignIn}),e.viaTwitter&&a(N,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignIn})]})]})},F=function(e){return i(o,{maxWidth:"xs",children:[a(j,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a(N,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a(N,{logo:"visa/master",buttonText:e.visaMasterLabel,onClick:e.handleCreditCard}),e.viaMada&&a(N,{logo:"mada",buttonText:e.madaLabel,onClick:e.handleMada}),e.viaSTCPay&&a(N,{logo:"stcpay",buttonText:e.stcPayLabel,onClick:e.handleSTCPay}),e.viaPayPal&&a(N,{logo:"paypal",buttonText:e.paypalLabel,onClick:e.handlePayPal}),e.viaGooglePay&&a(N,{logo:"googlepay",buttonText:e.googlePayLabel,onClick:e.handleGooglePay}),e.viaApplePay&&a(N,{logo:"applepay",buttonText:e.applePayLabel,onClick:e.handleApplePay})]})};z.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 Z=function(e){return{width:240,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),overflowX:"hidden"}},$=function(e){return q({transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden",width:"calc(".concat(e.spacing(7)," + 1px)")},e.breakpoints.up("sm"),{width:"calc(".concat(e.spacing(8)," + 1px)")})};k("div")((function(e){var t=e.theme;return L({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:t.spacing(0,1)},t.mixins.toolbar)})),k(d,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return L({zIndex:t.zIndex.drawer+1,transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.leavingScreen})},r&&{marginLeft:240,width:"calc(100% - ".concat(240,"px)"),transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.enteringScreen})})})),k(W,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return L(L({width:240,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box"},r&&L(L({},Z(t)),{},{"& .MuiDrawer-paper":Z(t)})),!r&&L(L({},$(t)),{},{"& .MuiDrawer-paper":$(t)}))}));var V=function(e){var t,r,l=b(),n=l.formState.errors,d=l.handleSubmit;return a(o,{maxWidth:"xs",children:a(y,L(L({},l),{},{children:i("form",{onSubmit:d(e.handle),children:[a(z,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"number",label:"Card Number",rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a(z,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"password",label:"Name On Card",rules:{required:"Password is rquired"},helperText:null===(r=n.password)||void 0===r?void 0:r.message}),a(s,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithCreditCard,children:"Pay with Credit Card"})]})}))})},H=function(r){var l,n=I(e(0),2),o=n[0],s=n[1],d=b(),c=d.formState.errors,p=d.handleSubmit;return i(m,{maxWidth:"xs",children:[i(u,{align:"center",variant:"h1",children:[Number(o).toLocaleString("en")||"0",a(u,{children:r.currency||"SAR"})]}),a(y,L(L({},d),{},{children:i("form",{onChange:function(e){e.preventDefault(),s(d.getValues().amount)},style:{marginTop:10},onSubmit:p(r.handleChargeWallet),children:[a(z,{fullWidth:!0,name:"amount",placeholder:"Enter amount",type:"number",value:o,rules:{required:"Password is rquired"},helperText:null===(l=c.amount)||void 0===l?void 0:l.message}),a(t,{type:"submit",fullWidth:!0,variant:"last",onClick:r.handleSignIn,children:"Charge Wallet"})]})}))]})},X=function(e){return i(o,{maxWidth:"xs",children:[a(n,{align:"center",children:"Wallet Balance"}),i(n,{align:"center",variant:"h1",children:[e.walletBalance||"0",a(n,{children:e.currency||"SAR"})]}),a(s,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithWallet,children:"Pay Now"})]})};export{H as ChargeWalletForm,V as CreditCardForm,G as NewPasswordForm,X as PayWithWallet,M as ResetPasswordForm,F as SelectPayment,U as SignInForm,D as SignUpForm,B as UserProfileForm,R as UserSettingsForm};
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 i,Fragment as l}from"react/jsx-runtime";import{Typography as n,Container as o,Button as s}from"@mui/material";import"@mui/icons-material/MoveToInbox";import d from"@mui/material/AppBar";import"@mui/material/Box";import"@mui/material/Toolbar";import"@mui/material/IconButton";import u from"@mui/material/Typography";import"@mui/material/Menu";import"@mui/icons-material/Menu";import m from"@mui/material/Container";import"@mui/material/Avatar";import"@mui/material/MenuItem";import"@mui/material/FormControlLabel";import"@mui/material/Checkbox";import"@mui/icons-material/CheckCircleOutlined";import c from"@mui/material/Input";import p from"@mui/material/InputLabel";import h from"@mui/icons-material/GitHub";import f from"@mui/icons-material/Twitter";import v from"@mui/icons-material/AccountBalanceWallet";import g from"@mui/material/Alert";import x from"@mui/material/AlertTitle";import"@mui/material/Table";import"@mui/material/TableBody";import"@mui/material/TableCell";import"@mui/material/TableContainer";import"@mui/material/TableHead";import"@mui/material/TableRow";import"@mui/material/Snackbar";import{useForm as b,FormProvider as y,Controller as w}from"react-hook-form";import T from"@mui/material/InputAdornment";import P from"@mui/icons-material/HttpsOutlined";import S from"@mui/icons-material/MailOutline";import C from"@mui/icons-material/PermIdentityOutlined";import{styled as k}from"@mui/material/styles";import W from"@mui/material/Drawer";import"@mui/material/List";import"@mui/material/Divider";import"@mui/icons-material/ChevronLeft";import"@mui/icons-material/ChevronRight";import"@mui/material/ListItemButton";import"@mui/material/ListItemIcon";import"@mui/material/ListItemText";import"@mui/icons-material/Mail";import"@mui/icons-material/Close";function A(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 L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(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,i,l=[],n=!0,o=!1;try{for(r=r.call(e);!(n=(a=r.next()).done)&&(l.push(a.value),!t||l.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==r.return||r.return()}finally{if(o)throw i}}return l}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return q(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 q(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 q(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;var z=function(e){return a(u,L(L({},e),{},{children:e.children}))},R=function(e){return i(l,{children:[i("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[a(p,{children:e.label}),e.helperText&&a(n,{variant:"validation",children:e.helperText})]}),a(c,L({disableUnderline:!0},e))]})};r.oneOf(["text","number","password"]),r.string;var j=function(e){var r,l="";switch(null===(r=e.logo)||void 0===r?void 0:r.toLowerCase()){case"google":l=a("img",{src:"https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"});break;case"github":l=a(h,{});break;case"twitter":l=a(f,{});break;case"mada":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png",height:20});break;case"stcpay":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png",height:20});break;case"visa/master":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png",height:30});break;case"paypal":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png",height:25});break;case"googlepay":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png",height:20});break;case"applepay":l=a("img",{src:"https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png",height:40});break;case"wallet":l=a(v,{})}return i(t,L(L({},e),{},{variant:"withLogo",children:[l,a("div",{style:{width:10}}),a(n,{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:e.buttonText})]}))},B=function(e){return i(g,{severity:e.severity,children:[e.title&&a(x,{children:e.title}),e.text]})},N=function(e){var r=b(),l=r.formState.errors,n=r.handleSubmit,o=r.control;return a(m,{maxWidth:"sm",children:a(y,L(L({},r),{},{children:i("form",{onSubmit:n(e.handleUpdateProfile),children:[a(w,{control:o,name:"fullName",render:function(t){var r,i,n=t.field;return a(R,L({fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.fullNameLabel,placeholder:e.texts.fullNamePlaceholder,helperText:null===(i=l.fullName)||void 0===i?void 0:i.message},n))}}),a(w,{control:o,name:"phoneNumber",render:function(e){var t=e.field;return a(R,L({fullWidth:!0,type:"number",label:"Phone Number",placeholder:"+966"},t))}}),a(w,{control:o,name:"email",render:function(t){var r,i,n=t.field;return a(R,L({fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=l.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder},n))},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}}}),a(w,{control:o,name:"password",render:function(t){var r,i,n=t.field;return a(R,L({fullWidth:!0,type:"password",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(i=l.password)||void 0===i?void 0:i.message},n))},rules:{required:e.texts.passwordRequiredText}}),a(w,{control:o,name:"confirmPassword",render:function(t){var r,i,n=t.field;return a(R,L({fullWidth:!0,type:"password",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.confirmPasswordLabel,placeholder:e.texts.confirmPasswordPlaceholder,helperText:null===(i=l.confirmPassword)||void 0===i?void 0:i.message},n))},rules:{required:e.texts.confirmPasswordRequiredText}}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:"update profile"})," "]})}))})},M=function(e){return i(o,{maxWidth:"sm",children:[e.children,a(s,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handleSaveSettings,children:e.saveSettingsText})]})},G=function(r){var l=O(e(""),2);l[0],l[1];var n=O(e(""),2);n[0],n[1];var o=O(e(!1),2),s=o[0],d=o[1],u=b(),c=u.formState.errors,p=u.handleSubmit,h=u.control;return i(m,{maxWidth:"xs",variant:"auth",children:[s&&a(B,{text:r.texts.passwordMatchError,severity:"error"}),r.passwordChanged?a(z,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a(y,L(L({},u),{},{children:i("form",{onSubmit:p((function(e){console.log("handling subb",e),e.password===e.confirmPassword?r.handleNewPassword():d(!0)})),children:[a(w,{control:h,name:"password",render:function(e){var t,i,l=e.field;return a(R,L({fullWidth:!0,type:"password",value:null!==(t=l.value)&&void 0!==t?t:"",label:r.texts.passwordLabel,placeholder:r.texts.passwordPlaceholder,helperText:null===(i=c.password)||void 0===i?void 0:i.message,startAdornment:a(T,{position:"start",children:a(P,{})})},l))},rules:{required:r.texts.passwordRequiredText}}),a(w,{control:h,name:"confirmPassword",render:function(e){var t,i,l=e.field;return a(R,L({fullWidth:!0,type:"password",value:null!==(t=l.value)&&void 0!==t?t:"",label:r.texts.confirmPasswordLabel,placeholder:r.texts.confirmPasswordPlaceholder,helperText:null===(i=c.confirmPassword)||void 0===i?void 0:i.message,startAdornment:a(T,{position:"start",children:a(P,{})})},l))},rules:{required:r.texts.confirmPasswordRequiredText}}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:r.texts.updatePassword})]})}))]})},U=function(e){var r,l=b(),n=l.formState.errors,o=l.handleSubmit;l.register;var s=l.control;return i(m,{maxWidth:"xs",variant:"auth",children:[e.error&&i(Alert,{severity:"error",children:[e.errorTitle&&a(AlertTitle,{children:e.errorTitle}),e.errorText]}),e.sent?a(z,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):i("form",{onSubmit:o(e.handleResetPassword),children:[console.log("eror ",null===(r=n.email)||void 0===r?void 0:r.message),a(w,{control:s,name:"email",render:function(t){var r,i,l=t.field;return a(R,L({fullWidth:!0,type:"text",value:null!==(r=l.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=n.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a(T,{position:"start",children:a(S,{})})},l))},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}}}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.resetPassword})]})]})},D=function(e){var r=b(),l=r.formState.errors,n=r.handleSubmit,o=r.control;return i(m,{maxWidth:"xs",variant:"auth",style:{direction:"ar"===e.lang?"rtl":"ltr"},children:[e.error&&i(g,{severity:"error",children:[e.errorTitle&&a(x,{children:e.errorTitle}),e.errorText]}),a(y,L(L({},r),{},{children:i("form",{onSubmit:n(e.handleSignUp),children:[a(w,{control:o,name:"fullName",render:function(t){var r,i,n=t.field;return a(R,{fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.fullNameLabel,placeholder:e.texts.fullNamePlaceholder,helperText:null===(i=l.fullName)||void 0===i?void 0:i.message,startAdornment:a(T,{position:"start",children:a(C,{})})})},rules:{required:e.texts.fullNameRequiredText}}),a(w,{control:o,name:"email",render:function(t){var r,i,n=t.field;return a(R,{fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=l.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a(T,{position:"start",children:a(S,{})})})},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}}}),a(w,{control:o,name:"password",render:function(t){var r,i,n,o=t.field;return a(R,L({fullWidth:!0,type:"password",defaultValue:null!==(r=o.value)&&void 0!==r?r:"",value:null!==(i=o.value)&&void 0!==i?i:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=l.password)||void 0===n?void 0:n.message,startAdornment:a(T,{position:"start",children:a(P,{})})},o))},rules:{required:e.texts.passwordRequiredText}}),a(t,{fullWidth:!0,variant:"last",type:"submit",children:e.texts.signUpText})]})})),i(u,{variant:"subtitle2",style:{marginTop:5,textAlign:"center",padding:5},children:[e.texts.existingUserText," ",a("span",{onClick:e.handleRouteToSignIn,style:{cursor:"pointer",color:"blue",textAlign:"center"},children:e.texts.signInText})]}),i("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a(j,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignUp}),e.viaGithub&&a(j,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignUp}),e.viaTwitter&&a(j,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignUp})]})]})};D.propTypes={theme:r.oneOf(["secondary","primary"])};var Z=function(e){var r=b(),l=r.formState.errors,n=r.handleSubmit;r.register;var o=r.control;return i(m,{maxWidth:"xs",variant:"auth",style:{direction:"ar"===e.lang?"rtl":"ltr"},children:[e.error&&i(g,{severity:"error",children:[e.errorTitle&&a(x,{children:e.errorTitle}),e.errorText]}),i("form",{onSubmit:n(e.handleSignIn),children:[a(w,{control:o,name:"email",render:function(t){var r,i,n=t.field;return a(R,L({fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=l.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a(T,{position:"start",children:a(S,{})})},n))},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}}}),a(w,{control:o,name:"password",render:function(t){var r,i,n,o=t.field;return a(R,L({fullWidth:!0,type:"password",defaultValue:null!==(r=o.value)&&void 0!==r?r:"",value:null!==(i=o.value)&&void 0!==i?i:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=l.password)||void 0===n?void 0:n.message,startAdornment:a(T,{position:"start",children:a(P,{})})},o))},rules:{required:e.texts.passwordRequiredText}}),a(u,{style:{cursor:"pointer",marginTop:5,width:"max-content",fontSize:15,padding:5},onClick:e.handleForgotPassword,children:e.texts.forgotPasswordText}),a(t,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.signInText})]}),i(u,{variant:"subtitle2",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})]}),i("div",{style:{display:"flex",flexDirection:"column"},children:[e.viaGoogle&&a(j,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignIn}),e.viaGithub&&a(j,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignIn}),e.viaTwitter&&a(j,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignIn})]})]})},E=function(e){return i(o,{maxWidth:"xs",children:[a(z,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a(j,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a(j,{logo:"visa/master",buttonText:e.visaMasterLabel,onClick:e.handleCreditCard}),e.viaMada&&a(j,{logo:"mada",buttonText:e.madaLabel,onClick:e.handleMada}),e.viaSTCPay&&a(j,{logo:"stcpay",buttonText:e.stcPayLabel,onClick:e.handleSTCPay}),e.viaPayPal&&a(j,{logo:"paypal",buttonText:e.paypalLabel,onClick:e.handlePayPal}),e.viaGooglePay&&a(j,{logo:"googlepay",buttonText:e.googlePayLabel,onClick:e.handleGooglePay}),e.viaApplePay&&a(j,{logo:"applepay",buttonText:e.applePayLabel,onClick:e.handleApplePay})]})};R.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){return{width:240,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),overflowX:"hidden"}},$=function(e){return I({transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden",width:"calc(".concat(e.spacing(7)," + 1px)")},e.breakpoints.up("sm"),{width:"calc(".concat(e.spacing(8)," + 1px)")})};k("div")((function(e){var t=e.theme;return L({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:t.spacing(0,1)},t.mixins.toolbar)})),k(d,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return L({zIndex:t.zIndex.drawer+1,transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.leavingScreen})},r&&{marginLeft:240,width:"calc(100% - ".concat(240,"px)"),transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.enteringScreen})})})),k(W,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return L(L({width:240,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box"},r&&L(L({},F(t)),{},{"& .MuiDrawer-paper":F(t)})),!r&&L(L({},$(t)),{},{"& .MuiDrawer-paper":$(t)}))}));var H=function(e){var t,r,l=b(),n=l.formState.errors,d=l.handleSubmit;return a(o,{maxWidth:"xs",children:a(y,L(L({},l),{},{children:i("form",{onSubmit:d(e.handle),children:[a(R,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"number",label:"Card Number",rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a(R,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"password",label:"Name On Card",rules:{required:"Password is rquired"},helperText:null===(r=n.password)||void 0===r?void 0:r.message}),a(s,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithCreditCard,children:"Pay with Credit Card"})]})}))})},V=function(r){var l=O(e(0),2),n=l[0],o=l[1],s=b();s.formState.errors;var d=s.handleSubmit,c=s.control;return i(m,{maxWidth:"xs",children:[i(u,{align:"center",variant:"h2",fontWeight:500,children:[Number(n).toLocaleString("en")||"0",a(u,{children:r.currency||"SAR"})]}),a(y,L(L({},s),{},{children:i("form",{onSubmit:d(r.handleChargeWallet),children:[a(w,{control:c,name:"amount",render:function(e){var t,r=e.field;return a(R,L(L({fullWidth:!0,placeholder:"Enter amount",type:"number",value:null!==(t=r.value)&&void 0!==t?t:""},r),{},{inputProps:{inputMode:"numeric",min:"0",max:"9999999",step:"0.01"},onChange:function(e){r.onChange(parseFloat(e.target.value)),console.log("e",e.target.value),o(e.target.value)}}))}}),a(t,{type:"submit",fullWidth:!0,variant:"last",onClick:r.handleSignIn,children:"Charge Wallet"})]})}))]})},X=function(e){return i(o,{maxWidth:"xs",children:[a(n,{align:"center",children:"Wallet Balance"}),i(n,{align:"center",variant:"h1",children:[e.walletBalance||"0",a(n,{children:e.currency||"SAR"})]}),a(s,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithWallet,children:"Pay Now"})]})};export{V as ChargeWalletForm,H as CreditCardForm,G as NewPasswordForm,X as PayWithWallet,U as ResetPasswordForm,E as SelectPayment,Z as SignInForm,D as SignUpForm,N as UserProfileForm,M as UserSettingsForm};
package/lib/index.js CHANGED
@@ -1 +1 @@
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"),i=require("@mui/material");require("@mui/icons-material/MoveToInbox");var l=require("@mui/material/AppBar");require("@mui/material/Box"),require("@mui/material/Toolbar"),require("@mui/material/IconButton");var n=require("@mui/material/Typography");require("@mui/material/Menu"),require("@mui/icons-material/Menu");var s=require("@mui/material/Container");require("@mui/material/Avatar"),require("@mui/material/MenuItem"),require("@mui/material/FormControlLabel"),require("@mui/material/Checkbox"),require("@mui/icons-material/CheckCircleOutlined");var o=require("@mui/material/Input"),u=require("@mui/material/InputLabel"),d=require("@mui/icons-material/GitHub"),m=require("@mui/icons-material/Twitter"),c=require("@mui/icons-material/AccountBalanceWallet"),p=require("@mui/material/Alert"),x=require("@mui/material/AlertTitle"),h=require("react-hook-form"),f=require("@mui/material/InputAdornment"),g=require("@mui/icons-material/HttpsOutlined"),v=require("@mui/icons-material/MailOutline"),b=require("@mui/icons-material/PermIdentityOutlined"),y=require("@mui/material/styles"),j=require("@mui/material/Drawer");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@mui/material/List"),require("@mui/material/Divider"),require("@mui/icons-material/ChevronLeft"),require("@mui/icons-material/ChevronRight"),require("@mui/material/ListItemButton"),require("@mui/material/ListItemIcon"),require("@mui/material/ListItemText"),require("@mui/icons-material/Mail");var T=w(t),q=w(r),P=w(l),C=w(n),S=w(s),k=w(o),W=w(u),A=w(d),L=w(m),I=w(c),F=w(p),O=w(x),N=w(f),z=w(g),B=w(v),E=w(b),R=w(j);function M(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 G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D(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,i,l=[],n=!0,s=!1;try{for(r=r.call(e);!(n=(a=r.next()).done)&&(l.push(a.value),!t||l.length!==t);n=!0);}catch(e){s=!0,i=e}finally{try{n||null==r.return||r.return()}finally{if(s)throw i}}return l}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Z(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 Z(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 Z(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}q.default.string,q.default.bool;var $=function(e){return a.jsx(C.default,G(G({},e),{},{children:e.children}))},_=function(e){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[a.jsx(W.default,{children:e.label}),e.helperText&&a.jsx(i.Typography,{variant:"validation",children:e.helperText})]}),a.jsx(k.default,G({disableUnderline:!0},e))]})};q.default.oneOf(["text","number","password"]),q.default.string;var V=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(A.default,{});break;case"twitter":r=a.jsx(L.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(I.default,{})}return a.jsxs(T.default,G(G({},e),{},{variant:"withLogo",children:[r,a.jsx("div",{style:{width:10}}),a.jsx(i.Typography,{style:{color:"black",fontSize:14,textAlign:"center",letterSpacing:.4,fontFamily:"Roboto",fontWeight:500},children:e.buttonText})]}))},H=function(e){return a.jsxs(F.default,G(G({},e),{},{children:[e.title&&a.jsx(O.default,{children:e.title}),e.text]}))},X=function(e){var t=h.useForm(),r=t.formState.errors,i=t.handleSubmit,l=t.control;return a.jsxs(S.default,{maxWidth:"xs",variant:"auth",children:[e.error&&a.jsxs(F.default,{severity:"error",children:[e.errorTitle&&a.jsx(O.default,{children:e.errorTitle}),e.errorText]}),a.jsx(h.FormProvider,G(G({},t),{},{children:a.jsxs("form",{onSubmit:i(e.handleSignUp),children:[a.jsx(h.Controller,{control:l,name:"fullName",render:function(t){var i,l,n=t.field;return a.jsx(_,{fullWidth:!0,type:"text",value:null!==(i=n.value)&&void 0!==i?i:"",label:e.texts.fullNameLabel,placeholder:e.texts.fullNamePlaceholder,helperText:null===(l=r.fullName)||void 0===l?void 0:l.message,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(E.default,{})})})},rules:{required:e.texts.fullNameRequiredText}}),a.jsx(h.Controller,{control:l,name:"email",render:function(t){var i,l,n=t.field;return a.jsx(_,{fullWidth:!0,type:"text",value:null!==(i=n.value)&&void 0!==i?i:"",label:e.texts.emailLabel,helperText:null===(l=r.email)||void 0===l?void 0:l.message,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(B.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}}}),a.jsx(h.Controller,{control:l,name:"password",render:function(t){var i,l,n,s=t.field;return a.jsx(_,G({fullWidth:!0,type:"password",defaultValue:null!==(i=s.value)&&void 0!==i?i:"",value:null!==(l=s.value)&&void 0!==l?l:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=r.password)||void 0===n?void 0:n.message,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(z.default,{})})},s))},rules:{required:e.texts.passwordRequiredText}}),a.jsx(T.default,{fullWidth:!0,variant:"last",type:"submit",children:e.texts.signUpText})]})})),a.jsxs(C.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(V,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignUp}),e.viaGithub&&a.jsx(V,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignUp}),e.viaTwitter&&a.jsx(V,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignUp})]})]})};X.propTypes={theme:q.default.oneOf(["secondary","primary"])};_.propTypes={theme:q.default.oneOf(["secondary","primary"]),viaApplePay:q.default.bool,viaGooglePay:q.default.bool,viaSTCPay:q.default.bool,viaCreditCard:q.default.bool,viaPayPal:q.default.bool,handleApplePay:q.default.func};var Y=function(e){return{width:240,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),overflowX:"hidden"}},J=function(e){return U({transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden",width:"calc(".concat(e.spacing(7)," + 1px)")},e.breakpoints.up("sm"),{width:"calc(".concat(e.spacing(8)," + 1px)")})};y.styled("div")((function(e){var t=e.theme;return G({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:t.spacing(0,1)},t.mixins.toolbar)})),y.styled(P.default,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return G({zIndex:t.zIndex.drawer+1,transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.leavingScreen})},r&&{marginLeft:240,width:"calc(100% - ".concat(240,"px)"),transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.enteringScreen})})})),y.styled(R.default,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return G(G({width:240,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box"},r&&G(G({},Y(t)),{},{"& .MuiDrawer-paper":Y(t)})),!r&&G(G({},J(t)),{},{"& .MuiDrawer-paper":J(t)}))}));exports.ChargeWalletForm=function(t){var r,i=D(e.useState(0),2),l=i[0],n=i[1],s=h.useForm(),o=s.formState.errors,u=s.handleSubmit;return a.jsxs(S.default,{maxWidth:"xs",children:[a.jsxs(C.default,{align:"center",variant:"h1",children:[Number(l).toLocaleString("en")||"0",a.jsx(C.default,{children:t.currency||"SAR"})]}),a.jsx(h.FormProvider,G(G({},s),{},{children:a.jsxs("form",{onChange:function(e){e.preventDefault(),n(s.getValues().amount)},style:{marginTop:10},onSubmit:u(t.handleChargeWallet),children:[a.jsx(_,{fullWidth:!0,name:"amount",placeholder:"Enter amount",type:"number",value:l,rules:{required:"Password is rquired"},helperText:null===(r=o.amount)||void 0===r?void 0:r.message}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",onClick:t.handleSignIn,children:"Charge Wallet"})]})}))]})},exports.CreditCardForm=function(e){var t,r,l=h.useForm(),n=l.formState.errors,s=l.handleSubmit;return a.jsx(i.Container,{maxWidth:"xs",children:a.jsx(h.FormProvider,G(G({},l),{},{children:a.jsxs("form",{onSubmit:s(e.handle),children:[a.jsx(_,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"number",label:"Card Number",rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a.jsx(_,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"password",label:"Name On Card",rules:{required:"Password is rquired"},helperText:null===(r=n.password)||void 0===r?void 0:r.message}),a.jsx(i.Button,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithCreditCard,children:"Pay with Credit Card"})]})}))})},exports.NewPasswordForm=function(t){var r=D(e.useState(""),2);r[0],r[1];var i=D(e.useState(""),2);i[0],i[1];var l=D(e.useState(!1),2),n=l[0],s=l[1],o=h.useForm(),u=o.formState.errors,d=o.handleSubmit,m=o.control;return a.jsxs(S.default,{maxWidth:"xs",variant:"auth",children:[n&&a.jsx(H,{text:t.texts.passwordMatchError,severity:"error"}),t.passwordChanged?a.jsx($,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a.jsx(h.FormProvider,G(G({},o),{},{children:a.jsxs("form",{onSubmit:d((function(e){console.log("handling subb",e),e.password===e.confirmPassword?t.handleNewPassword():s(!0)})),children:[a.jsx(h.Controller,{control:m,name:"password",render:function(e){var r,i,l=e.field;return a.jsx(_,G({fullWidth:!0,type:"password",value:null!==(r=l.value)&&void 0!==r?r:"",label:t.texts.passwordLabel,placeholder:t.texts.passwordPlaceholder,helperText:null===(i=u.password)||void 0===i?void 0:i.message,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(z.default,{})})},l))},rules:{required:t.texts.passwordRequiredText}}),a.jsx(h.Controller,{control:m,name:"confirmPassword",render:function(e){var r,i,l=e.field;return a.jsx(_,G({fullWidth:!0,type:"password",value:null!==(r=l.value)&&void 0!==r?r:"",label:t.texts.confirmPasswordLabel,placeholder:t.texts.confirmPasswordPlaceholder,helperText:null===(i=u.confirmPassword)||void 0===i?void 0:i.message,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(z.default,{})})},l))},rules:{required:t.texts.confirmPasswordRequiredText}}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:t.texts.updatePassword})]})}))]})},exports.PayWithWallet=function(e){return a.jsxs(i.Container,{maxWidth:"xs",children:[a.jsx(i.Typography,{align:"center",children:"Wallet Balance"}),a.jsxs(i.Typography,{align:"center",variant:"h1",children:[e.walletBalance||"0",a.jsx(i.Typography,{children:e.currency||"SAR"})]}),a.jsx(i.Button,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithWallet,children:"Pay Now"})]})},exports.ResetPasswordForm=function(e){var t,r=h.useForm(),i=r.formState.errors,l=r.handleSubmit;r.register;var n=r.control;return a.jsxs(S.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($,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):a.jsxs("form",{onSubmit:l(e.handleResetPassword),children:[console.log("eror ",null===(t=i.email)||void 0===t?void 0:t.message),a.jsx(h.Controller,{control:n,name:"email",render:function(t){var r,l,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(l=i.email)||void 0===l?void 0:l.message,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(B.default,{})})},n))},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}}}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.resetPassword})]})]})},exports.SelectPayment=function(e){return a.jsxs(i.Container,{maxWidth:"xs",children:[a.jsx($,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a.jsx(V,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a.jsx(V,{logo:"visa/master",buttonText:e.visaMasterLabel,onClick:e.handleCreditCard}),e.viaMada&&a.jsx(V,{logo:"mada",buttonText:e.madaLabel,onClick:e.handleMada}),e.viaSTCPay&&a.jsx(V,{logo:"stcpay",buttonText:e.stcPayLabel,onClick:e.handleSTCPay}),e.viaPayPal&&a.jsx(V,{logo:"paypal",buttonText:e.paypalLabel,onClick:e.handlePayPal}),e.viaGooglePay&&a.jsx(V,{logo:"googlepay",buttonText:e.googlePayLabel,onClick:e.handleGooglePay}),e.viaApplePay&&a.jsx(V,{logo:"applepay",buttonText:e.applePayLabel,onClick:e.handleApplePay})]})},exports.SignInForm=function(e){var t=h.useForm(),r=t.formState.errors,i=t.handleSubmit;t.register;var l=t.control;return a.jsxs(S.default,{maxWidth:"xs",variant:"auth",children:[e.error&&a.jsxs(F.default,{severity:"error",children:[e.errorTitle&&a.jsx(O.default,{children:e.errorTitle}),e.errorText]}),a.jsxs("form",{onSubmit:i(e.handleSignIn),children:[a.jsx(h.Controller,{control:l,name:"email",render:function(t){var i,l,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"text",value:null!==(i=n.value)&&void 0!==i?i:"",label:e.texts.emailLabel,helperText:null===(l=r.email)||void 0===l?void 0:l.message,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(B.default,{})})},n))},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}}}),a.jsx(h.Controller,{control:l,name:"password",render:function(t){var i,l,n,s=t.field;return a.jsx(_,G({fullWidth:!0,type:"password",defaultValue:null!==(i=s.value)&&void 0!==i?i:"",value:null!==(l=s.value)&&void 0!==l?l:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=r.password)||void 0===n?void 0:n.message,startAdornment:a.jsx(N.default,{position:"start",children:a.jsx(z.default,{})})},s))},rules:{required:e.texts.passwordRequiredText}}),a.jsx(C.default,{style:{cursor:"pointer",marginTop:5,width:"max-content",fontSize:15,padding:5},onClick:e.handleForgotPassword,children:e.texts.forgotPasswordText}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.signInText})]}),a.jsxs(C.default,{variant:"subtitle2",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(V,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignIn}),e.viaGithub&&a.jsx(V,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignIn}),e.viaTwitter&&a.jsx(V,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignIn})]})]})},exports.SignUpForm=X,exports.UserProfileForm=function(e){var t,r,i,l,n=h.useForm(),s=n.formState.errors;return a.jsx(S.default,{maxWidth:"sm",children:a.jsx(h.FormProvider,G(G({},n),{},{children:a.jsxs("form",{children:[a.jsx(_,{fullWidth:!0,type:"text",name:"fullName",label:"Full Name",placeholder:"Fulan AlFulani",rules:{required:"Email is required"},helperText:null===(t=s.fullName)||void 0===t?void 0:t.message}),a.jsx(_,{fullWidth:!0,type:"text",name:"fullName",label:"Phone Number",placeholder:"+966",rules:{required:"Email is required"}}),a.jsx(_,{fullWidth:!0,type:"text",name:"email",label:"New Email",placeholder:"Enter your new email",rules:{required:"Email is required"},helperText:null===(r=s.email)||void 0===r?void 0:r.message}),a.jsx(_,{fullWidth:!0,type:"password",name:"password",label:"New password",placeholder:"Enter your new password",rules:{required:"Email is required"},helperText:null===(i=s.password)||void 0===i?void 0:i.message}),a.jsx(_,{fullWidth:!0,type:"password",name:"confirmPassword",label:"Confirm new password",placeholder:"Confirm new password",rules:{required:"Email is required"},helperText:null===(l=s.confirmPassword)||void 0===l?void 0:l.message}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:"update profile"})," "]})}))})},exports.UserSettingsForm=function(e){return a.jsxs(i.Container,{maxWidth:"sm",children:[e.children,a.jsx(i.Button,{type:"submit",fullWidth:!0,variant:"last",children:"Save Settings"})]})};
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"),l=require("@mui/material");require("@mui/icons-material/MoveToInbox");var i=require("@mui/material/AppBar");require("@mui/material/Box"),require("@mui/material/Toolbar"),require("@mui/material/IconButton");var n=require("@mui/material/Typography");require("@mui/material/Menu"),require("@mui/icons-material/Menu");var o=require("@mui/material/Container");require("@mui/material/Avatar"),require("@mui/material/MenuItem"),require("@mui/material/FormControlLabel"),require("@mui/material/Checkbox"),require("@mui/icons-material/CheckCircleOutlined");var s=require("@mui/material/Input"),u=require("@mui/material/InputLabel"),d=require("@mui/icons-material/GitHub"),c=require("@mui/icons-material/Twitter"),m=require("@mui/icons-material/AccountBalanceWallet"),x=require("@mui/material/Alert"),h=require("@mui/material/AlertTitle");require("@mui/material/Table"),require("@mui/material/TableBody"),require("@mui/material/TableCell"),require("@mui/material/TableContainer"),require("@mui/material/TableHead"),require("@mui/material/TableRow"),require("@mui/material/Snackbar");var p=require("react-hook-form"),f=require("@mui/material/InputAdornment"),v=require("@mui/icons-material/HttpsOutlined"),g=require("@mui/icons-material/MailOutline"),b=require("@mui/icons-material/PermIdentityOutlined"),y=require("@mui/material/styles"),j=require("@mui/material/Drawer");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@mui/material/List"),require("@mui/material/Divider"),require("@mui/icons-material/ChevronLeft"),require("@mui/icons-material/ChevronRight"),require("@mui/material/ListItemButton"),require("@mui/material/ListItemIcon"),require("@mui/material/ListItemText"),require("@mui/icons-material/Mail"),require("@mui/icons-material/Close");var T=w(t),P=w(r),q=w(i),C=w(n),S=w(o),k=w(s),W=w(u),A=w(d),L=w(c),I=w(m),O=w(x),F=w(h),R=w(f),z=w(v),B=w(g),N=w(b),M=w(j);function U(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 G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?U(Object(r),!0).forEach((function(t){D(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Z(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 E(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 E(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 E(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}P.default.string,P.default.bool;var $=function(e){return a.jsx(C.default,G(G({},e),{},{children:e.children}))},_=function(e){return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[a.jsx(W.default,{children:e.label}),e.helperText&&a.jsx(l.Typography,{variant:"validation",children:e.helperText})]}),a.jsx(k.default,G({disableUnderline:!0},e))]})};P.default.oneOf(["text","number","password"]),P.default.string;var H=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(A.default,{});break;case"twitter":r=a.jsx(L.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(I.default,{})}return a.jsxs(T.default,G(G({},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})]}))},V=function(e){return a.jsxs(O.default,{severity:e.severity,children:[e.title&&a.jsx(F.default,{children:e.title}),e.text]})},X=function(e){var t=p.useForm(),r=t.formState.errors,l=t.handleSubmit,i=t.control;return a.jsxs(S.default,{maxWidth:"xs",variant:"auth",style:{direction:"ar"===e.lang?"rtl":"ltr"},children:[e.error&&a.jsxs(O.default,{severity:"error",children:[e.errorTitle&&a.jsx(F.default,{children:e.errorTitle}),e.errorText]}),a.jsx(p.FormProvider,G(G({},t),{},{children:a.jsxs("form",{onSubmit:l(e.handleSignUp),children:[a.jsx(p.Controller,{control:i,name:"fullName",render:function(t){var l,i,n=t.field;return a.jsx(_,{fullWidth:!0,type:"text",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.fullNameLabel,placeholder:e.texts.fullNamePlaceholder,helperText:null===(i=r.fullName)||void 0===i?void 0:i.message,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(N.default,{})})})},rules:{required:e.texts.fullNameRequiredText}}),a.jsx(p.Controller,{control:i,name:"email",render:function(t){var l,i,n=t.field;return a.jsx(_,{fullWidth:!0,type:"text",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.emailLabel,helperText:null===(i=r.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(B.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}}}),a.jsx(p.Controller,{control:i,name:"password",render:function(t){var l,i,n,o=t.field;return a.jsx(_,G({fullWidth:!0,type:"password",defaultValue:null!==(l=o.value)&&void 0!==l?l:"",value:null!==(i=o.value)&&void 0!==i?i:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=r.password)||void 0===n?void 0:n.message,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(z.default,{})})},o))},rules:{required:e.texts.passwordRequiredText}}),a.jsx(T.default,{fullWidth:!0,variant:"last",type:"submit",children:e.texts.signUpText})]})})),a.jsxs(C.default,{variant:"subtitle2",style:{marginTop:5,textAlign:"center",padding:5},children:[e.texts.existingUserText," ",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(H,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignUp}),e.viaGithub&&a.jsx(H,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignUp}),e.viaTwitter&&a.jsx(H,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignUp})]})]})};X.propTypes={theme:P.default.oneOf(["secondary","primary"])};_.propTypes={theme:P.default.oneOf(["secondary","primary"]),viaApplePay:P.default.bool,viaGooglePay:P.default.bool,viaSTCPay:P.default.bool,viaCreditCard:P.default.bool,viaPayPal:P.default.bool,handleApplePay:P.default.func};var Y=function(e){return{width:240,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),overflowX:"hidden"}},J=function(e){return D({transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden",width:"calc(".concat(e.spacing(7)," + 1px)")},e.breakpoints.up("sm"),{width:"calc(".concat(e.spacing(8)," + 1px)")})};y.styled("div")((function(e){var t=e.theme;return G({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:t.spacing(0,1)},t.mixins.toolbar)})),y.styled(q.default,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return G({zIndex:t.zIndex.drawer+1,transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.leavingScreen})},r&&{marginLeft:240,width:"calc(100% - ".concat(240,"px)"),transition:t.transitions.create(["width","margin"],{easing:t.transitions.easing.sharp,duration:t.transitions.duration.enteringScreen})})})),y.styled(M.default,{shouldForwardProp:function(e){return"open"!==e}})((function(e){var t=e.theme,r=e.open;return G(G({width:240,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box"},r&&G(G({},Y(t)),{},{"& .MuiDrawer-paper":Y(t)})),!r&&G(G({},J(t)),{},{"& .MuiDrawer-paper":J(t)}))}));exports.ChargeWalletForm=function(t){var r=Z(e.useState(0),2),l=r[0],i=r[1],n=p.useForm();n.formState.errors;var o=n.handleSubmit,s=n.control;return a.jsxs(S.default,{maxWidth:"xs",children:[a.jsxs(C.default,{align:"center",variant:"h2",fontWeight:500,children:[Number(l).toLocaleString("en")||"0",a.jsx(C.default,{children:t.currency||"SAR"})]}),a.jsx(p.FormProvider,G(G({},n),{},{children:a.jsxs("form",{onSubmit:o(t.handleChargeWallet),children:[a.jsx(p.Controller,{control:s,name:"amount",render:function(e){var t,r=e.field;return a.jsx(_,G(G({fullWidth:!0,placeholder:"Enter amount",type:"number",value:null!==(t=r.value)&&void 0!==t?t:""},r),{},{inputProps:{inputMode:"numeric",min:"0",max:"9999999",step:"0.01"},onChange:function(e){r.onChange(parseFloat(e.target.value)),console.log("e",e.target.value),i(e.target.value)}}))}}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",onClick:t.handleSignIn,children:"Charge Wallet"})]})}))]})},exports.CreditCardForm=function(e){var t,r,i=p.useForm(),n=i.formState.errors,o=i.handleSubmit;return a.jsx(l.Container,{maxWidth:"xs",children:a.jsx(p.FormProvider,G(G({},i),{},{children:a.jsxs("form",{onSubmit:o(e.handle),children:[a.jsx(_,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"number",label:"Card Number",rules:{required:"Password is rquired"},helperText:null===(t=n.password)||void 0===t?void 0:t.message}),a.jsx(_,{fullWidth:!0,name:"password",placeholder:"Enter password",type:"password",label:"Name On Card",rules:{required:"Password is rquired"},helperText:null===(r=n.password)||void 0===r?void 0:r.message}),a.jsx(l.Button,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithCreditCard,children:"Pay with Credit Card"})]})}))})},exports.NewPasswordForm=function(t){var r=Z(e.useState(""),2);r[0],r[1];var l=Z(e.useState(""),2);l[0],l[1];var i=Z(e.useState(!1),2),n=i[0],o=i[1],s=p.useForm(),u=s.formState.errors,d=s.handleSubmit,c=s.control;return a.jsxs(S.default,{maxWidth:"xs",variant:"auth",children:[n&&a.jsx(V,{text:t.texts.passwordMatchError,severity:"error"}),t.passwordChanged?a.jsx($,{style:{textAlign:"center",margin:5},children:"Your password has been changed, you'll be redirected to sign in page"}):a.jsx(p.FormProvider,G(G({},s),{},{children:a.jsxs("form",{onSubmit:d((function(e){console.log("handling subb",e),e.password===e.confirmPassword?t.handleNewPassword():o(!0)})),children:[a.jsx(p.Controller,{control:c,name:"password",render:function(e){var r,l,i=e.field;return a.jsx(_,G({fullWidth:!0,type:"password",value:null!==(r=i.value)&&void 0!==r?r:"",label:t.texts.passwordLabel,placeholder:t.texts.passwordPlaceholder,helperText:null===(l=u.password)||void 0===l?void 0:l.message,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(z.default,{})})},i))},rules:{required:t.texts.passwordRequiredText}}),a.jsx(p.Controller,{control:c,name:"confirmPassword",render:function(e){var r,l,i=e.field;return a.jsx(_,G({fullWidth:!0,type:"password",value:null!==(r=i.value)&&void 0!==r?r:"",label:t.texts.confirmPasswordLabel,placeholder:t.texts.confirmPasswordPlaceholder,helperText:null===(l=u.confirmPassword)||void 0===l?void 0:l.message,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(z.default,{})})},i))},rules:{required:t.texts.confirmPasswordRequiredText}}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:t.texts.updatePassword})]})}))]})},exports.PayWithWallet=function(e){return a.jsxs(l.Container,{maxWidth:"xs",children:[a.jsx(l.Typography,{align:"center",children:"Wallet Balance"}),a.jsxs(l.Typography,{align:"center",variant:"h1",children:[e.walletBalance||"0",a.jsx(l.Typography,{children:e.currency||"SAR"})]}),a.jsx(l.Button,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handlePayWithWallet,children:"Pay Now"})]})},exports.ResetPasswordForm=function(e){var t,r=p.useForm(),l=r.formState.errors,i=r.handleSubmit;r.register;var n=r.control;return a.jsxs(S.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($,{style:{textAlign:"center",margin:5},children:"An link was sent to your email to reset the password."}):a.jsxs("form",{onSubmit:i(e.handleResetPassword),children:[console.log("eror ",null===(t=l.email)||void 0===t?void 0:t.message),a.jsx(p.Controller,{control:n,name:"email",render:function(t){var r,i,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"text",value:null!==(r=n.value)&&void 0!==r?r:"",label:e.texts.emailLabel,helperText:null===(i=l.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(B.default,{})})},n))},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}}}),a.jsx(T.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($,{align:"center",children:"Choose Payment Method"}),e.viaWallet&&a.jsx(H,{logo:"wallet",buttonText:e.walletLabel,onClick:e.handleWallet}),e.viaCreditCard&&a.jsx(H,{logo:"visa/master",buttonText:e.visaMasterLabel,onClick:e.handleCreditCard}),e.viaMada&&a.jsx(H,{logo:"mada",buttonText:e.madaLabel,onClick:e.handleMada}),e.viaSTCPay&&a.jsx(H,{logo:"stcpay",buttonText:e.stcPayLabel,onClick:e.handleSTCPay}),e.viaPayPal&&a.jsx(H,{logo:"paypal",buttonText:e.paypalLabel,onClick:e.handlePayPal}),e.viaGooglePay&&a.jsx(H,{logo:"googlepay",buttonText:e.googlePayLabel,onClick:e.handleGooglePay}),e.viaApplePay&&a.jsx(H,{logo:"applepay",buttonText:e.applePayLabel,onClick:e.handleApplePay})]})},exports.SignInForm=function(e){var t=p.useForm(),r=t.formState.errors,l=t.handleSubmit;t.register;var i=t.control;return a.jsxs(S.default,{maxWidth:"xs",variant:"auth",style:{direction:"ar"===e.lang?"rtl":"ltr"},children:[e.error&&a.jsxs(O.default,{severity:"error",children:[e.errorTitle&&a.jsx(F.default,{children:e.errorTitle}),e.errorText]}),a.jsxs("form",{onSubmit:l(e.handleSignIn),children:[a.jsx(p.Controller,{control:i,name:"email",render:function(t){var l,i,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"text",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.emailLabel,helperText:null===(i=r.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(B.default,{})})},n))},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}}}),a.jsx(p.Controller,{control:i,name:"password",render:function(t){var l,i,n,o=t.field;return a.jsx(_,G({fullWidth:!0,type:"password",defaultValue:null!==(l=o.value)&&void 0!==l?l:"",value:null!==(i=o.value)&&void 0!==i?i:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(n=r.password)||void 0===n?void 0:n.message,startAdornment:a.jsx(R.default,{position:"start",children:a.jsx(z.default,{})})},o))},rules:{required:e.texts.passwordRequiredText}}),a.jsx(C.default,{style:{cursor:"pointer",marginTop:5,width:"max-content",fontSize:15,padding:5},onClick:e.handleForgotPassword,children:e.texts.forgotPasswordText}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:e.texts.signInText})]}),a.jsxs(C.default,{variant:"subtitle2",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(H,{logo:"google",buttonText:e.texts.googleButtonLabel,onClick:e.handleGoogleSignIn}),e.viaGithub&&a.jsx(H,{logo:"github",buttonText:e.texts.githubButtonLabel,onClick:e.handleGithubSignIn}),e.viaTwitter&&a.jsx(H,{logo:"twitter",buttonText:e.texts.twitterButtonLabel,onClick:e.handleTwitterSignIn})]})]})},exports.SignUpForm=X,exports.UserProfileForm=function(e){var t=p.useForm(),r=t.formState.errors,l=t.handleSubmit,i=t.control;return a.jsx(S.default,{maxWidth:"sm",children:a.jsx(p.FormProvider,G(G({},t),{},{children:a.jsxs("form",{onSubmit:l(e.handleUpdateProfile),children:[a.jsx(p.Controller,{control:i,name:"fullName",render:function(t){var l,i,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"text",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.fullNameLabel,placeholder:e.texts.fullNamePlaceholder,helperText:null===(i=r.fullName)||void 0===i?void 0:i.message},n))}}),a.jsx(p.Controller,{control:i,name:"phoneNumber",render:function(e){var t=e.field;return a.jsx(_,G({fullWidth:!0,type:"number",label:"Phone Number",placeholder:"+966"},t))}}),a.jsx(p.Controller,{control:i,name:"email",render:function(t){var l,i,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"text",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.emailLabel,helperText:null===(i=r.email)||void 0===i?void 0:i.message,placeholder:e.texts.emailPlaceholder},n))},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}}}),a.jsx(p.Controller,{control:i,name:"password",render:function(t){var l,i,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"password",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.passwordLabel,placeholder:e.texts.passwordPlaceholder,helperText:null===(i=r.password)||void 0===i?void 0:i.message},n))},rules:{required:e.texts.passwordRequiredText}}),a.jsx(p.Controller,{control:i,name:"confirmPassword",render:function(t){var l,i,n=t.field;return a.jsx(_,G({fullWidth:!0,type:"password",value:null!==(l=n.value)&&void 0!==l?l:"",label:e.texts.confirmPasswordLabel,placeholder:e.texts.confirmPasswordPlaceholder,helperText:null===(i=r.confirmPassword)||void 0===i?void 0:i.message},n))},rules:{required:e.texts.confirmPasswordRequiredText}}),a.jsx(T.default,{type:"submit",fullWidth:!0,variant:"last",children:"update profile"})," "]})}))})},exports.UserSettingsForm=function(e){return a.jsxs(l.Container,{maxWidth:"sm",children:[e.children,a.jsx(l.Button,{type:"submit",fullWidth:!0,variant:"last",onClick:e.handleSaveSettings,children:e.saveSettingsText})]})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.15",
3
+ "version": "0.0.18",
4
4
  "description": "UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -1,73 +1,109 @@
1
1
  import React from "react";
2
2
  import { HawaTextField } from "../../elements";
3
- import { FormProvider, useForm } from "react-hook-form";
3
+ import { Controller, FormProvider, useForm } from "react-hook-form";
4
4
  import Container from "@mui/material/Container";
5
5
  import Button from "@mui/material/Button";
6
6
 
7
7
  export const UserProfileForm = (props) => {
8
8
  const methods = useForm();
9
9
  const {
10
- formState: { errors }
10
+ formState: { errors },
11
+ handleSubmit,
12
+ control
11
13
  } = methods;
12
14
 
13
15
  return (
14
16
  <Container maxWidth="sm">
15
17
  <FormProvider {...methods}>
16
- <form>
17
- <HawaTextField
18
- fullWidth
19
- type="text"
18
+ <form onSubmit={handleSubmit(props.handleUpdateProfile)}>
19
+ <Controller
20
+ control={control}
20
21
  name="fullName"
21
- label="Full Name"
22
- placeholder="Fulan AlFulani"
23
- rules={{
24
- required: "Email is required"
25
- }}
26
- helperText={errors.fullName?.message}
22
+ render={({ field }) => (
23
+ <HawaTextField
24
+ fullWidth
25
+ type="text"
26
+ value={field.value ?? ""}
27
+ label={props.texts.fullNameLabel}
28
+ placeholder={props.texts.fullNamePlaceholder}
29
+ helperText={errors.fullName?.message}
30
+ {...field}
31
+ />
32
+ )}
27
33
  />
28
- <HawaTextField
29
- fullWidth
30
- type="text"
31
- name="fullName"
32
- label="Phone Number"
33
- placeholder="+966"
34
- rules={{
35
- required: "Email is required"
36
- }}
37
- // helperText={errors.fullName?.message}
34
+ <Controller
35
+ control={control}
36
+ name="phoneNumber"
37
+ render={({ field }) => (
38
+ <HawaTextField
39
+ fullWidth
40
+ type="number"
41
+ label="Phone Number"
42
+ placeholder="+966"
43
+ {...field}
44
+ />
45
+ )}
38
46
  />
39
- <HawaTextField
40
- fullWidth
41
- type="text"
47
+ <Controller
48
+ control={control}
42
49
  name="email"
43
- label="New Email"
44
- placeholder="Enter your new email"
50
+ render={({ field }) => (
51
+ <HawaTextField
52
+ fullWidth
53
+ type="text"
54
+ value={field.value ?? ""}
55
+ label={props.texts.emailLabel}
56
+ helperText={errors.email?.message}
57
+ placeholder={props.texts.emailPlaceholder}
58
+ {...field}
59
+ />
60
+ )}
45
61
  rules={{
46
- required: "Email is required"
62
+ required: props.texts.emailRequiredText,
63
+ pattern: {
64
+ value:
65
+ /^(([^<>()[\]\\.,;:\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,}))$/,
66
+ message: props.texts.emailInvalidText
67
+ }
47
68
  }}
48
- helperText={errors.email?.message}
49
69
  />
50
- <HawaTextField
51
- fullWidth
52
- type="password"
70
+ <Controller
71
+ control={control}
53
72
  name="password"
54
- label="New password"
55
- placeholder="Enter your new password"
73
+ render={({ field }) => (
74
+ <HawaTextField
75
+ fullWidth
76
+ type="password"
77
+ value={field.value ?? ""}
78
+ label={props.texts.passwordLabel}
79
+ placeholder={props.texts.passwordPlaceholder}
80
+ // onChange={(e) => setNewPassword(e.target.value)}
81
+ helperText={errors.password?.message}
82
+ {...field}
83
+ />
84
+ )}
56
85
  rules={{
57
- required: "Email is required"
86
+ required: props.texts.passwordRequiredText
58
87
  }}
59
- helperText={errors.password?.message}
60
88
  />
61
- <HawaTextField
62
- fullWidth
63
- type="password"
89
+ <Controller
90
+ control={control}
64
91
  name="confirmPassword"
65
- label="Confirm new password"
66
- placeholder="Confirm new password"
92
+ render={({ field }) => (
93
+ <HawaTextField
94
+ fullWidth
95
+ type="password"
96
+ value={field.value ?? ""}
97
+ label={props.texts.confirmPasswordLabel}
98
+ placeholder={props.texts.confirmPasswordPlaceholder}
99
+ // onChange={(e) => setConfirmPassword(e.target.value)}
100
+ helperText={errors.confirmPassword?.message}
101
+ {...field}
102
+ />
103
+ )}
67
104
  rules={{
68
- required: "Email is required"
105
+ required: props.texts.confirmPasswordRequiredText
69
106
  }}
70
- helperText={errors.confirmPassword?.message}
71
107
  />
72
108
  <Button type="submit" fullWidth variant="last">
73
109
  update profile
@@ -5,8 +5,13 @@ export const UserSettingsForm = (props) => {
5
5
  return (
6
6
  <Container maxWidth="sm">
7
7
  {props.children}
8
- <Button type="submit" fullWidth variant="last">
9
- Save Settings
8
+ <Button
9
+ type="submit"
10
+ fullWidth
11
+ variant="last"
12
+ onClick={props.handleSaveSettings}
13
+ >
14
+ {props.saveSettingsText}
10
15
  </Button>
11
16
  </Container>
12
17
  );
@@ -20,7 +20,11 @@ export const SignInForm = (props) => {
20
20
  } = methods;
21
21
 
22
22
  return (
23
- <Container maxWidth="xs" variant="auth">
23
+ <Container
24
+ maxWidth="xs"
25
+ variant="auth"
26
+ style={{ direction: props.lang === "ar" ? "rtl" : "ltr" }}
27
+ >
24
28
  {props.error && (
25
29
  <Alert severity="error">
26
30
  {props.errorTitle && <AlertTitle>{props.errorTitle}</AlertTitle>}
@@ -21,7 +21,11 @@ export const SignUpForm = (props) => {
21
21
  } = methods;
22
22
 
23
23
  return (
24
- <Container maxWidth="xs" variant="auth">
24
+ <Container
25
+ maxWidth="xs"
26
+ variant="auth"
27
+ style={{ direction: props.lang === "ar" ? "rtl" : "ltr" }}
28
+ >
25
29
  {props.error && (
26
30
  <Alert severity="error">
27
31
  {props.errorTitle && <AlertTitle>{props.errorTitle}</AlertTitle>}
@@ -120,7 +124,7 @@ export const SignUpForm = (props) => {
120
124
  padding: 5
121
125
  }}
122
126
  >
123
- Existing user?{" "}
127
+ {props.texts.existingUserText}{" "}
124
128
  <span
125
129
  onClick={props.handleRouteToSignIn}
126
130
  style={{
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { HawaTextField } from "../../elements";
3
- import { FormProvider, useForm } from "react-hook-form";
3
+ import { Controller, FormProvider, useForm } from "react-hook-form";
4
4
  import Container from "@mui/material/Container";
5
5
  import Button from "@mui/material/Button";
6
6
  import Typography from "@mui/material/Typography";
@@ -10,34 +10,43 @@ export const ChargeWalletForm = (props) => {
10
10
  const methods = useForm();
11
11
  const {
12
12
  formState: { errors },
13
- handleSubmit
13
+ handleSubmit,
14
+ control
14
15
  } = methods;
15
16
 
16
17
  return (
17
18
  <Container maxWidth="xs">
18
- <Typography align="center" variant="h1">
19
+ <Typography align="center" variant="h2" fontWeight={500}>
19
20
  {Number(walletAmount).toLocaleString("en") || "0"}
20
21
  <Typography>{props.currency || "SAR"}</Typography>
21
22
  </Typography>
22
23
  <FormProvider {...methods}>
23
- <form
24
- onChange={(e) => {
25
- e.preventDefault();
26
- setWalletAmount(methods.getValues().amount);
27
- }}
28
- style={{ marginTop: 10 }}
29
- onSubmit={handleSubmit(props.handleChargeWallet)}
30
- >
31
- <HawaTextField
32
- fullWidth
24
+ <form onSubmit={handleSubmit(props.handleChargeWallet)}>
25
+ <Controller
26
+ control={control}
33
27
  name="amount"
34
- placeholder="Enter amount"
35
- type="number"
36
- value={walletAmount}
37
- rules={{
38
- required: "Password is rquired"
39
- }}
40
- helperText={errors.amount?.message}
28
+ render={({ field }) => (
29
+ <HawaTextField
30
+ fullWidth
31
+ placeholder="Enter amount"
32
+ type="number"
33
+ value={field.value ?? ""}
34
+ // helperText={errors.amount?.message}
35
+ {...field}
36
+ inputProps={{
37
+ inputMode: "numeric",
38
+ min: "0",
39
+ max: "9999999",
40
+ step: "0.01"
41
+ }}
42
+ onChange={(e) => {
43
+ // e.preventDefault();
44
+ field.onChange(parseFloat(e.target.value));
45
+ console.log("e", e.target.value);
46
+ setWalletAmount(e.target.value);
47
+ }}
48
+ />
49
+ )}
41
50
  />
42
51
 
43
52
  <Button
@@ -1,33 +1,10 @@
1
1
  import React from "react";
2
- // import { styled } from "@mui/material/styles";
3
-
4
2
  import Alert from "@mui/material/Alert";
5
3
  import AlertTitle from "@mui/material/AlertTitle";
6
4
 
7
5
  export const HawaAlert = (props) => {
8
- // const currentTheme = Object.keys(hawaTheme.alerts).find(
9
- // (tName) => tName.toLowerCase() === themeName?.toLowerCase()
10
- // );
11
- // let alertStyle = {};
12
-
13
- // if (currentTheme) {
14
- // alertStyle = {
15
- // ...hawaTheme.alerts[currentTheme]
16
- // };
17
- // } else {
18
- // alertStyle = {
19
- // marginBottom: 10
20
- // };
21
- // }
22
-
23
- // const StyledAlert = styled(Alert)(({ theme }) => {
24
- // return {
25
- // ...alertStyle
26
- // };
27
- // });
28
-
29
6
  return (
30
- <Alert {...props}>
7
+ <Alert severity={props.severity}>
31
8
  {props.title && <AlertTitle>{props.title}</AlertTitle>}
32
9
  {props.text}
33
10
  </Alert>
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import Table from "@mui/material/Table";
3
+ import TableBody from "@mui/material/TableBody";
4
+ import TableCell from "@mui/material/TableCell";
5
+ import TableContainer from "@mui/material/TableContainer";
6
+ import TableHead from "@mui/material/TableHead";
7
+ import TableRow from "@mui/material/TableRow";
8
+
9
+ export const HawaTable = (props) => {
10
+ return (
11
+ <TableContainer>
12
+ <Table aria-label="a dense table">
13
+ <TableHead>
14
+ <TableRow>
15
+ {props.columns.map((col, i) => (
16
+ <TableCell variant={i == 0 || "bordered"}>{col}</TableCell>
17
+ ))}
18
+ </TableRow>
19
+ </TableHead>
20
+ <TableBody>
21
+ {props.rows.map((singleRow, j) => (
22
+ <TableRow key={j}>
23
+ {singleRow.map((r, i) => (
24
+ <TableCell
25
+ key={i}
26
+ component="th"
27
+ scope="row"
28
+ variant={i == 0 || "bordered"}
29
+ >
30
+ {r}
31
+ </TableCell>
32
+ ))}
33
+ </TableRow>
34
+ ))}
35
+ </TableBody>
36
+ </Table>
37
+ </TableContainer>
38
+ );
39
+ };
@@ -3,24 +3,5 @@ import React from "react";
3
3
  import Typography from "@mui/material/Typography";
4
4
 
5
5
  export const HawaTypography = (props) => {
6
- // const currentTheme = Object.keys(hawaTheme.typography).find(
7
- // (tName) => tName.toLowerCase() === themeName?.toLowerCase()
8
- // );
9
- // let typographyStyle = {};
10
-
11
- // if (currentTheme) {
12
- // typographyStyle = { ...hawaTheme.typography[currentTheme] };
13
- // } else {
14
- // typographyStyle = {
15
- // color: "black"
16
- // };
17
- // }
18
-
19
- // const StyledTypography = styled(Typography)(({ theme }) => {
20
- // return {
21
- // ...typographyStyle
22
- // };
23
- // });
24
-
25
6
  return <Typography {...props}>{props.children}</Typography>;
26
7
  };
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import Snackbar from "@mui/material/Snackbar";
3
+ import AlertTitle from "@mui/material/AlertTitle";
4
+ import Alert from "@mui/material/Alert";
5
+
6
+ export const OfflineBanner = (props) => {
7
+ return (
8
+ <Snackbar
9
+ variant="danger"
10
+ // style={{ outline: "1px solid red" }}
11
+ open={props.open}
12
+ onClose={props.handleClose}
13
+ >
14
+ <Alert icon={false} severity={"error"} variant="offline">
15
+ {props.title && <AlertTitle>{props.title}</AlertTitle>}
16
+ {props.text}
17
+ </Alert>
18
+ </Snackbar>
19
+ );
20
+ };