contentoh-components-library 21.4.28 → 21.4.30
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/atoms/Avatar/index.js +2 -3
- package/dist/components/atoms/Card/index.js +5 -46
- package/dist/components/atoms/Card/styles.js +1 -3
- package/dist/components/atoms/CheckBox/index.js +2 -7
- package/dist/components/atoms/CheckBox/styles.js +1 -1
- package/dist/components/atoms/InputFormatter/styles.js +1 -1
- package/dist/components/atoms/SliderToolTip/styles.js +1 -1
- package/dist/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/dist/components/molecules/HeaderTop/index.js +11 -68
- package/dist/components/molecules/TagAndInput/index.js +1 -1
- package/dist/components/organisms/Chat/Chat.stories.js +8 -27
- package/dist/components/organisms/Chat/ContainerItems/index.js +3 -19
- package/dist/components/organisms/Chat/ContainerItems/styles.js +1 -1
- package/dist/components/organisms/Chat/ContentChat/index.js +197 -350
- package/dist/components/organisms/Chat/Footer/index.js +39 -48
- package/dist/components/organisms/Chat/index.js +4 -49
- package/dist/components/organisms/Chat/styles.js +1 -1
- package/dist/components/organisms/FullProductNameHeader/index.js +2 -2
- package/dist/components/organisms/Modal/styles.js +1 -1
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +4 -6
- package/dist/components/pages/ProviderProductEdition/index.js +142 -117
- package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +3 -7
- package/dist/components/pages/RetailerProductEdition/index.js +274 -276
- package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/utils.js +2 -61
- package/dist/index.js +52 -247
- package/package.json +1 -4
- package/src/components/atoms/Avatar/index.js +2 -8
- package/src/components/atoms/Card/index.js +2 -35
- package/src/components/atoms/Card/styles.js +5 -41
- package/src/components/atoms/CheckBox/index.js +1 -4
- package/src/components/atoms/CheckBox/styles.js +0 -2
- package/src/components/atoms/InputFormatter/styles.js +1 -2
- package/src/components/atoms/SliderToolTip/styles.js +1 -1
- package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/src/components/molecules/HeaderTop/index.js +6 -52
- package/src/components/molecules/TagAndInput/index.js +8 -10
- package/src/components/organisms/Chat/Chat.stories.js +7 -27
- package/src/components/organisms/Chat/ContainerItems/index.js +2 -18
- package/src/components/organisms/Chat/ContainerItems/styles.js +2 -14
- package/src/components/organisms/Chat/ContentChat/index.js +12 -88
- package/src/components/organisms/Chat/Footer/index.js +0 -11
- package/src/components/organisms/Chat/index.js +4 -46
- package/src/components/organisms/Chat/styles.js +0 -4
- package/src/components/organisms/FullProductNameHeader/index.js +1 -1
- package/src/components/organisms/Modal/styles.js +1 -4
- package/src/components/organisms/OrderDetail/utils/Table/utils.js +16 -6
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +4 -6
- package/src/components/pages/ProviderProductEdition/index.js +129 -97
- package/src/components/pages/ProviderProductEdition/styles.js +1 -5
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +2 -6
- package/src/components/pages/RetailerProductEdition/index.js +142 -111
- package/src/components/pages/RetailerProductEdition/styles.js +0 -4
- package/src/components/pages/RetailerProductEdition/utils.js +0 -37
- package/src/index.js +0 -15
- package/.env.development +0 -39
- package/.env.production +0 -36
- package/dist/assets/fonts/roboto/LICENSE.txt +0 -202
- package/dist/components/atoms/ImageCarousel/ImgeSlider.stories.js +0 -90
- package/dist/components/atoms/ImageCarousel/index.js +0 -120
- package/dist/components/atoms/ImageCarousel/styles.js +0 -18
- package/dist/components/atoms/PercentTag/PercentTag.stories.js +0 -31
- package/dist/components/atoms/PercentTag/index.js +0 -23
- package/dist/components/atoms/PercentTag/styles.js +0 -22
- package/dist/components/atoms/RatingStars/RatingStars.stories.js +0 -30
- package/dist/components/atoms/RatingStars/index.js +0 -53
- package/dist/components/atoms/RatingStars/styles.js +0 -18
- package/dist/components/atoms/RetailerCatalog/RetailerCatalog.stories.js +0 -48
- package/dist/components/atoms/RetailerCatalog/index.js +0 -69
- package/dist/components/atoms/RetailerCatalog/styles.js +0 -20
- package/dist/components/atoms/RetailerOption/RetailerOption.stories.js +0 -33
- package/dist/components/atoms/RetailerOption/index.js +0 -62
- package/dist/components/atoms/RetailerOption/styles.js +0 -20
- package/dist/components/atoms/RetailersList/RetailersList.stories.js +0 -45
- package/dist/components/atoms/RetailersList/index.js +0 -46
- package/dist/components/atoms/RetailersList/styles.js +0 -18
- package/dist/components/atoms/UserCatalog/UserCatalog.stories.js +0 -73
- package/dist/components/atoms/UserCatalog/index.js +0 -101
- package/dist/components/atoms/UserCatalog/styles.js +0 -18
- package/dist/components/atoms/UserOption/UserOption.stories.js +0 -40
- package/dist/components/atoms/UserOption/index.js +0 -130
- package/dist/components/atoms/UserOption/styles.js +0 -20
- package/dist/components/atoms/UserSelector/UserSelector.stories.js +0 -40
- package/dist/components/atoms/UserSelector/index.js +0 -98
- package/dist/components/atoms/UserSelector/styles.js +0 -32
- package/dist/components/molecules/GridItem/GridItem.stories.js +0 -123
- package/dist/components/molecules/GridItem/index.js +0 -152
- package/dist/components/molecules/GridItem/styles.js +0 -20
- package/dist/components/molecules/HeaderItem/ColumnItem.js +0 -23
- package/dist/components/molecules/HeaderItem/HeaderItem.stories.js +0 -70
- package/dist/components/molecules/HeaderItem/index.js +0 -42
- package/dist/components/molecules/HeaderItem/styles.js +0 -30
- package/dist/components/molecules/RowItem/ColumnItem.js +0 -23
- package/dist/components/molecules/RowItem/RowItem.stories.js +0 -5242
- package/dist/components/molecules/RowItem/index.js +0 -58
- package/dist/components/molecules/RowItem/styles.js +0 -30
- package/dist/components/molecules/StripeCardForm/StripeCardForm.stories.js +0 -31
- package/dist/components/molecules/StripeCardForm/index.js +0 -94
- package/dist/components/molecules/StripeCardForm/paymentForm.js +0 -191
- package/dist/components/molecules/StripeCardForm/styles.js +0 -27
- package/dist/components/molecules/StripeCardSelector/CardSelector.stories.js +0 -30
- package/dist/components/molecules/StripeCardSelector/index.js +0 -120
- package/dist/components/molecules/StripeCardSelector/styles.js +0 -22
- package/dist/components/molecules/StripeCardSelector/utils.js +0 -56
- package/dist/components/organisms/GridProducts/GridProducts.stories.js +0 -5097
- package/dist/components/organisms/GridProducts/index.js +0 -63
- package/dist/components/organisms/GridProducts/styles.js +0 -18
- package/dist/components/organisms/GridProducts/utils.js +0 -149
- package/dist/components/organisms/PanelLayout/PanelLayout.stories.js +0 -87
- package/dist/components/organisms/PanelLayout/index.js +0 -29
- package/dist/components/organisms/PanelLayout/styles.js +0 -32
- package/dist/components/organisms/SideModal/SideModal.stories.js +0 -42
- package/dist/components/organisms/SideModal/index.js +0 -72
- package/dist/components/organisms/SideModal/styles.js +0 -18
- package/src/components/atoms/ImageCarousel/ImgeSlider.stories.js +0 -76
- package/src/components/atoms/ImageCarousel/index.js +0 -103
- package/src/components/atoms/ImageCarousel/styles.js +0 -79
- package/src/components/atoms/PercentTag/PercentTag.stories.js +0 -7
- package/src/components/atoms/PercentTag/index.js +0 -9
- package/src/components/atoms/PercentTag/styles.js +0 -69
- package/src/components/atoms/RatingStars/RatingStars.stories.js +0 -10
- package/src/components/atoms/RatingStars/index.js +0 -31
- package/src/components/atoms/RatingStars/styles.js +0 -28
- package/src/components/atoms/RetailerCatalog/RetailerCatalog.stories.js +0 -36
- package/src/components/atoms/RetailerCatalog/index.js +0 -49
- package/src/components/atoms/RetailerCatalog/styles.js +0 -30
- package/src/components/atoms/RetailerOption/RetailerOption.stories.js +0 -15
- package/src/components/atoms/RetailerOption/index.js +0 -53
- package/src/components/atoms/RetailerOption/styles.js +0 -41
- package/src/components/atoms/RetailersList/RetailersList.stories.js +0 -33
- package/src/components/atoms/RetailersList/index.js +0 -20
- package/src/components/atoms/RetailersList/styles.js +0 -19
- package/src/components/atoms/UserCatalog/UserCatalog.stories.js +0 -67
- package/src/components/atoms/UserCatalog/index.js +0 -100
- package/src/components/atoms/UserCatalog/styles.js +0 -24
- package/src/components/atoms/UserOption/UserOption.stories.js +0 -25
- package/src/components/atoms/UserOption/index.js +0 -95
- package/src/components/atoms/UserOption/styles.js +0 -61
- package/src/components/atoms/UserSelector/UserSelector.stories.js +0 -25
- package/src/components/atoms/UserSelector/index.js +0 -86
- package/src/components/atoms/UserSelector/styles.js +0 -55
- package/src/components/molecules/GridItem/GridItem.stories.js +0 -126
- package/src/components/molecules/GridItem/index.js +0 -105
- package/src/components/molecules/GridItem/styles.js +0 -104
- package/src/components/molecules/HeaderItem/ColumnItem.js +0 -9
- package/src/components/molecules/HeaderItem/HeaderItem.stories.js +0 -24
- package/src/components/molecules/HeaderItem/index.js +0 -26
- package/src/components/molecules/HeaderItem/styles.js +0 -27
- package/src/components/molecules/RowItem/ColumnItem.js +0 -9
- package/src/components/molecules/RowItem/RowItem.stories.js +0 -5660
- package/src/components/molecules/RowItem/index.js +0 -45
- package/src/components/molecules/RowItem/styles.js +0 -40
- package/src/components/molecules/StripeCardForm/StripeCardForm.stories.js +0 -13
- package/src/components/molecules/StripeCardForm/index.js +0 -44
- package/src/components/molecules/StripeCardForm/paymentForm.js +0 -124
- package/src/components/molecules/StripeCardForm/styles.js +0 -75
- package/src/components/molecules/StripeCardSelector/CardSelector.stories.js +0 -12
- package/src/components/molecules/StripeCardSelector/index.js +0 -57
- package/src/components/molecules/StripeCardSelector/styles.js +0 -6
- package/src/components/molecules/StripeCardSelector/utils.js +0 -17
- package/src/components/organisms/GridProducts/GridProducts.stories.js +0 -5485
- package/src/components/organisms/GridProducts/index.js +0 -50
- package/src/components/organisms/GridProducts/styles.js +0 -14
- package/src/components/organisms/GridProducts/utils.js +0 -111
- package/src/components/organisms/PanelLayout/PanelLayout.stories.js +0 -63
- package/src/components/organisms/PanelLayout/index.js +0 -11
- package/src/components/organisms/PanelLayout/styles.js +0 -39
- package/src/components/organisms/SideModal/SideModal.stories.js +0 -23
- package/src/components/organisms/SideModal/index.js +0 -50
- package/src/components/organisms/SideModal/styles.js +0 -30
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Container } from "./styles";
|
|
2
|
-
import { ColumnItem } from "./ColumnItem";
|
|
3
|
-
import { CheckBox } from "../../atoms/CheckBox";
|
|
4
|
-
|
|
5
|
-
export const RowItem = ({
|
|
6
|
-
productsArray = [],
|
|
7
|
-
chkOnChange,
|
|
8
|
-
onGridClick,
|
|
9
|
-
chkChecked,
|
|
10
|
-
}) => {
|
|
11
|
-
return (
|
|
12
|
-
<Container>
|
|
13
|
-
{productsArray.map(({ cols, product, id }, i) => (
|
|
14
|
-
<div
|
|
15
|
-
className="row-container"
|
|
16
|
-
key={id}
|
|
17
|
-
onClick={(e) => onGridClick && onGridClick(e, product, i)}
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
className="chk-container"
|
|
21
|
-
onClick={(e) => {
|
|
22
|
-
e.stopPropagation();
|
|
23
|
-
}}
|
|
24
|
-
>
|
|
25
|
-
<CheckBox
|
|
26
|
-
id={"chk-" + id}
|
|
27
|
-
name={"chk-" + id}
|
|
28
|
-
className="chk-item"
|
|
29
|
-
onChange={(e) => chkOnChange && chkOnChange(e, product)}
|
|
30
|
-
defaultChecked={chkChecked && chkChecked(product)}
|
|
31
|
-
/>
|
|
32
|
-
</div>
|
|
33
|
-
{cols.map((col, i) => (
|
|
34
|
-
<ColumnItem
|
|
35
|
-
key={id + "-" + i}
|
|
36
|
-
element={col.name}
|
|
37
|
-
flex={col.flex}
|
|
38
|
-
minWidth={col.minWidth}
|
|
39
|
-
/>
|
|
40
|
-
))}
|
|
41
|
-
</div>
|
|
42
|
-
))}
|
|
43
|
-
</Container>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
import { FontFamily } from "../../../global-files/variables";
|
|
3
|
-
|
|
4
|
-
export const Container = styled.div`
|
|
5
|
-
height: calc(100% - 36px);
|
|
6
|
-
overflow: auto;
|
|
7
|
-
min-width: fit-content;
|
|
8
|
-
|
|
9
|
-
.row-container {
|
|
10
|
-
display: flex;
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
&:hover {
|
|
13
|
-
background-color: #fafafa;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.chk-container {
|
|
17
|
-
width: 30px;
|
|
18
|
-
display: flex;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
align-items: center;
|
|
21
|
-
.chk-item {
|
|
22
|
-
width: 16px;
|
|
23
|
-
height: 16px;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
export const Column = styled.div`
|
|
30
|
-
flex: ${({ flex }) => (flex ? flex : 1)};
|
|
31
|
-
min-width: ${({ minWidth }) => (minWidth ? minWidth : 100)}px;
|
|
32
|
-
text-align: center;
|
|
33
|
-
color: #262626;
|
|
34
|
-
font-family: ${FontFamily.Lato};
|
|
35
|
-
font-size: 12px;
|
|
36
|
-
line-height: 16px;
|
|
37
|
-
padding: 10px 5px;
|
|
38
|
-
display: flex;
|
|
39
|
-
justify-content: center;
|
|
40
|
-
`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StripeCardForm } from ".";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/molecules/StripeCardForm",
|
|
5
|
-
component: StripeCardForm,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const Template = (args) => <StripeCardForm {...args} />;
|
|
9
|
-
export const StripeCardFormDefault = Template.bind({});
|
|
10
|
-
StripeCardFormDefault.args = {
|
|
11
|
-
customerId: "cus_KuEt6R6vwmN09f",
|
|
12
|
-
jwt: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3Vwcy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q",
|
|
13
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Container } from "./styles";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { loadStripe } from "@stripe/stripe-js";
|
|
4
|
-
import { Elements } from "@stripe/react-stripe-js";
|
|
5
|
-
import { PaymentForm } from "./paymentForm";
|
|
6
|
-
import { Loading } from "../../atoms/Loading";
|
|
7
|
-
const stripeApiKey = loadStripe(`${process.env.REACT_APP_KEY_STRIPE}`);
|
|
8
|
-
|
|
9
|
-
export const StripeCardForm = ({
|
|
10
|
-
setToken,
|
|
11
|
-
setCard,
|
|
12
|
-
setStripe,
|
|
13
|
-
setModalErrorCard,
|
|
14
|
-
setMsj,
|
|
15
|
-
isSelected = false,
|
|
16
|
-
onClick,
|
|
17
|
-
}) => {
|
|
18
|
-
const [stripeLoaded, setStripeLoaded] = useState(false);
|
|
19
|
-
|
|
20
|
-
const loadStripeJS = async () => {
|
|
21
|
-
await stripeApiKey;
|
|
22
|
-
setStripeLoaded(true);
|
|
23
|
-
};
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
loadStripeJS();
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
return stripeLoaded ? (
|
|
29
|
-
<Container isSelected={isSelected} onClick={() => onClick && onClick()}>
|
|
30
|
-
<Elements stripe={stripeApiKey}>
|
|
31
|
-
<PaymentForm
|
|
32
|
-
labelForm={"Pago con tarjeta"}
|
|
33
|
-
setToken={setToken}
|
|
34
|
-
setCard={setCard}
|
|
35
|
-
setStripe={setStripe}
|
|
36
|
-
setModalErrorCard={setModalErrorCard}
|
|
37
|
-
setMsj={setMsj}
|
|
38
|
-
/>
|
|
39
|
-
</Elements>
|
|
40
|
-
</Container>
|
|
41
|
-
) : (
|
|
42
|
-
<Loading />
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { PaymentFormContainer } from "./styles";
|
|
3
|
-
import {
|
|
4
|
-
useStripe,
|
|
5
|
-
useElements,
|
|
6
|
-
CardNumberElement,
|
|
7
|
-
CardExpiryElement,
|
|
8
|
-
CardCvcElement,
|
|
9
|
-
} from "@stripe/react-stripe-js";
|
|
10
|
-
import { useEffect } from "react";
|
|
11
|
-
|
|
12
|
-
export const PaymentForm = ({
|
|
13
|
-
labelForm = "Pago con tarjeta",
|
|
14
|
-
setToken,
|
|
15
|
-
setCard,
|
|
16
|
-
setStripe,
|
|
17
|
-
setModalErrorCard,
|
|
18
|
-
setMsj,
|
|
19
|
-
}) => {
|
|
20
|
-
const stripe = useStripe();
|
|
21
|
-
const elements = useElements();
|
|
22
|
-
const [cardName, setCardName] = useState("");
|
|
23
|
-
const [valuesComplete, setValuesComplete] = useState({
|
|
24
|
-
name: false,
|
|
25
|
-
number: false,
|
|
26
|
-
cvc: false,
|
|
27
|
-
exp: false,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const handleIputChange = (event, key) => {
|
|
31
|
-
const temp = { ...valuesComplete };
|
|
32
|
-
if (key === "name") {
|
|
33
|
-
temp[key] = event?.length;
|
|
34
|
-
setValuesComplete(temp);
|
|
35
|
-
} else {
|
|
36
|
-
temp[key] = event.complete;
|
|
37
|
-
setValuesComplete(temp);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Este método crea un nuevo token que será enviado a la bd para generar una nueva tarjeta
|
|
43
|
-
*/
|
|
44
|
-
const createToken = async () => {
|
|
45
|
-
/* isNew values
|
|
46
|
-
1: is new
|
|
47
|
-
0: use card existing
|
|
48
|
-
-1: use other payment metoh */
|
|
49
|
-
let token = "";
|
|
50
|
-
token = await stripe.createToken(elements.getElement(CardNumberElement));
|
|
51
|
-
|
|
52
|
-
const { error, paymentMethod } = await stripe.createPaymentMethod({
|
|
53
|
-
type: "card",
|
|
54
|
-
card: elements.getElement(CardNumberElement),
|
|
55
|
-
billing_details: {
|
|
56
|
-
name: cardName,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
if (token.token) {
|
|
62
|
-
token = token.token.id;
|
|
63
|
-
} else {
|
|
64
|
-
setModalErrorCard && setModalErrorCard(true);
|
|
65
|
-
setMsj && setMsj(token.error.message);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
paymentMethod.isNew = 1;
|
|
69
|
-
setToken && setToken(token);
|
|
70
|
-
setCard && setCard(paymentMethod);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.log(err, error);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const valuesArray = Object.values(valuesComplete);
|
|
78
|
-
const allValuesComplete = valuesArray?.every((val) => val);
|
|
79
|
-
allValuesComplete ? createToken() : "le falta algo oiga";
|
|
80
|
-
setStripe && setStripe(stripe);
|
|
81
|
-
}, [valuesComplete]);
|
|
82
|
-
|
|
83
|
-
const handleCardNameChange = (event) => {
|
|
84
|
-
handleIputChange(event.target.value, "name");
|
|
85
|
-
setCardName(event.target.value);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<PaymentFormContainer>
|
|
90
|
-
<h2>{labelForm}</h2>
|
|
91
|
-
<div className="card-fields">
|
|
92
|
-
<div className="element card-name">
|
|
93
|
-
<label>Nombre en la tarjeta</label>
|
|
94
|
-
<input
|
|
95
|
-
className="card-input"
|
|
96
|
-
value={cardName}
|
|
97
|
-
onChange={handleCardNameChange}
|
|
98
|
-
/>
|
|
99
|
-
</div>
|
|
100
|
-
<div className="element card-number">
|
|
101
|
-
<label>No. de tarjeta</label>
|
|
102
|
-
<CardNumberElement
|
|
103
|
-
className="card-input"
|
|
104
|
-
onChange={(e) => handleIputChange(e, "number")}
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
107
|
-
<div className="element expiration-date">
|
|
108
|
-
<label>Fecha de expiración</label>
|
|
109
|
-
<CardExpiryElement
|
|
110
|
-
className="card-input"
|
|
111
|
-
onChange={(e) => handleIputChange(e, "exp")}
|
|
112
|
-
/>
|
|
113
|
-
</div>
|
|
114
|
-
<div className="element cvc-code ">
|
|
115
|
-
<label>CVC</label>
|
|
116
|
-
<CardCvcElement
|
|
117
|
-
className="card-input"
|
|
118
|
-
onChange={(e) => handleIputChange(e, "cvc")}
|
|
119
|
-
/>
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
</PaymentFormContainer>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
import { FontFamily } from "../../../global-files/variables";
|
|
3
|
-
|
|
4
|
-
export const Container = styled.div`
|
|
5
|
-
${({ isSelected }) => isSelected && `border-color: #E33AA9;`}
|
|
6
|
-
`;
|
|
7
|
-
|
|
8
|
-
export const PaymentFormContainer = styled.form`
|
|
9
|
-
padding: 20px;
|
|
10
|
-
border: 1px solid #f0f0f0;
|
|
11
|
-
border-radius: 10px;
|
|
12
|
-
|
|
13
|
-
h2 {
|
|
14
|
-
font-size: 15px;
|
|
15
|
-
line-height: 20px;
|
|
16
|
-
color: #262626;
|
|
17
|
-
font-family: ${FontFamily.RobotoMedium};
|
|
18
|
-
|
|
19
|
-
& + * {
|
|
20
|
-
margin-top: 10px;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.card-fields {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-wrap: wrap;
|
|
27
|
-
gap: 10px;
|
|
28
|
-
.element {
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
|
-
|
|
32
|
-
label {
|
|
33
|
-
color: #808080;
|
|
34
|
-
font-family: ${FontFamily.Lato};
|
|
35
|
-
font-size: 12px;
|
|
36
|
-
display: flex;
|
|
37
|
-
|
|
38
|
-
& + * {
|
|
39
|
-
margin-left: 6px;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.card-input {
|
|
44
|
-
border: 1px solid #f0f0f0 !important;
|
|
45
|
-
border-radius: 5px;
|
|
46
|
-
padding: 3px;
|
|
47
|
-
font-family: ${FontFamily.Lato};
|
|
48
|
-
font-size: 12px;
|
|
49
|
-
flex: 1;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&.card-name {
|
|
53
|
-
flex: 1 0 100%;
|
|
54
|
-
label + * {
|
|
55
|
-
margin-left: 6px;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&.card-number {
|
|
60
|
-
flex: 1 0 100%;
|
|
61
|
-
label + * {
|
|
62
|
-
margin-left: 43px;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&.expiration-date,
|
|
67
|
-
&.cvc-code {
|
|
68
|
-
flex: 1 1 49%;
|
|
69
|
-
label + * {
|
|
70
|
-
margin-left: 9px;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CardSelector } from ".";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/molecules/CardSelector",
|
|
5
|
-
component: CardSelector,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const Template = (args) => <CardSelector {...args} />;
|
|
9
|
-
export const CardSelectorDefault = Template.bind({});
|
|
10
|
-
CardSelectorDefault.args = {
|
|
11
|
-
jwt: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1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";
|
|
2
|
-
import { Container } from "./styles";
|
|
3
|
-
import { loadStripe } from "@stripe/stripe-js";
|
|
4
|
-
import { Elements } from "@stripe/react-stripe-js";
|
|
5
|
-
import { getAllCards } from "./utils";
|
|
6
|
-
import { Card } from "../../atoms/Card";
|
|
7
|
-
import { Loading } from "../../atoms/Loading";
|
|
8
|
-
const stripeApiKey = loadStripe(`${process.env.REACT_APP_KEY_STRIPE}`);
|
|
9
|
-
|
|
10
|
-
export const CardSelector = ({
|
|
11
|
-
jwt,
|
|
12
|
-
setCard,
|
|
13
|
-
setStripe,
|
|
14
|
-
isSelected = false,
|
|
15
|
-
onClick,
|
|
16
|
-
}) => {
|
|
17
|
-
const [stripeLoaded, setStripeLoaded] = useState(false);
|
|
18
|
-
const [cards, setCards] = useState([]);
|
|
19
|
-
const [selectedCard, setSelectedCard] = useState("");
|
|
20
|
-
|
|
21
|
-
const loadStripeJS = async () => {
|
|
22
|
-
await stripeApiKey;
|
|
23
|
-
setStripeLoaded(true);
|
|
24
|
-
const cardsResponse = await getAllCards(jwt);
|
|
25
|
-
setCards(cardsResponse);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
// loadStripeJS();
|
|
30
|
-
stripeApiKey.then(() => {
|
|
31
|
-
setStripeLoaded(true);
|
|
32
|
-
getAllCards(jwt).then((cardsResponse) => {
|
|
33
|
-
setCards(cardsResponse);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
return stripeLoaded ? (
|
|
39
|
-
<Container isSelected={isSelected} onClick={() => onClick && onClick()}>
|
|
40
|
-
<h2>Tarjetas guardadas</h2>
|
|
41
|
-
<Elements stripe={stripeApiKey}>
|
|
42
|
-
{cards.map((card) => (
|
|
43
|
-
<Card
|
|
44
|
-
key={card.id}
|
|
45
|
-
card={card}
|
|
46
|
-
selectedCard={selectedCard}
|
|
47
|
-
setSelectedCard={setSelectedCard}
|
|
48
|
-
setCard={setCard}
|
|
49
|
-
setStripe={setStripe}
|
|
50
|
-
/>
|
|
51
|
-
))}
|
|
52
|
-
</Elements>
|
|
53
|
-
</Container>
|
|
54
|
-
) : (
|
|
55
|
-
<Loading />
|
|
56
|
-
);
|
|
57
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
|
|
3
|
-
export const getAllCards = async (jwt) => {
|
|
4
|
-
try {
|
|
5
|
-
const response = await axios({
|
|
6
|
-
method: "get",
|
|
7
|
-
url: `${process.env.REACT_APP_CARDS_ENDPOINT}`,
|
|
8
|
-
headers: {
|
|
9
|
-
Authorization: jwt,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
const stripeCards = JSON.parse(response.data.body).data;
|
|
13
|
-
return stripeCards;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.log(error);
|
|
16
|
-
}
|
|
17
|
-
};
|