@homefile/components-v2 1.4.0 → 1.4.2

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.
@@ -1,2 +1,2 @@
1
1
  import { SignInI } from '../../../interfaces';
2
- export declare const SignIn: ({ isLoading, handleForgotPassword, handleSignIn, handleSignUp, loginError, values, }: SignInI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SignIn: ({ isLoading, handleForgotPassword, handleSignIn, handleSignUp, loginErrorMessage, values, }: SignInI) => import("react/jsx-runtime").JSX.Element;
@@ -9,23 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { t } from 'i18next';
12
- import { Box, Button, Center, Container, Stack } from '@chakra-ui/react';
12
+ import { Box, Button, Center, Container, Stack, Text } from '@chakra-ui/react';
13
13
  import { Logo, Footer, PageTitle, CardFooter, PasswordInput, TextInput, ButtonLoader, BasePageWrapper, } from '../..';
14
14
  import { isEmptyField } from '../../../utils';
15
15
  import { useSignIn } from '../../../hooks';
16
- export const SignIn = ({ isLoading, handleForgotPassword, handleSignIn, handleSignUp, loginError, values = { email: '', password: '' }, }) => {
16
+ export const SignIn = ({ isLoading, handleForgotPassword, handleSignIn, handleSignUp, loginErrorMessage, values = { email: '', password: '' }, }) => {
17
17
  const { inputs, handleInputChange, isValidated, setIsValidated } = useSignIn(values);
18
- return (_jsxs(BasePageWrapper, { children: [_jsxs(Container, { size: "onboarding", boxShadow: "lg", children: [_jsx(Logo, {}), _jsx(PageTitle, { title: t('signin.title') }), _jsx(Box, { px: ['container.sm', 'container.md', 'container.lg'], mb: 6, children: _jsxs(Stack, { spacing: 8, children: [_jsxs(Stack, { spacing: "base", as: "form", children: [_jsx(TextInput, { autoCapitalize: "none", autoCorrect: "off", autoComplete: "username", errorMessage: loginError
19
- ? t('forms.errorLogin')
20
- : t('forms.email') + ' ' + t('forms.required'), hasError: isValidated && (loginError || isEmptyField(inputs.email)), id: "email", placeholder: t('forms.email'), value: values.email || inputs.email, handleChange: (event) => {
18
+ return (_jsxs(BasePageWrapper, { children: [_jsxs(Container, { size: "onboarding", boxShadow: "lg", children: [_jsx(Logo, {}), _jsx(PageTitle, { title: t('signin.title') }), _jsx(Box, { px: ['container.sm', 'container.md', 'container.lg'], mb: 6, children: _jsxs(Stack, { spacing: 8, children: [_jsxs(Stack, { spacing: "base", as: "form", children: [_jsx(TextInput, { autoCapitalize: "none", autoCorrect: "off", autoComplete: "username", errorMessage: t('forms.email') + ' ' + t('forms.required'), hasError: isValidated && isEmptyField(inputs.email), id: "email", placeholder: t('forms.email'), value: values.email || inputs.email, handleChange: (event) => {
21
19
  values.email = event.target.value;
22
20
  handleInputChange(event);
23
- } }), _jsx(PasswordInput, { autoComplete: "current-password", errorMessage: loginError
24
- ? t('forms.errorLogin')
25
- : t('forms.password') + ' ' + t('forms.required'), hasError: isValidated && (loginError || isEmptyField(inputs.password)), id: "password", placeholder: t('forms.password'), value: values.password || inputs.password, handleChange: (event) => {
21
+ } }), _jsx(PasswordInput, { autoComplete: "current-password", errorMessage: t('forms.password') + ' ' + t('forms.required'), hasError: isValidated && isEmptyField(inputs.password), id: "password", placeholder: t('forms.password'), value: values.password || inputs.password, handleChange: (event) => {
26
22
  values.password = event.target.value;
27
23
  handleInputChange(event);
28
- } })] }), _jsxs(Stack, { spacing: 4, children: [_jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: () => __awaiter(void 0, void 0, void 0, function* () {
24
+ } }), Boolean(loginErrorMessage) && (_jsx(Text, { variant: "error", children: loginErrorMessage }))] }), _jsxs(Stack, { spacing: 4, children: [_jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: () => __awaiter(void 0, void 0, void 0, function* () {
29
25
  setIsValidated(true);
30
26
  if (!isEmptyField(inputs.email) &&
31
27
  !isEmptyField(inputs.password)) {
@@ -1,2 +1,2 @@
1
1
  import { SignUpI } from '../../../interfaces';
2
- export declare const SignUp: ({ isLoading, handleCreateAccount, handleSignIn, showPromoCode, signupError, values, }: SignUpI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SignUp: ({ isLoading, handleCreateAccount, handleSignIn, showPromoCode, signupErrorMessage, values, }: SignUpI) => import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { Box, Button, Center, Container, Stack, Text } from '@chakra-ui/react';
4
4
  import { Logo, Footer, CardFooter, PageTitle, PasswordInput, TextInput, ButtonLoader, BasePageWrapper, } from '../..';
5
5
  import { isEmptyField, isValidEmail, isValidPassword, passwordMatch, } from '../../../utils';
6
6
  import { useSignUp } from '../../../hooks';
7
- export const SignUp = ({ isLoading, handleCreateAccount, handleSignIn, showPromoCode, signupError, values = {
7
+ export const SignUp = ({ isLoading, handleCreateAccount, handleSignIn, showPromoCode, signupErrorMessage, values = {
8
8
  email: '',
9
9
  firstName: '',
10
10
  lastName: '',
@@ -22,5 +22,5 @@ export const SignUp = ({ isLoading, handleCreateAccount, handleSignIn, showPromo
22
22
  (!isValidPassword(inputs.password) ||
23
23
  !passwordMatch(inputs.password, inputs.confirmPassword)), id: "password", placeholder: t('forms.password'), value: (_b = inputs.password) !== null && _b !== void 0 ? _b : '', handleChange: (event) => handleInputChange(event), autoComplete: "new-password" }), _jsx(PasswordInput, { errorMessage: passwordErrorMessage(inputs.confirmPassword), hasError: isValidated &&
24
24
  (!isValidPassword(inputs.confirmPassword) ||
25
- !passwordMatch(inputs.password, inputs.confirmPassword)), id: "confirmPassword", placeholder: t('forms.passwordConfirm'), value: (_c = inputs.confirmPassword) !== null && _c !== void 0 ? _c : '', handleChange: (event) => handleInputChange(event), autoComplete: "new-password" }), _jsx(Center, { px: ['container.sm', 'container.md', 'container.lg'], h: "4rem", children: _jsxs(Text, { textAlign: "center", variant: "info", w: "100%", children: [t('signup.terms'), _jsx("a", { target: "_blank", href: t('footer.termsUrl'), children: t('footer.termsLink') })] }) }), _jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: handleSubmit, children: t('signup.signupBt') })] }) }), _jsx(CardFooter, { title: t('signup.signin'), buttonLabel: t('signup.signinBt'), handleButtonClick: handleSignIn })] }), _jsx(Footer, {})] }));
25
+ !passwordMatch(inputs.password, inputs.confirmPassword)), id: "confirmPassword", placeholder: t('forms.passwordConfirm'), value: (_c = inputs.confirmPassword) !== null && _c !== void 0 ? _c : '', handleChange: (event) => handleInputChange(event), autoComplete: "new-password" }), _jsx(Center, { px: ['container.sm', 'container.md', 'container.lg'], h: "4rem", children: _jsxs(Text, { textAlign: "center", variant: "info", w: "100%", children: [t('signup.terms'), _jsx("a", { target: "_blank", href: t('footer.termsUrl'), children: t('footer.termsLink') })] }) }), _jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: handleSubmit, children: t('signup.signupBt') }), Boolean(signupErrorMessage) && (_jsx(Text, { variant: "error", children: signupErrorMessage }))] }) }), _jsx(CardFooter, { title: t('signup.signin'), buttonLabel: t('signup.signinBt'), handleButtonClick: handleSignIn })] }), _jsx(Footer, {})] }));
26
26
  };
@@ -7,6 +7,6 @@ export interface SignInI {
7
7
  handleForgotPassword: () => void;
8
8
  handleSignIn: (form: SignInFormI) => void;
9
9
  handleSignUp: () => void;
10
- loginError: boolean;
10
+ loginErrorMessage?: string;
11
11
  values?: SignInFormI;
12
12
  }
@@ -11,6 +11,6 @@ export interface SignUpI {
11
11
  handleCreateAccount: (form: SignUpFormI) => void;
12
12
  handleSignIn: () => void;
13
13
  showPromoCode?: boolean;
14
- signupError: boolean;
14
+ signupErrorMessage?: string;
15
15
  values?: SignUpFormI;
16
16
  }
@@ -6,7 +6,6 @@ export declare const SignInPage: {
6
6
  (args: SignInI): import("react/jsx-runtime").JSX.Element;
7
7
  args: {
8
8
  isLoading: boolean;
9
- loginError: boolean;
10
9
  values: {
11
10
  email: string;
12
11
  password: string;
@@ -12,6 +12,5 @@ export const SignInPage = (args) => {
12
12
  };
13
13
  SignInPage.args = {
14
14
  isLoading: false,
15
- loginError: false,
16
15
  values: { email: 'damaprodutora@gmail.com', password: '123456' },
17
16
  };
@@ -6,7 +6,6 @@ export declare const SignUpPage: {
6
6
  (args: SignUpI): import("react/jsx-runtime").JSX.Element;
7
7
  args: {
8
8
  isLoading: boolean;
9
- signupError: boolean;
10
9
  showPromoCode: boolean;
11
10
  values: {
12
11
  email: string;
@@ -14,7 +14,6 @@ const valuesFilled = {
14
14
  };
15
15
  SignUpPage.args = {
16
16
  isLoading: false,
17
- signupError: false,
18
17
  showPromoCode: true,
19
18
  values: valuesFilled,
20
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import { t } from 'i18next'
2
- import { Box, Button, Center, Container, Stack } from '@chakra-ui/react'
2
+ import { Box, Button, Center, Container, Stack, Text } from '@chakra-ui/react'
3
3
  import {
4
4
  Logo,
5
5
  Footer,
@@ -19,7 +19,7 @@ export const SignIn = ({
19
19
  handleForgotPassword,
20
20
  handleSignIn,
21
21
  handleSignUp,
22
- loginError,
22
+ loginErrorMessage,
23
23
  values = { email: '', password: '' },
24
24
  }: SignInI) => {
25
25
  const { inputs, handleInputChange, isValidated, setIsValidated } =
@@ -37,14 +37,8 @@ export const SignIn = ({
37
37
  autoCapitalize="none"
38
38
  autoCorrect="off"
39
39
  autoComplete="username"
40
- errorMessage={
41
- loginError
42
- ? t('forms.errorLogin')
43
- : t('forms.email') + ' ' + t('forms.required')
44
- }
45
- hasError={
46
- isValidated && (loginError || isEmptyField(inputs.email))
47
- }
40
+ errorMessage={t('forms.email') + ' ' + t('forms.required')}
41
+ hasError={isValidated && isEmptyField(inputs.email)}
48
42
  id="email"
49
43
  placeholder={t('forms.email')}
50
44
  value={values.email || inputs.email}
@@ -55,14 +49,8 @@ export const SignIn = ({
55
49
  />
56
50
  <PasswordInput
57
51
  autoComplete="current-password"
58
- errorMessage={
59
- loginError
60
- ? t('forms.errorLogin')
61
- : t('forms.password') + ' ' + t('forms.required')
62
- }
63
- hasError={
64
- isValidated && (loginError || isEmptyField(inputs.password))
65
- }
52
+ errorMessage={t('forms.password') + ' ' + t('forms.required')}
53
+ hasError={isValidated && isEmptyField(inputs.password)}
66
54
  id="password"
67
55
  placeholder={t('forms.password')}
68
56
  value={values.password || inputs.password}
@@ -71,6 +59,9 @@ export const SignIn = ({
71
59
  handleInputChange(event)
72
60
  }}
73
61
  />
62
+ {Boolean(loginErrorMessage) && (
63
+ <Text variant="error">{loginErrorMessage}</Text>
64
+ )}
74
65
  </Stack>
75
66
  <Stack spacing={4}>
76
67
  <Button
@@ -24,7 +24,7 @@ export const SignUp = ({
24
24
  handleCreateAccount,
25
25
  handleSignIn,
26
26
  showPromoCode,
27
- signupError,
27
+ signupErrorMessage,
28
28
  values = {
29
29
  email: '',
30
30
  firstName: '',
@@ -142,6 +142,9 @@ export const SignUp = ({
142
142
  >
143
143
  {t('signup.signupBt')}
144
144
  </Button>
145
+ {Boolean(signupErrorMessage) && (
146
+ <Text variant="error">{signupErrorMessage}</Text>
147
+ )}
145
148
  </Stack>
146
149
  </Box>
147
150
  <CardFooter
@@ -8,6 +8,6 @@ export interface SignInI {
8
8
  handleForgotPassword: () => void
9
9
  handleSignIn: (form: SignInFormI) => void
10
10
  handleSignUp: () => void
11
- loginError: boolean
11
+ loginErrorMessage?: string
12
12
  values?: SignInFormI
13
- }
13
+ }
@@ -12,6 +12,6 @@ export interface SignUpI {
12
12
  handleCreateAccount: (form: SignUpFormI) => void
13
13
  handleSignIn: () => void
14
14
  showPromoCode?: boolean
15
- signupError: boolean
15
+ signupErrorMessage?: string
16
16
  values?: SignUpFormI
17
- }
17
+ }
@@ -20,6 +20,5 @@ export const SignInPage = (args: SignInI) => {
20
20
 
21
21
  SignInPage.args = {
22
22
  isLoading: false,
23
- loginError: false,
24
23
  values: { email: 'damaprodutora@gmail.com', password: '123456' },
25
24
  }
@@ -23,7 +23,6 @@ const valuesFilled = {
23
23
 
24
24
  SignUpPage.args = {
25
25
  isLoading: false,
26
- signupError: false,
27
26
  showPromoCode: true,
28
27
  values: valuesFilled,
29
28
  }