@homefile/components-v2 2.7.26 → 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.
- package/dist/components/myProfile/ProfilePaymentTab.js +2 -1
- package/dist/components/myProfile/payment/CreditCardContainer.js +2 -1
- package/dist/stories/myProfile/ProfilePaymentTab.stories.d.ts +8 -5
- package/dist/stories/myProfile/ProfilePaymentTab.stories.js +7 -4
- package/package.json +1 -1
- package/src/components/myProfile/ProfilePaymentTab.tsx +13 -14
- package/src/components/myProfile/payment/CreditCardContainer.tsx +13 -10
- package/src/stories/myProfile/ProfilePaymentTab.stories.tsx +8 -5
|
@@ -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 === null || paymentMethod === void 0 ? void 0 : paymentMethod.
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
@@ -11,20 +11,19 @@ export const ProfilePaymentTab = ({
|
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
{
|
|
26
|
-
<Box bg={
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 {
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
handleNewCard: action('handleAddCard'),
|
|
23
|
+
handleDelete: action('handleDeleteCard'),
|
|
24
|
+
paymentMethod: {
|
|
25
|
+
brand: 'visa',
|
|
26
|
+
number: '1234',
|
|
27
|
+
isPaymentMethodValid: true,
|
|
28
|
+
},
|
|
26
29
|
}
|