@homefile/components-v2 2.7.25 → 2.7.27

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,6 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MyProfileReceipts, CreditCardContainer } from '..';
3
3
  export const ProfilePaymentTab = ({ paymentMethod, receipts, handleDelete, handleNewCard, }) => {
4
+ var _a, _b;
4
5
  const hasReceipts = receipts.length > 0;
5
- return (_jsxs(_Fragment, { children: [paymentMethod && (_jsx(CreditCardContainer, { brand: paymentMethod.brand, cardNumber: paymentMethod.number, hasError: !paymentMethod.isPaymentMethodValid, onAddCard: handleNewCard, onDeleteCard: handleDelete, onSubmit: () => null, cardHolder: '', cvv: '', expirationMonth: '', expirationYear: '' })), hasReceipts && _jsx(MyProfileReceipts, { receipts })] }));
6
+ return (_jsxs(_Fragment, { children: [_jsx(CreditCardContainer, { brand: (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.brand) !== null && _a !== void 0 ? _a : '', cardNumber: (_b = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.number) !== null && _b !== void 0 ? _b : '', hasError: !(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.isPaymentMethodValid), onAddCard: handleNewCard, onDeleteCard: handleDelete, onSubmit: () => null, cardHolder: '', cvv: '', expirationMonth: '', expirationYear: '' }), hasReceipts && _jsx(MyProfileReceipts, { receipts })] }));
6
7
  };
@@ -16,5 +16,6 @@ import { CreditCard, CreditCardError, LeftButtonAnimated, PaymentFormProvider, }
16
16
  export const CreditCardContainer = (_a) => {
17
17
  var { brand, hasError = false, onAddCard, onDeleteCard, onSubmit = () => null, cardNumber, showEdition = false } = _a, props = __rest(_a, ["brand", "hasError", "onAddCard", "onDeleteCard", "onSubmit", "cardNumber", "showEdition"]);
18
18
  const formAttributes = Object.assign({ cardNumber }, props);
19
- return (_jsxs(_Fragment, { children: [hasError && _jsx(CreditCardError, {}), _jsxs(Box, { bg: hasError ? 'error.1' : 'lightGreen.1', w: "100%", children: [_jsxs(Flex, { justify: "space-between", w: "full", pt: "base", align: "center", children: [_jsx(Text, { variant: "home", textTransform: "uppercase", pl: "base", children: t('myProfile.payment.activePayment') }), _jsx(LeftButtonAnimated, { onClick: onAddCard, label: t('myProfile.payment.addCrediCard'), marginLeft: "auto", fontSize: "sm", width: "11" })] }), _jsx(Box, { py: "6", px: "base", children: _jsx(CreditCard, { brand, cardNumber, hasError, showEdition, onClick: onDeleteCard, children: showEdition && (_jsx(PaymentFormProvider, Object.assign({}, formAttributes, { onSubmit: onSubmit }))) }) })] })] }));
19
+ const error = hasError && cardNumber;
20
+ return (_jsxs(_Fragment, { children: [error && _jsx(CreditCardError, {}), _jsxs(Box, { bg: error ? 'error.1' : 'lightGreen.1', w: "100%", children: [_jsxs(Flex, { justify: "space-between", w: "full", pt: "base", align: "center", children: [_jsx(Text, { variant: "home", textTransform: "uppercase", pl: "base", children: t('myProfile.payment.activePayment') }), _jsx(LeftButtonAnimated, { onClick: onAddCard, label: t('myProfile.payment.addCrediCard'), marginLeft: "auto", fontSize: "sm", width: "11" })] }), _jsx(Box, { py: "6", px: "base", children: cardNumber && (_jsx(CreditCard, { brand, cardNumber, hasError, showEdition, onClick: onDeleteCard, children: showEdition && (_jsx(PaymentFormProvider, Object.assign({}, formAttributes, { onSubmit: onSubmit }))) })) })] })] }));
20
21
  };
@@ -1,14 +1,17 @@
1
1
  import { Meta } from '@storybook/react';
2
- import { PaymentMethodI, ProfilePaymentTabI } from '../../interfaces';
2
+ import { ProfilePaymentTabI } from '../../interfaces';
3
3
  declare const _default: Meta<ProfilePaymentTabI>;
4
4
  export default _default;
5
5
  export declare const ProfilePaymentTabComponent: {
6
6
  (props: ProfilePaymentTabI): import("react/jsx-runtime").JSX.Element;
7
7
  args: {
8
- paymentMethod: PaymentMethodI;
9
8
  receipts: never[];
10
- isStandAlone: boolean;
11
- buttonLabel: string;
12
- handleAddCard: import("@storybook/addon-actions").HandlerFunction;
9
+ handleNewCard: import("@storybook/addon-actions").HandlerFunction;
10
+ handleDelete: import("@storybook/addon-actions").HandlerFunction;
11
+ paymentMethod: {
12
+ brand: string;
13
+ number: string;
14
+ isPaymentMethodValid: boolean;
15
+ };
13
16
  };
14
17
  };
