@homefile/components-v2 2.7.23 → 2.7.24

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 { MyProfileContentI } from '../../interfaces';
2
- export declare const MyProfileContent: ({ user, payment, plans, onSubmit, handleClose, isLoading }: MyProfileContentI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MyProfileContent: ({ user, payment, plans, onSubmit, handleClose, isLoading, }: MyProfileContentI) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { t } from 'i18next';
3
- import { DrawerBody, DrawerContent, DrawerFooter, DrawerHeader, } from '@chakra-ui/react';
3
+ import { DrawerBody, DrawerContent, DrawerFooter, DrawerHeader, Center, } from '@chakra-ui/react';
4
4
  import { Profile } from '../../assets/images';
5
5
  import { PanelHeader, TabsHeader, ProfileDetailsTab, ProfileAccountTab, ProfilePaymentTab, FooterDrawer, FooterButtons, } from '..';
6
6
  import { useMyProfileContent } from '../../hooks';
7
- import BeatLoader from "react-spinners/BeatLoader";
8
- import { Center } from "@chakra-ui/react";
9
- export const MyProfileContent = ({ user, payment, plans, onSubmit, handleClose, isLoading }) => {
7
+ import BeatLoader from 'react-spinners/BeatLoader';
8
+ export const MyProfileContent = ({ user, payment, plans, onSubmit, handleClose, isLoading, }) => {
10
9
  const { handlePlanChange, handleSubmit } = useMyProfileContent({
11
10
  user,
12
11
  plans,
@@ -19,17 +18,17 @@ export const MyProfileContent = ({ user, payment, plans, onSubmit, handleClose,
19
18
  },
20
19
  {
21
20
  label: t('myProfile.tabs.tab3'),
22
- component: _jsx(ProfilePaymentTab, Object.assign({}, payment, { isStandAlone: false, handleAddCard: () => { } })),
21
+ component: _jsx(ProfilePaymentTab, Object.assign({}, payment)),
23
22
  },
24
23
  {
25
24
  label: t('myProfile.tabs.tab2'),
26
25
  component: _jsx(ProfileAccountTab, Object.assign({}, plans, { onChange: handlePlanChange })),
27
- }
26
+ },
28
27
  ];
29
- return (_jsxs(DrawerContent, { bg: "lightBlue.1", p: "0", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: handleClose, icon: Profile, title: t('myProfile.title') }) }), _jsx(DrawerBody, { p: "0", mb: "104px", children: isLoading ? (_jsx(Center, { h: "4rem", bg: "neutral.white", children: _jsx(BeatLoader, { color: "gray", size: 8 }) })) : (_jsx(TabsHeader, { tabList: tabs })) }), _jsx(DrawerFooter, { p: "0", zIndex: "dropdown", children: _jsx(FooterDrawer, { children: _jsx(FooterButtons, { button1: {
28
+ return (_jsxs(DrawerContent, { bg: "lightBlue.1", p: "0", children: [_jsx(DrawerHeader, { p: "0", children: _jsx(PanelHeader, { handleCloseButton: handleClose, icon: Profile, title: t('myProfile.title') }) }), _jsx(DrawerBody, { p: "0", mb: "104px", children: isLoading ? (_jsx(Center, { h: "4rem", bg: "neutral.white", children: _jsx(BeatLoader, { color: "gray", size: 8 }) })) : (_jsx(TabsHeader, { tabList: tabs })) }), _jsx(DrawerFooter, { p: "0", zIndex: "dropdown", children: _jsx(FooterDrawer, { isOpen: true, children: _jsx(FooterButtons, { button1: {
30
29
  buttonStyle: 'primaryFooter',
31
30
  isDisabled: false,
32
31
  label: 'save',
33
32
  onClick: handleSubmit,
34
- } }), isOpen: true }) })] }));
33
+ } }) }) })] }));
35
34
  };
@@ -1,2 +1,2 @@
1
1
  import { ProfilePaymentTabI } from '../../interfaces';
