@homefile/components-v2 2.41.0 → 2.42.0

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.
@@ -617,7 +617,10 @@
617
617
  },
618
618
  "details": {
619
619
  "2FactorSubtitle": "Select how you would like to receive your 2FA codes. These codes keep your account secure.",
620
- "2FactorTitle": "2 Factor Authentication (2FA)"
620
+ "2FactorTitle": "2 Factor Authentication (2FA)",
621
+ "homiSmsAlt": "Homi SMS",
622
+ "homiSmsSubtitle": "Enable SMS messaging to interact with Homi without a mobile app. Text images, documents, and information directly into Homefile so Homi can capture and organize it for you automatically.",
623
+ "homiSmsTitle": "Enable Homi SMS Messaging"
621
624
  },
622
625
  "email": {
623
626
  "emailPermissions": "Email Permissions",
@@ -0,0 +1,2 @@
1
+ import { HomiSmsI } from '../../../interfaces';
2
+ export declare const HomiSms: ({ defaultEnabled, defaultSmsEnabled, sms, loading, onChange, onSave, }: HomiSmsI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { t } from 'i18next';
3
+ import { Controller, useForm, useWatch } from 'react-hook-form';
4
+ import { useEffect } from 'react';
5
+ import * as yup from 'yup';
6
+ import { Stack, Flex, Img, Text, Box, FormControl, FormLabel, Switch, Checkbox, Button, } from '@chakra-ui/react';
7
+ import { SMS } from '../../../assets/images';
8
+ import { ControlledInput, Loading } from '../../../components';
9
+ export const HomiSms = ({ defaultEnabled = false, defaultSmsEnabled = true, sms = '', loading, onChange, onSave, }) => {
10
+ var _a, _b, _c;
11
+ const { control, handleSubmit } = useForm({
12
+ defaultValues: {
13
+ enabled: defaultEnabled,
14
+ smsEnabled: defaultSmsEnabled,
15
+ sms,
16
+ },
17
+ });
18
+ const values = useWatch({ control });
19
+ const isEnabled = (_a = values === null || values === void 0 ? void 0 : values.enabled) !== null && _a !== void 0 ? _a : false;
20
+ const isSmsEnabled = (_b = values === null || values === void 0 ? void 0 : values.smsEnabled) !== null && _b !== void 0 ? _b : false;
21
+ const smsValue = (_c = values === null || values === void 0 ? void 0 : values.sms) !== null && _c !== void 0 ? _c : '';
22
+ const isEnabledChanged = isEnabled !== defaultEnabled;
23
+ const isSmsEnabledChanged = isSmsEnabled !== defaultSmsEnabled;
24
+ const isSmsChanged = smsValue !== sms;
25
+ const showButtons = isEnabledChanged || isSmsEnabledChanged || isSmsChanged;
26
+ const handlePhoneValidation = (value) => {
27
+ if (isEnabled && isSmsEnabled)
28
+ return yup.string().required().min(10).max(10).isValidSync(value);
29
+ return true;
30
+ };
31
+ useEffect(() => {
32
+ if (onChange && values) {
33
+ onChange(values);
34
+ }
35
+ }, [onChange, values]);
36
+ return (_jsxs(Box, { position: "relative", children: [loading && _jsx(Loading, {}), _jsxs(Stack, { bg: "lightBlue.2", px: "base", py: "4", spacing: "4", children: [_jsxs(Stack, { spacing: "3", children: [_jsxs(Flex, { align: "center", justify: "space-between", children: [_jsxs(Flex, { gap: "base", align: "center", children: [_jsx(Img, { src: SMS, alt: t('myProfile.details.homiSmsAlt') }), _jsx(Text, { fontSize: "sm", textTransform: "uppercase", children: t('myProfile.details.homiSmsTitle') })] }), _jsx(Controller, { name: "enabled", control: control, render: ({ field: { value, onChange, onBlur } }) => {
37
+ const label = value ? 'ON' : 'OFF';
38
+ return (_jsxs(FormControl, { display: "flex", alignItems: "center", w: "fit-content", children: [_jsx(FormLabel, { htmlFor: "homi-sms", mb: "0", fontSize: "sm", children: label }), _jsx(Switch, { id: "homi-sms", size: "lg", isChecked: value, onChange: onChange, onBlur: onBlur })] }));
39
+ } })] }), _jsx(Text, { fontFamily: "secondary", lineHeight: "1.2", children: t('myProfile.details.homiSmsSubtitle') })] }), _jsxs(Flex, { gap: "base", align: "center", justify: "space-between", children: [_jsx(Controller, { name: "smsEnabled", control: control, render: ({ field: { value, onChange } }) => (_jsx(Checkbox, { size: "md", isChecked: value, onChange: (event) => onChange(event.target.checked), isDisabled: !isEnabled, children: _jsx(Text, { variant: "info", fontWeight: "normal", children: "SMS" }) })) }), _jsx(Box, { w: "75%", children: _jsx(Controller, { name: "sms", control: control, rules: { validate: handlePhoneValidation }, render: ({ field: { value, onBlur, onChange }, fieldState: { invalid }, }) => (_jsx(ControlledInput, { placeholder: t('myProfile.placeholders.sms'), onChange: onChange, onBlur: onBlur, value: value !== null && value !== void 0 ? value : '', type: "tel", hasError: invalid, errorMessage: `${t('forms.invalid')} ${t('forms.phone')}`, isDisabled: !isEnabled || !isSmsEnabled })) }) })] }), showButtons && onSave && (_jsx(Box, { w: "75%", alignSelf: "end", children: _jsx(Button, { variant: "secondaryFooter", type: "submit", bg: "neutral.white", fontWeight: "medium", onClick: handleSubmit(onSave), children: t('buttons.save').toUpperCase() }) }))] })] }));
40
+ };
@@ -1,3 +1,4 @@
1
1
  export * from './TwoFactorDialog';
2
2
  export * from './TwoFactorSetting';
3
3
  export * from './UserDetails';
4
+ export * from './HomiSms';
@@ -1,3 +1,4 @@
1
1
  export * from './TwoFactorDialog';
2
2
  export * from './TwoFactorSetting';
3
3
  export * from './UserDetails';
4
+ export * from './HomiSms';
@@ -0,0 +1,13 @@
1
+ export interface HomiSmsFormI {
2
+ enabled: boolean;
3
+ smsEnabled: boolean;
4
+ sms?: string;
5
+ }
6
+ export interface HomiSmsI {
7
+ defaultEnabled?: boolean;
8
+ defaultSmsEnabled?: boolean;
9
+ sms?: string;
10
+ loading?: boolean;
11
+ onChange?: (value: HomiSmsFormI) => void;
12
+ onSave?: (value: HomiSmsFormI) => void;
13
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './TwoFactorDialog.interface';
2
2
  export * from './TwoFactorSetting.interface';
3
3
  export * from './UserDetails.interface';
4
+ export * from './HomiSms.interface';
@@ -1,3 +1,4 @@
1
1
  export * from './TwoFactorDialog.interface';
2
2
  export * from './TwoFactorSetting.interface';
3
3
  export * from './UserDetails.interface';
4
+ export * from './HomiSms.interface';
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Divider, DrawerBody } from '@chakra-ui/react';
3
- import { ActiveSubscription, CancelAccount, CreditCardContainer, CreditCardError, MonthlyCharge, MyProfileBody, MyProfileHeader, MyProfilePanel, NewCreditCard, NewCreditCardHeader, PaymentReceipts, RightPanel, RolePermissionsTab, TwoFactorSetting, UserDetails, } from '../../components';
3
+ import { ActiveSubscription, CancelAccount, CreditCardContainer, CreditCardError, HomiSms, MonthlyCharge, MyProfileBody, MyProfileHeader, MyProfilePanel, NewCreditCard, NewCreditCardHeader, PaymentReceipts, RightPanel, RolePermissionsTab, TwoFactorSetting, UserDetails, } from '../../components';
4
4
  import { action } from '@storybook/addon-actions';
5
5
  import { featuresSelectedMock, menuMock, receiptsMock } from '../../mocks';
6
6
  import { useState } from 'react';
@@ -14,5 +14,5 @@ export const MyProfilePanelComponent = () => {
14
14
  const handleCloseNewCreditCardPanel = () => setIsNewCreditCardPanelOpen(false);
15
15
  const handleOpenNewCreditCardPanel = () => setIsNewCreditCardPanelOpen(true);
16
16
  const handleError = () => setHasError(true);
17
- return (_jsxs(_Fragment, { children: [_jsx(RightPanel, { isOpen: true, onClose: action('onCloseClick'), children: _jsxs(MyProfilePanel, { children: [_jsx(MyProfileHeader, { onClose: action('onCloseClick') }), _jsx(MyProfileBody, { isLoading: false, account: _jsxs(_Fragment, { children: [_jsx(ActiveSubscription, { nextCharge: "2024-12-01", subscriptionPrice: 36, totalStorage: 2, totalUsed: 1, availableStorage: 200, state: 'trial' }), _jsx(Divider, { width: "calc(100% - 26px)", mx: "auto" }), _jsx(MonthlyCharge, { additionalPrice: 36, monthlyCharge: 36, monthDate: "03/01/2023", nextCharge: "01/12/2024", taxPercentage: 8.5, taxValue: 3.06, subtotal: 36.0 }), _jsx(CancelAccount, { label: "Contact Homefile", onClick: action('onCancelAccountClick') })] }), details: _jsxs(_Fragment, { children: [_jsx(UserDetails, { email: "gary.edmunds@gmail.com", firstName: "Gary", lastName: "Edmunds", onSave: action('onSaveClick'), bg: "#4CC35A" }), _jsx(TwoFactorSetting, { email: "gary.edmunds@gmail.com", sms: "2032409108", onChange: action('on2FAChangeClick'), onSave: action('onSaveClick'), defaultValue: "email", twoFactor: 'active' })] }), payment: _jsxs(Box, { bg: "lightBlue.2", h: "inherit", children: [_jsx(CreditCardContainer, { cardNumber: "1234 5678 9012 3456", brand: "visa", onAddCard: action('onAddCard'), onDeleteCard: handleOpenNewCreditCardPanel, onSubmit: (data) => action('onDeleteCard')(data), cardHolder: "Gary Edmunds", cvv: "123", expirationMonth: "12", expirationYear: "2024" }), _jsx(PaymentReceipts, { receipts: receiptsMock, menuItems: menuMock })] }), rolePermissions: _jsx(RolePermissionsTab, { selected: featuresSelectedMock, onSelect: action('onSelect') }) })] }) }), _jsx(RightPanel, { isOpen: isNewCreditCardPanelOpen, onClose: handleCloseNewCreditCardPanel, children: _jsxs(MyProfilePanel, { children: [_jsx(MyProfileHeader, { onClose: handleCloseNewCreditCardPanel }), _jsxs(DrawerBody, { p: "0", children: [_jsx(NewCreditCardHeader, { onClick: handleCloseNewCreditCardPanel }), hasError && _jsx(CreditCardError, {}), _jsx(NewCreditCard, { hasError: hasError, onSubmit: handleError })] })] }) })] }));
17
+ return (_jsxs(_Fragment, { children: [_jsx(RightPanel, { isOpen: true, onClose: action('onCloseClick'), children: _jsxs(MyProfilePanel, { children: [_jsx(MyProfileHeader, { onClose: action('onCloseClick') }), _jsx(MyProfileBody, { isLoading: false, account: _jsxs(_Fragment, { children: [_jsx(ActiveSubscription, { nextCharge: "2024-12-01", subscriptionPrice: 36, totalStorage: 2, totalUsed: 1, availableStorage: 200, state: 'trial' }), _jsx(Divider, { width: "calc(100% - 26px)", mx: "auto" }), _jsx(MonthlyCharge, { additionalPrice: 36, monthlyCharge: 36, monthDate: "03/01/2023", nextCharge: "01/12/2024", taxPercentage: 8.5, taxValue: 3.06, subtotal: 36.0 }), _jsx(CancelAccount, { label: "Contact Homefile", onClick: action('onCancelAccountClick') })] }), details: _jsxs(_Fragment, { children: [_jsx(UserDetails, { email: "gary.edmunds@gmail.com", firstName: "Gary", lastName: "Edmunds", onSave: action('onSaveClick'), bg: "#4CC35A" }), _jsx(TwoFactorSetting, { email: "gary.edmunds@gmail.com", sms: "2032409108", onChange: action('on2FAChangeClick'), onSave: action('onSaveClick'), defaultValue: "email", twoFactor: 'active' }), _jsx(HomiSms, { defaultEnabled: true, defaultSmsEnabled: true, sms: "2032409108", onChange: action('onHomiSmsChange'), onSave: action('onHomiSmsSave') })] }), payment: _jsxs(Box, { bg: "lightBlue.2", h: "inherit", children: [_jsx(CreditCardContainer, { cardNumber: "1234 5678 9012 3456", brand: "visa", onAddCard: action('onAddCard'), onDeleteCard: handleOpenNewCreditCardPanel, onSubmit: (data) => action('onDeleteCard')(data), cardHolder: "Gary Edmunds", cvv: "123", expirationMonth: "12", expirationYear: "2024" }), _jsx(PaymentReceipts, { receipts: receiptsMock, menuItems: menuMock })] }), rolePermissions: _jsx(RolePermissionsTab, { selected: featuresSelectedMock, onSelect: action('onSelect') }) })] }) }), _jsx(RightPanel, { isOpen: isNewCreditCardPanelOpen, onClose: handleCloseNewCreditCardPanel, children: _jsxs(MyProfilePanel, { children: [_jsx(MyProfileHeader, { onClose: handleCloseNewCreditCardPanel }), _jsxs(DrawerBody, { p: "0", children: [_jsx(NewCreditCardHeader, { onClick: handleCloseNewCreditCardPanel }), hasError && _jsx(CreditCardError, {}), _jsx(NewCreditCard, { hasError: hasError, onSubmit: handleError })] })] }) })] }));
18
18
  };
@@ -0,0 +1,18 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { HomiSmsI } from '../../../interfaces';
3
+ declare const _default: Meta<HomiSmsI>;
4
+ export default _default;
5
+ export declare const HomiSmsEnabledComponent: {
6
+ (args: HomiSmsI): import("react/jsx-runtime").JSX.Element;
7
+ args: {
8
+ defaultEnabled: boolean;
9
+ sms: string;
10
+ };
11
+ };
12
+ export declare const HomiSmsDisabledComponent: {
13
+ (args: HomiSmsI): import("react/jsx-runtime").JSX.Element;
14
+ args: {
15
+ defaultEnabled: boolean;
16
+ sms: string;
17
+ };
18
+ };
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from '@chakra-ui/react';
3
+ import { action } from '@storybook/addon-actions';
4
+ import { HomiSms } from '../../../components';
5
+ export default {
6
+ title: 'Components/MyProfile/Details',
7
+ component: HomiSms,
8
+ args: {
9
+ onChange: (form) => action('onChange')(form),
10
+ onSave: (form) => action('onSave')(form),
11
+ },
12
+ };
13
+ export const HomiSmsEnabledComponent = (args) => (_jsx(Box, { w: ['full', 'md'], p: "base", children: _jsx(HomiSms, Object.assign({}, args)) }));
14
+ HomiSmsEnabledComponent.args = {
15
+ defaultEnabled: true,
16
+ sms: '512.806.5011',
17
+ };
18
+ export const HomiSmsDisabledComponent = (args) => (_jsx(HomiSmsEnabledComponent, Object.assign({}, args)));
19
+ HomiSmsDisabledComponent.args = {
20
+ defaultEnabled: false,
21
+ sms: '512.806.5011',
22
+ };
@@ -2,12 +2,7 @@ import { Meta } from '@storybook/react';
2
2
  import { TwoFactorSettingI } from '../../../interfaces';
3
3
  declare const _default: Meta<TwoFactorSettingI>;
4
4
  export default _default;
5
- export declare const TwoFactorActiveComponent: {
6
- (args: TwoFactorSettingI): import("react/jsx-runtime").JSX.Element;
7
- args: {
8
- twoFactor: string;
9
- };
10
- };
5
+ export declare const TwoFactorActiveComponent: (args: TwoFactorSettingI) => import("react/jsx-runtime").JSX.Element;
11
6
  export declare const TwoFactorInactiveComponent: {
12
7
  (args: TwoFactorSettingI): import("react/jsx-runtime").JSX.Element;
13
8
  args: {
@@ -6,15 +6,13 @@ export default {
6
6
  title: 'Components/MyProfile/Details',
7
7
  component: TwoFactorSetting,
8
8
  args: {
9
+ twoFactor: 'active',
9
10
  onSave: (form) => action('onSave')(form),
10
11
  },
11
12
  };
12
13
  export const TwoFactorActiveComponent = (args) => {
13
14
  return (_jsx(Box, { w: ['full', 'md'], p: "base", children: _jsx(TwoFactorSetting, Object.assign({}, args)) }));
14
15
  };
15
- TwoFactorActiveComponent.args = {
16
- twoFactor: 'active',
17
- };
18
16
  export const TwoFactorInactiveComponent = (args) => (_jsx(TwoFactorActiveComponent, Object.assign({}, args)));
19
17
  TwoFactorInactiveComponent.args = {
20
18
  twoFactor: undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.41.0",
3
+ "version": "2.42.0",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",