@@ -10,9 +10,12 @@ export const ProfilePaymentTabComponent = (props) => {
10
10
  return (_jsx(Box, { w: ['full', 'md'], bg: "white", p: "base", children: _jsx(ProfilePaymentTab, Object.assign({}, props)) }));
11
11
  };
12
12
  ProfilePaymentTabComponent.args = {
13
- paymentMethod: {},
14
13
  receipts: [],
15
- isStandAlone: true,
16
- buttonLabel: 'Save',
17
- handleAddCard: action('handleAddCard'),
14
+ handleNewCard: action('handleAddCard'),
15
+ handleDelete: action('handleDeleteCard'),
16
+ paymentMethod: {
17
+ brand: 'visa',
18
+ number: '1234',
19
+ isPaymentMethodValid: true,
20
+ },
18
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.7.25",
3
+ "version": "2.7.27",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -11,20 +11,19 @@ export const ProfilePaymentTab = ({
11
11
 
12
12
  return (
13
13
  <>
14
- {paymentMethod && (
15
- <CreditCardContainer
16
- brand={paymentMethod.brand}
17
- cardNumber={paymentMethod.number}
18
- hasError={!paymentMethod.isPaymentMethodValid}
19
- onAddCard={handleNewCard}
20
- onDeleteCard={handleDelete}
21
- onSubmit={() => null}
22
- cardHolder={''}
23
- cvv={''}
24
- expirationMonth={''}
25
- expirationYear={''}
26
- />
27
- )}
14
+ <CreditCardContainer
15
+ brand={paymentMethod?.brand ?? ''}
16
+ cardNumber={paymentMethod?.number ?? ''}
17
+ hasError={!paymentMethod?.isPaymentMethodValid}
18
+ onAddCard={handleNewCard}
19
+ onDeleteCard={handleDelete}
20
+ onSubmit={() => null}
21
+ cardHolder={''}
22
+ cvv={''}
23
+ expirationMonth={''}
24
+ expirationYear={''}
25
+ />
26
+
28
27
  {hasReceipts && <MyProfileReceipts {...{ receipts }} />}
29
28
  </>
30
29
  )
@@ -19,11 +19,12 @@ export const CreditCardContainer = ({
19
19
  ...props
20
20
  }: CreditCardContainerI) => {
21
21
  const formAttributes = { cardNumber, ...props }
22
+ const error = hasError && cardNumber
22
23
 
23
24
  return (
24
25
  <>
25
- {hasError && <CreditCardError />}
26
- <Box bg={hasError ? 'error.1' : 'lightGreen.1'} w="100%">
26
+ {error && <CreditCardError />}
27
+ <Box bg={error ? 'error.1' : 'lightGreen.1'} w="100%">
27
28
  <Flex justify="space-between" w="full" pt="base" align="center">
28
29
  <Text variant="home" textTransform="uppercase" pl="base">
29
30
  {t('myProfile.payment.activePayment')}
@@ -37,14 +38,16 @@ export const CreditCardContainer = ({
37
38
  />
38
39
  </Flex>
39
40
  <Box py="6" px="base">
40
- <CreditCard
41
- {...{ brand, cardNumber, hasError, showEdition }}
42
- onClick={onDeleteCard}
43
- >
44
- {showEdition && (
45
- <PaymentFormProvider {...formAttributes} onSubmit={onSubmit} />
46
- )}
47
- </CreditCard>
41
+ {cardNumber && (
42
+ <CreditCard
43
+ {...{ brand, cardNumber, hasError, showEdition }}
44
+ onClick={onDeleteCard}
45
+ >
46
+ {showEdition && (
47
+ <PaymentFormProvider {...formAttributes} onSubmit={onSubmit} />
48
+ )}
49
+ </CreditCard>
50
+ )}
48
51
  </Box>
49
52
  </Box>
50
53
  </>
@@ -1,7 +1,7 @@
1
1
  import { Meta } from '@storybook/react'
2
2
  import { Box } from '@chakra-ui/react'
3
3
  import { ProfilePaymentTab } from '@/components'
4
- import { PaymentMethodI, ProfilePaymentTabI } from '@/interfaces'
4
+ import { ProfilePaymentTabI } from '@/interfaces'
5
5
  import { action } from '@storybook/addon-actions'
6
6
 
7
7
  export default {
@@ -18,9 +18,12 @@ export const ProfilePaymentTabComponent = (props: ProfilePaymentTabI) => {
18
18
  }
19
19
 
20
20
  ProfilePaymentTabComponent.args = {
21
- paymentMethod: {} as PaymentMethodI,
22
21
  receipts: [],
23
- isStandAlone: true,
24
- buttonLabel: 'Save',
25
- handleAddCard: action('handleAddCard'),
22
+ handleNewCard: action('handleAddCard'),
23
+ handleDelete: action('handleDeleteCard'),
24
+ paymentMethod: {
25
+ brand: 'visa',
26
+ number: '1234',
27
+ isPaymentMethodValid: true,
28
+ },
26
29
  }