contentoh-components-library 21.3.81 → 21.3.83
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/.env.development +0 -5
- package/.env.production +0 -3
- package/dist/components/atoms/ButtonV2/styles.js +1 -1
- 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 -4
- package/dist/components/atoms/GeneralInput/index.js +20 -24
- package/dist/components/atoms/InputFormatter/index.js +16 -14
- package/dist/components/atoms/InputFormatter/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/TabsMenu/index.js +48 -22
- package/dist/components/molecules/TagAndInput/index.js +3 -1
- package/dist/components/organisms/Chat/Chat.stories.js +1 -21
- 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 +200 -348
- package/dist/components/organisms/Chat/Footer/index.js +39 -48
- package/dist/components/organisms/Chat/index.js +3 -48
- package/dist/components/organisms/FullProductNameHeader/index.js +2 -2
- package/dist/components/organisms/FullTabsMenu/index.js +12 -2
- package/dist/components/organisms/Modal/styles.js +1 -1
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +96 -171
- package/dist/components/pages/ProviderProductEdition/index.js +196 -189
- package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +28 -40
- package/dist/components/pages/RetailerProductEdition/index.js +290 -262
- package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/utils.js +2 -61
- package/dist/index.js +12 -51
- package/package.json +1 -3
- package/src/components/atoms/ButtonV2/styles.js +1 -1
- 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 +0 -2
- package/src/components/atoms/GeneralInput/index.js +21 -20
- package/src/components/atoms/InputFormatter/index.js +18 -14
- package/src/components/atoms/InputFormatter/styles.js +1 -2
- package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/src/components/molecules/HeaderTop/index.js +6 -52
- package/src/components/molecules/TabsMenu/index.js +88 -65
- package/src/components/molecules/TagAndInput/index.js +12 -10
- package/src/components/organisms/Chat/Chat.stories.js +0 -21
- package/src/components/organisms/Chat/ContainerItems/index.js +2 -18
- package/src/components/organisms/Chat/ContainerItems/styles.js +2 -10
- package/src/components/organisms/Chat/ContentChat/index.js +15 -86
- package/src/components/organisms/Chat/Footer/index.js +0 -11
- package/src/components/organisms/Chat/index.js +3 -47
- package/src/components/organisms/FullProductNameHeader/index.js +1 -1
- package/src/components/organisms/FullTabsMenu/index.js +16 -4
- package/src/components/organisms/Modal/styles.js +1 -4
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +98 -181
- package/src/components/pages/ProviderProductEdition/index.js +142 -134
- package/src/components/pages/ProviderProductEdition/styles.js +1 -5
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +26 -38
- package/src/components/pages/RetailerProductEdition/index.js +148 -111
- package/src/components/pages/RetailerProductEdition/styles.js +0 -4
- package/src/components/pages/RetailerProductEdition/utils.js +0 -37
- package/src/index.js +0 -3
- package/dist/assets/fonts/roboto/LICENSE.txt +0 -202
- package/src/components/molecules/StripeCardForm/StripeCardForm.stories.js +0 -13
- package/src/components/molecules/StripeCardForm/index.js +0 -42
- package/src/components/molecules/StripeCardForm/paymentForm.js +0 -124
- package/src/components/molecules/StripeCardForm/styles.js +0 -73
- package/src/components/molecules/StripeCardSelector/CardSelector.stories.js +0 -12
- package/src/components/molecules/StripeCardSelector/index.js +0 -44
- package/src/components/molecules/StripeCardSelector/styles.js +0 -4
- package/src/components/molecules/StripeCardSelector/utils.js +0 -17
- 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,42 +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
|
-
}) => {
|
|
16
|
-
const [stripeLoaded, setStripeLoaded] = useState(false);
|
|
17
|
-
|
|
18
|
-
const loadStripeJS = async () => {
|
|
19
|
-
await stripeApiKey;
|
|
20
|
-
setStripeLoaded(true);
|
|
21
|
-
};
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
loadStripeJS();
|
|
24
|
-
}, []);
|
|
25
|
-
|
|
26
|
-
return stripeLoaded ? (
|
|
27
|
-
<Container>
|
|
28
|
-
<Elements stripe={stripeApiKey}>
|
|
29
|
-
<PaymentForm
|
|
30
|
-
labelForm={"Pago con tarjeta"}
|
|
31
|
-
setToken={setToken}
|
|
32
|
-
setCard={setCard}
|
|
33
|
-
setStripe={setStripe}
|
|
34
|
-
setModalErrorCard={setModalErrorCard}
|
|
35
|
-
setMsj={setMsj}
|
|
36
|
-
/>
|
|
37
|
-
</Elements>
|
|
38
|
-
</Container>
|
|
39
|
-
) : (
|
|
40
|
-
<Loading />
|
|
41
|
-
);
|
|
42
|
-
};
|
|
@@ -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,73 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
import { FontFamily } from "../../../global-files/variables";
|
|
3
|
-
|
|
4
|
-
export const Container = styled.div``;
|
|
5
|
-
|
|
6
|
-
export const PaymentFormContainer = styled.form`
|
|
7
|
-
padding: 20px;
|
|
8
|
-
border: 1px solid #f0f0f0;
|
|
9
|
-
border-radius: 10px;
|
|
10
|
-
|
|
11
|
-
h2 {
|
|
12
|
-
font-size: 15px;
|
|
13
|
-
line-height: 20px;
|
|
14
|
-
color: #262626;
|
|
15
|
-
font-family: ${FontFamily.Lato};
|
|
16
|
-
|
|
17
|
-
& + * {
|
|
18
|
-
margin-top: 10px;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.card-fields {
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-wrap: wrap;
|
|
25
|
-
gap: 10px;
|
|
26
|
-
.element {
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
|
|
30
|
-
label {
|
|
31
|
-
color: #808080;
|
|
32
|
-
font-family: ${FontFamily.Lato};
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
display: flex;
|
|
35
|
-
|
|
36
|
-
& + * {
|
|
37
|
-
margin-left: 6px;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.card-input {
|
|
42
|
-
border: 1px solid #f0f0f0 !important;
|
|
43
|
-
border-radius: 5px;
|
|
44
|
-
padding: 3px;
|
|
45
|
-
font-family: ${FontFamily.Lato};
|
|
46
|
-
font-size: 12px;
|
|
47
|
-
flex: 1;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&.card-name {
|
|
51
|
-
flex: 1 0 100%;
|
|
52
|
-
label + * {
|
|
53
|
-
margin-left: 6px;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.card-number {
|
|
58
|
-
flex: 1 0 100%;
|
|
59
|
-
label + * {
|
|
60
|
-
margin-left: 43px;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&.expiration-date,
|
|
65
|
-
&.cvc-code {
|
|
66
|
-
flex: 1 1 49%;
|
|
67
|
-
label + * {
|
|
68
|
-
margin-left: 9px;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
@@ -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.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI5ZjQzNjAwMC0wYzgyLTRjNzYtYWEzNi1kM2Q1NGJjZTZiMTMiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4NTU2OTUyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2ODU1NzMxMjMsImlhdCI6MTY4NTU2OTUyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.EotcxmtkUpBxwlXa3bo25iLAmRcT0kj1G3PVITVB_0ZtF8UC19rJIMTNSc1hYkl8cbfCuB_vkjYCAxi4b2SOru5MdMTRhgNjcQTVbiwIYww-QdUWq0WSv84nW_HaRoxCJ8ezm-wBZgUTpcD3VFuynUICbODKKHUfxVdKdVoAM6GGE6ymSbO7-0C7ZumoWEqaZ22BF4G1H-JvLkR-tL5iqXa2N-QCnNoteFmHstBfH6Sp5UZhPav1VBEGRmwdFfUnC-Xc-aNeIFwgWCXMsOXFWbbmWeh0uNF-Btu-QEJ7VkCu4pbElqHWJKBYLCx1zqDBrKrsrNxyvQlxsJ9NSOae8Q",
|
|
12
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
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 = ({ jwt, setCard, setStripe }) => {
|
|
11
|
-
const [stripeLoaded, setStripeLoaded] = useState(false);
|
|
12
|
-
const [cards, setCards] = useState([]);
|
|
13
|
-
const [selectedCard, setSelectedCard] = useState("");
|
|
14
|
-
|
|
15
|
-
const loadStripeJS = async () => {
|
|
16
|
-
await stripeApiKey;
|
|
17
|
-
setStripeLoaded(true);
|
|
18
|
-
const cardsResponse = await getAllCards(jwt);
|
|
19
|
-
setCards(cardsResponse);
|
|
20
|
-
};
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
loadStripeJS();
|
|
23
|
-
}, []);
|
|
24
|
-
|
|
25
|
-
return stripeLoaded ? (
|
|
26
|
-
<Container>
|
|
27
|
-
<h2>Tarjetas guardadas</h2>
|
|
28
|
-
<Elements stripe={stripeApiKey}>
|
|
29
|
-
{cards.map((card) => (
|
|
30
|
-
<Card
|
|
31
|
-
key={card.id}
|
|
32
|
-
card={card}
|
|
33
|
-
selectedCard={selectedCard}
|
|
34
|
-
setSelectedCard={setSelectedCard}
|
|
35
|
-
setCard={setCard}
|
|
36
|
-
setStripe={setStripe}
|
|
37
|
-
/>
|
|
38
|
-
))}
|
|
39
|
-
</Elements>
|
|
40
|
-
</Container>
|
|
41
|
-
) : (
|
|
42
|
-
<Loading />
|
|
43
|
-
);
|
|
44
|
-
};
|
|
@@ -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
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SideModal } from ".";
|
|
2
|
-
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: "Components/organisms/SideModal",
|
|
6
|
-
component: SideModal,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const Template = (args) => <SideModal {...args} />;
|
|
10
|
-
|
|
11
|
-
export const DefaultSideModal = Template.bind({});
|
|
12
|
-
DefaultSideModal.args = {
|
|
13
|
-
show: false,
|
|
14
|
-
header: [
|
|
15
|
-
<div className="title-container">
|
|
16
|
-
<h2></h2>
|
|
17
|
-
</div>,
|
|
18
|
-
<ButtonV2 label="Ir al Checkout" />,
|
|
19
|
-
<ButtonV2 label="X" />,
|
|
20
|
-
],
|
|
21
|
-
body: <></>,
|
|
22
|
-
footer: <></>,
|
|
23
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useRef } from "react";
|
|
2
|
-
import { Container } from "./styles";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { PropaneSharp } from "@mui/icons-material";
|
|
5
|
-
|
|
6
|
-
export const SideModal = ({
|
|
7
|
-
header,
|
|
8
|
-
body,
|
|
9
|
-
footer,
|
|
10
|
-
show,
|
|
11
|
-
setShow,
|
|
12
|
-
id = "side-modal",
|
|
13
|
-
}) => {
|
|
14
|
-
const modal = useRef();
|
|
15
|
-
|
|
16
|
-
const closeModal = (e) => {
|
|
17
|
-
if (!e.target.closest(`#${id}`) && show) {
|
|
18
|
-
document.removeEventListener("click", closeModal, false);
|
|
19
|
-
modal?.current?.classList?.remove("shown");
|
|
20
|
-
setShow && setShow(false);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (show && modal.current) {
|
|
26
|
-
document.addEventListener("click", closeModal, false);
|
|
27
|
-
modal?.current?.classList?.add("shown");
|
|
28
|
-
}
|
|
29
|
-
}, [show]);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
return () => {
|
|
33
|
-
document.removeEventListener("click", closeModal, false);
|
|
34
|
-
modal?.current?.classList?.remove("shown");
|
|
35
|
-
setShow && setShow(false);
|
|
36
|
-
};
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
show && (
|
|
41
|
-
<Container>
|
|
42
|
-
<div id={id} ref={modal} className="modal-container">
|
|
43
|
-
<div className="modal-header">{header}</div>
|
|
44
|
-
<div className="modal-body">{body}</div>
|
|
45
|
-
<div className="modal-footer">{footer}</div>
|
|
46
|
-
</div>
|
|
47
|
-
</Container>
|
|
48
|
-
)
|
|
49
|
-
);
|
|
50
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
|
|
3
|
-
export const Container = styled.div`
|
|
4
|
-
width: 100vw;
|
|
5
|
-
height: 100vh;
|
|
6
|
-
position: fixed;
|
|
7
|
-
z-index: 9999999;
|
|
8
|
-
background-color: transparent;
|
|
9
|
-
top: 0;
|
|
10
|
-
left: 0;
|
|
11
|
-
|
|
12
|
-
.modal-container {
|
|
13
|
-
width: 600px;
|
|
14
|
-
height: 100%;
|
|
15
|
-
position: absolute;
|
|
16
|
-
right: -600px;
|
|
17
|
-
background-color: #fff;
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
box-shadow: -0.5px 0px 5px #f0f0f0;
|
|
21
|
-
border: 1px solid #f0f0f0;
|
|
22
|
-
.modal-body {
|
|
23
|
-
flex: 1;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&.shown {
|
|
27
|
-
right: 0;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;
|