@homefile/components-v2 2.7.18 → 2.7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/myProfile/details/TwoFactorDialog.d.ts +2 -0
- package/dist/components/myProfile/details/TwoFactorDialog.js +6 -0
- package/dist/components/myProfile/details/index.d.ts +1 -0
- package/dist/components/myProfile/details/index.js +1 -0
- package/dist/components/onboarding/pages/TwoFactor.d.ts +1 -1
- package/dist/components/onboarding/pages/TwoFactor.js +3 -3
- package/dist/interfaces/myProfile/details/TwoFactorDialog.interface.d.ts +8 -0
- package/dist/interfaces/myProfile/details/TwoFactorDialog.interface.js +1 -0
- package/dist/interfaces/myProfile/details/TwoFactorSetting.interface.d.ts +1 -1
- package/dist/interfaces/myProfile/details/index.d.ts +1 -0
- package/dist/interfaces/myProfile/details/index.js +1 -0
- package/dist/interfaces/pages/TwoFactor.interface.d.ts +3 -2
- package/dist/stories/myProfile/details/TwoFactorDialog.stories.d.ts +5 -0
- package/dist/stories/myProfile/details/TwoFactorDialog.stories.js +18 -0
- package/package.json +1 -1
- package/src/components/myProfile/details/TwoFactorDialog.tsx +27 -0
- package/src/components/myProfile/details/index.ts +1 -0
- package/src/components/onboarding/pages/TwoFactor.tsx +13 -10
- package/src/hooks/myProfile/useTwoFactorSetting.ts +4 -3
- package/src/interfaces/myProfile/details/TwoFactorDialog.interface.ts +8 -0
- package/src/interfaces/myProfile/details/TwoFactorSetting.interface.ts +1 -1
- package/src/interfaces/myProfile/details/index.ts +1 -0
- package/src/interfaces/pages/TwoFactor.interface.ts +3 -2
- package/src/stories/myProfile/details/TwoFactorDialog.stories.tsx +22 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal, ModalContent, ModalOverlay } from '@chakra-ui/react';
|
|
3
|
+
import { TwoFactor } from '../..';
|
|
4
|
+
export const TwoFactorDialog = ({ isOpen, isLoading = false, onClose, onResend, onReset, twoFactorMethod, }) => {
|
|
5
|
+
return (_jsxs(Modal, { isOpen: isOpen, onClose: onClose, children: [_jsx(ModalOverlay, {}), _jsx(ModalContent, { children: _jsx(TwoFactor, { twoFactorMethod: twoFactorMethod, isDialog: true, isLoading: isLoading, onResend: onResend, onReset: onReset }) })] }));
|
|
6
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TwoFactorI } from '../../../interfaces';
|
|
2
|
-
export declare const TwoFactor: ({
|
|
2
|
+
export declare const TwoFactor: ({ onReset, onResend, isDialog, isLoading, twoFactorMethod, }: TwoFactorI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { Box, Button, Text, Container, Stack, Center } from '@chakra-ui/react';
|
|
|
4
4
|
import { Logo, Footer, ButtonLoader, TextInput, BasePageWrapper, } from '../..';
|
|
5
5
|
import { isEmptyField } from '../../../utils';
|
|
6
6
|
import { useTwoFactor } from '../../../hooks';
|
|
7
|
-
export const TwoFactor = ({
|
|
8
|
-
const { code, handleInputChange, handleSubmit, isValidated } = useTwoFactor(
|
|
9
|
-
return (_jsxs(BasePageWrapper, { children: [_jsxs(Container, { size: "onboarding", boxShadow:
|
|
7
|
+
export const TwoFactor = ({ onReset, onResend, isDialog, isLoading, twoFactorMethod, }) => {
|
|
8
|
+
const { code, handleInputChange, handleSubmit, isValidated } = useTwoFactor(onReset);
|
|
9
|
+
return (_jsxs(BasePageWrapper, { children: [_jsxs(Container, { size: "onboarding", boxShadow: !isDialog ? 'lg' : 'none', children: [_jsx(Logo, {}), _jsxs(Stack, { my: "6", children: [_jsx(Text, { variant: "title", textAlign: "center", px: "10", children: t('reset.2FA.title') }), _jsxs(Text, { fontFamily: "secondary", textAlign: "center", px: ['10', '20'], children: [twoFactorMethod === 'email' && t('reset.2FA.subtitleEmail'), twoFactorMethod === 'sms' && t('reset.2FA.subtitleSms')] })] }), _jsx(Box, { px: ['container.sm', 'container.md', 'container.lg'], pb: "container.md", mb: "6", children: _jsxs(Stack, { spacing: "4", children: [_jsx(TextInput, { errorMessage: t('forms.code') + ' ' + t('forms.required'), hasError: isValidated && isEmptyField(code), id: "code", placeholder: t('reset.2FA.placeholder'), value: code, handleChange: handleInputChange }), _jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: handleSubmit, children: t('forms.submit') }), onResend && (_jsx(Center, { children: _jsx(Button, { onClick: onResend, variant: "text", children: t('reset.2FA.resend') }) }))] }) })] }), !isDialog && _jsx(Footer, {})] }));
|
|
10
10
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,7 +7,7 @@ export interface TwoFactorSettingI {
|
|
|
7
7
|
defaultValue?: string;
|
|
8
8
|
email?: string;
|
|
9
9
|
loading?: boolean;
|
|
10
|
-
onChange?: (value:
|
|
10
|
+
onChange?: (value: 'email' | 'sms') => void;
|
|
11
11
|
onSave: (value: TwoFactorFormI) => void;
|
|
12
12
|
sms?: string;
|
|
13
13
|
twoFactor?: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { TwoFactorDialogI } from '../../../interfaces';
|
|
3
|
+
declare const _default: Meta<TwoFactorDialogI>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const TwoFactorDialogComponent: (args: TwoFactorDialogI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TwoFactorDialog } from '../../../components';
|
|
3
|
+
import { action } from '@storybook/addon-actions';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/MyProfile/Details',
|
|
6
|
+
component: TwoFactorDialog,
|
|
7
|
+
args: {
|
|
8
|
+
onReset: action('onReset'),
|
|
9
|
+
onResend: action('onResend'),
|
|
10
|
+
onClose: action('onClose'),
|
|
11
|
+
twoFactorMethod: 'sms',
|
|
12
|
+
isLoading: false,
|
|
13
|
+
isOpen: true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export const TwoFactorDialogComponent = (args) => {
|
|
17
|
+
return _jsx(TwoFactorDialog, Object.assign({}, args));
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Modal, ModalContent, ModalOverlay } from '@chakra-ui/react'
|
|
2
|
+
import { TwoFactor } from '@/components'
|
|
3
|
+
import { TwoFactorDialogI } from '@/interfaces'
|
|
4
|
+
|
|
5
|
+
export const TwoFactorDialog = ({
|
|
6
|
+
isOpen,
|
|
7
|
+
isLoading = false,
|
|
8
|
+
onClose,
|
|
9
|
+
onResend,
|
|
10
|
+
onReset,
|
|
11
|
+
twoFactorMethod,
|
|
12
|
+
}: TwoFactorDialogI) => {
|
|
13
|
+
return (
|
|
14
|
+
<Modal isOpen={isOpen} onClose={onClose}>
|
|
15
|
+
<ModalOverlay />
|
|
16
|
+
<ModalContent>
|
|
17
|
+
<TwoFactor
|
|
18
|
+
twoFactorMethod={twoFactorMethod}
|
|
19
|
+
isDialog
|
|
20
|
+
isLoading={isLoading}
|
|
21
|
+
onResend={onResend}
|
|
22
|
+
onReset={onReset}
|
|
23
|
+
/>
|
|
24
|
+
</ModalContent>
|
|
25
|
+
</Modal>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -12,17 +12,18 @@ import { TwoFactorI } from '@/interfaces'
|
|
|
12
12
|
import { useTwoFactor } from '@/hooks'
|
|
13
13
|
|
|
14
14
|
export const TwoFactor = ({
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
onReset,
|
|
16
|
+
onResend,
|
|
17
|
+
isDialog,
|
|
17
18
|
isLoading,
|
|
18
19
|
twoFactorMethod,
|
|
19
20
|
}: TwoFactorI) => {
|
|
20
21
|
const { code, handleInputChange, handleSubmit, isValidated } =
|
|
21
|
-
useTwoFactor(
|
|
22
|
+
useTwoFactor(onReset)
|
|
22
23
|
|
|
23
24
|
return (
|
|
24
25
|
<BasePageWrapper>
|
|
25
|
-
<Container size="onboarding" boxShadow=
|
|
26
|
+
<Container size="onboarding" boxShadow={!isDialog ? 'lg' : 'none'}>
|
|
26
27
|
<Logo />
|
|
27
28
|
<Stack my="6">
|
|
28
29
|
<Text variant="title" textAlign="center" px="10">
|
|
@@ -55,15 +56,17 @@ export const TwoFactor = ({
|
|
|
55
56
|
>
|
|
56
57
|
{t('forms.submit')}
|
|
57
58
|
</Button>
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
{onResend && (
|
|
60
|
+
<Center>
|
|
61
|
+
<Button onClick={onResend} variant="text">
|
|
62
|
+
{t('reset.2FA.resend')}
|
|
63
|
+
</Button>
|
|
64
|
+
</Center>
|
|
65
|
+
)}
|
|
63
66
|
</Stack>
|
|
64
67
|
</Box>
|
|
65
68
|
</Container>
|
|
66
|
-
<Footer />
|
|
69
|
+
{!isDialog && <Footer />}
|
|
67
70
|
</BasePageWrapper>
|
|
68
71
|
)
|
|
69
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
2
|
import { useRadioGroup } from '@chakra-ui/react'
|
|
3
3
|
import { useForm } from 'react-hook-form'
|
|
4
4
|
import * as yup from 'yup'
|
|
@@ -15,7 +15,7 @@ export const useTwoFactorSetting = ({
|
|
|
15
15
|
}: Partial<TwoFactorSettingI>) => {
|
|
16
16
|
const altText = getIconAltText(Security)
|
|
17
17
|
|
|
18
|
-
const handleRadioChange = (value:
|
|
18
|
+
const handleRadioChange = (value: 'email' | 'sms') => {
|
|
19
19
|
onChange?.(value)
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -56,7 +56,8 @@ export const useTwoFactorSetting = ({
|
|
|
56
56
|
const isSmsChanged = smsValue !== sms
|
|
57
57
|
const radioChanged = radioValue !== defaultValue && is2faEnabled
|
|
58
58
|
|
|
59
|
-
const showButtons =
|
|
59
|
+
const showButtons =
|
|
60
|
+
isSwitchChanged || isEmailChanged || isSmsChanged || radioChanged
|
|
60
61
|
|
|
61
62
|
const handlePhoneValidation = (value?: string): boolean => {
|
|
62
63
|
if (radioValue === 'sms')
|
|
@@ -8,7 +8,7 @@ export interface TwoFactorSettingI {
|
|
|
8
8
|
defaultValue?: string
|
|
9
9
|
email?: string
|
|
10
10
|
loading?: boolean
|
|
11
|
-
onChange?: (value:
|
|
11
|
+
onChange?: (value: 'email' | 'sms') => void
|
|
12
12
|
onSave: (value: TwoFactorFormI) => void
|
|
13
13
|
sms?: string
|
|
14
14
|
twoFactor?: string
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react'
|
|
2
|
+
import { Box } from '@chakra-ui/react'
|
|
3
|
+
import { TwoFactorDialog } from '@/components'
|
|
4
|
+
import { action } from '@storybook/addon-actions'
|
|
5
|
+
import { TwoFactorDialogI } from '@/interfaces'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/MyProfile/Details',
|
|
9
|
+
component: TwoFactorDialog,
|
|
10
|
+
args: {
|
|
11
|
+
onReset: action('onReset'),
|
|
12
|
+
onResend: action('onResend'),
|
|
13
|
+
onClose: action('onClose'),
|
|
14
|
+
twoFactorMethod: 'sms',
|
|
15
|
+
isLoading: false,
|
|
16
|
+
isOpen: true,
|
|
17
|
+
},
|
|
18
|
+
} as Meta<TwoFactorDialogI>
|
|
19
|
+
|
|
20
|
+
export const TwoFactorDialogComponent = (args: TwoFactorDialogI) => {
|
|
21
|
+
return <TwoFactorDialog {...args} />
|
|
22
|
+
}
|