2
- export declare const ProfilePaymentTab: ({ paymentMethod, receipts, handleDelete, isStandAlone, handleAddCard, handleNewCard, buttonLabel, }: ProfilePaymentTabI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ProfilePaymentTab: ({ paymentMethod, receipts, handleDelete, handleNewCard, }: ProfilePaymentTabI) => import("react/jsx-runtime").JSX.Element;
@@ -1,24 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect } from 'react';
3
- import { AddCreditCard, MyProfileReceipts, CreditCardContainer, } from '..';
4
- import { usePaymentMethod } from '../../hooks';
5
- import { Button, Flex } from '@chakra-ui/react';
6
- export const ProfilePaymentTab = ({ paymentMethod, receipts, handleDelete, isStandAlone, handleAddCard, handleNewCard, buttonLabel, }) => {
7
- const [hasSavedCreditCard, updateSavedCard] = useState(false);
8
- const { handleSubmit } = usePaymentMethod(handleAddCard);
9
- useEffect(() => {
10
- if (paymentMethod.number) {
11
- updateSavedCard(true);
12
- }
13
- else {
14
- updateSavedCard(false);
15
- }
16
- }, [paymentMethod]);
2
+ import { MyProfileReceipts, CreditCardContainer } from '..';
3
+ export const ProfilePaymentTab = ({ paymentMethod, receipts, handleDelete, handleNewCard, }) => {
17
4
  const hasReceipts = receipts.length > 0;
18
5
  const { brand, number, isPaymentMethodValid } = paymentMethod || {
19
6
  brand: '',
20
7
  number: '',
21
8
  isPaymentMethodValid: false,
22
9
  };
23
- return hasSavedCreditCard ? (_jsxs(_Fragment, { children: [_jsx(CreditCardContainer, { brand: brand, cardNumber: number, hasError: !isPaymentMethodValid, onAddCard: handleNewCard, onDeleteCard: handleDelete, onSubmit: () => null, cardHolder: '', cvv: '', expirationMonth: '', expirationYear: '' }), hasReceipts && _jsx(MyProfileReceipts, { receipts })] })) : (_jsxs(Flex, { flexDir: 'column', w: "100%", alignItems: 'center', children: [_jsx(AddCreditCard, {}), isStandAlone && (_jsx(Flex, { justifyContent: 'center', alignItems: "center", mt: '1rem', children: _jsx(Button, { variant: 'primaryFooter', onClick: handleSubmit, w: 'fit-content', children: buttonLabel }) }))] }));
10
+ return (_jsxs(_Fragment, { children: [_jsx(CreditCardContainer, { brand: brand, cardNumber: number, hasError: !isPaymentMethodValid, onAddCard: handleNewCard, onDeleteCard: handleDelete, onSubmit: () => null, cardHolder: '', cvv: '', expirationMonth: '', expirationYear: '' }), hasReceipts && _jsx(MyProfileReceipts, { receipts })] }));
24
11
  };
@@ -8,11 +8,8 @@ export interface MyProfileReceiptsI {
8
8
  id: string;
9
9
  }
10
10
  export interface ProfilePaymentTabI {
11
- paymentMethod: PaymentMethodI;
11
+ paymentMethod?: PaymentMethodI;
12
12
  receipts: MyProfileReceiptsI[];
13
13
  handleDelete: () => void;
14
- isStandAlone: boolean;
15
- handleAddCard: (form: any) => void;
16
14
  handleNewCard: () => void;
17
- buttonLabel: string;
18
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.7.23",
3
+ "version": "2.7.24",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -4,6 +4,7 @@ import {
4
4
  DrawerContent,
5
5
  DrawerFooter,
6
6
  DrawerHeader,
7
+ Center,
7
8
  } from '@chakra-ui/react'
8
9
  import { Profile } from '@/assets/images'
9
10
  import {
@@ -17,8 +18,7 @@ import {
17
18
  } from '@/components'
18
19
  import { MyProfileContentI } from '@/interfaces'
19
20
  import { useMyProfileContent } from '@/hooks'
20
- import BeatLoader from "react-spinners/BeatLoader";
21
- import { Center } from "@chakra-ui/react";
21
+ import BeatLoader from 'react-spinners/BeatLoader'
22
22
 
23
23
  export const MyProfileContent = ({
24
24
  user,
@@ -26,9 +26,9 @@ export const MyProfileContent = ({
26
26
  plans,
27
27
  onSubmit,
28
28
  handleClose,
29
- isLoading
29
+ isLoading,
30
30
  }: MyProfileContentI) => {
31
- const { handlePlanChange,handleSubmit } = useMyProfileContent({
31
+ const { handlePlanChange, handleSubmit } = useMyProfileContent({
32
32
  user,
33
33
  plans,
34
34
  onSubmit,
@@ -41,12 +41,12 @@ export const MyProfileContent = ({
41
41
  },
42
42
  {
43
43
  label: t('myProfile.tabs.tab3'),
44
- component: <ProfilePaymentTab {...payment} isStandAlone={false} handleAddCard={() => {}} />,
44
+ component: <ProfilePaymentTab {...payment} />,
45
45
  },
46
46
  {
47
47
  label: t('myProfile.tabs.tab2'),
48
48
  component: <ProfileAccountTab {...plans} onChange={handlePlanChange} />,
49
- }
49
+ },
50
50
  ]
51
51
 
52
52
  return (
@@ -59,30 +59,25 @@ export const MyProfileContent = ({
59
59
  />
60
60
  </DrawerHeader>
61
61
  <DrawerBody p="0" mb="104px">
62
- {
63
- isLoading ? (
64
- <Center h="4rem" bg="neutral.white">
65
- <BeatLoader color="gray" size={8} />
66
- </Center>
67
- ) : (
68
- <TabsHeader tabList={tabs} />
69
- )
70
- }
62
+ {isLoading ? (
63
+ <Center h="4rem" bg="neutral.white">
64
+ <BeatLoader color="gray" size={8} />
65
+ </Center>
66
+ ) : (
67
+ <TabsHeader tabList={tabs} />
68
+ )}
71
69
  </DrawerBody>
72
70
  <DrawerFooter p="0" zIndex="dropdown">
73
- <FooterDrawer
74
- children={
75
- <FooterButtons
76
- button1={{
77
- buttonStyle: 'primaryFooter',
78
- isDisabled: false,
79
- label: 'save',
80
- onClick: handleSubmit,
81
- }}
82
- />
83
- }
84
- isOpen
85
- />
71
+ <FooterDrawer isOpen>
72
+ <FooterButtons
73
+ button1={{
74
+ buttonStyle: 'primaryFooter',
75
+ isDisabled: false,
76
+ label: 'save',
77
+ onClick: handleSubmit,
78
+ }}
79
+ />
80
+ </FooterDrawer>
86
81
  </DrawerFooter>
87
82
  </DrawerContent>
88
83
  )
@@ -1,34 +1,12 @@
1
- import { useState, useEffect } from 'react'
2
- import {
3
- AddCreditCard,
4
- MyProfileReceipts,
5
- CreditCardContainer,
6
- } from '@/components'
1
+ import { MyProfileReceipts, CreditCardContainer } from '@/components'
7
2
  import { ProfilePaymentTabI } from '@/interfaces'
8
- import { usePaymentMethod } from '@/hooks'
9
- import { Button, Flex } from '@chakra-ui/react'
10
3
 
11
4
  export const ProfilePaymentTab = ({
12
5
  paymentMethod,
13
6
  receipts,
14
7
  handleDelete,
15
- isStandAlone,
16
- handleAddCard,
17
8
  handleNewCard,
18
- buttonLabel,
19
9
  }: ProfilePaymentTabI) => {
20
- const [hasSavedCreditCard, updateSavedCard] = useState(false)
21
-
22
- const { handleSubmit } = usePaymentMethod(handleAddCard)
23
-
24
- useEffect(() => {
25
- if (paymentMethod.number) {
26
- updateSavedCard(true)
27
- } else {
28
- updateSavedCard(false)
29
- }
30
- }, [paymentMethod])
31
-
32
10
  const hasReceipts = receipts.length > 0
33
11
  const { brand, number, isPaymentMethodValid } = paymentMethod || {
34
12
  brand: '',
@@ -36,7 +14,7 @@ export const ProfilePaymentTab = ({
36
14
  isPaymentMethodValid: false,
37
15
  }
38
16
 
39
- return hasSavedCreditCard ? (
17
+ return (
40
18
  <>
41
19
  <CreditCardContainer
42
20
  brand={brand}
@@ -52,20 +30,5 @@ export const ProfilePaymentTab = ({
52
30
  />
53
31
  {hasReceipts && <MyProfileReceipts {...{ receipts }} />}
54
32
  </>
55
- ) : (
56
- <Flex flexDir={'column'} w="100%" alignItems={'center'}>
57
- <AddCreditCard />
58
- {isStandAlone && (
59
- <Flex justifyContent={'center'} alignItems="center" mt={'1rem'}>
60
- <Button
61
- variant={'primaryFooter'}
62
- onClick={handleSubmit}
63
- w={'fit-content'}
64
- >
65
- {buttonLabel}
66
- </Button>
67
- </Flex>
68
- )}
69
- </Flex>
70
33
  )
71
34
  }
@@ -10,11 +10,8 @@ export interface MyProfileReceiptsI {
10
10
  }
11
11
 
12
12
  export interface ProfilePaymentTabI {
13
- paymentMethod: PaymentMethodI
13
+ paymentMethod?: PaymentMethodI
14
14
  receipts: MyProfileReceiptsI[]
15
15
  handleDelete: () => void
16
- isStandAlone: boolean
17
- handleAddCard: (form: any) => void
18
16
  handleNewCard: () => void
19
- buttonLabel: string
20
17
  }