contentoh-components-library 21.3.88 → 21.3.90
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 +5 -0
- package/.env.production +3 -0
- package/dist/components/atoms/Card/index.js +46 -5
- package/dist/components/atoms/Card/styles.js +3 -1
- package/dist/components/atoms/CheckBox/index.js +4 -2
- package/dist/components/atoms/InputFormatter/styles.js +1 -1
- package/dist/components/atoms/ProgressBar/index.js +18 -10
- package/dist/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/dist/components/molecules/HeaderTop/index.js +68 -11
- package/dist/components/molecules/TagAndInput/index.js +1 -1
- package/dist/components/organisms/Chat/Chat.stories.js +27 -8
- package/dist/components/organisms/Chat/ContainerItems/index.js +19 -3
- package/dist/components/organisms/Chat/ContainerItems/styles.js +1 -1
- package/dist/components/organisms/Chat/ContentChat/index.js +350 -197
- package/dist/components/organisms/Chat/Footer/index.js +48 -39
- package/dist/components/organisms/Chat/index.js +49 -4
- 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 +171 -96
- package/dist/components/pages/ProviderProductEdition/index.js +188 -175
- package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +40 -28
- package/dist/components/pages/RetailerProductEdition/index.js +265 -273
- package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
- package/dist/components/pages/RetailerProductEdition/utils.js +61 -2
- package/dist/index.js +51 -12
- package/package.json +3 -1
- package/src/components/atoms/Card/index.js +35 -2
- package/src/components/atoms/Card/styles.js +41 -5
- package/src/components/atoms/CheckBox/index.js +2 -0
- package/src/components/atoms/InputFormatter/styles.js +2 -1
- package/src/components/atoms/ProgressBar/index.js +17 -8
- package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
- package/src/components/molecules/HeaderTop/index.js +52 -6
- package/src/components/molecules/StripeCardForm/StripeCardForm.stories.js +13 -0
- package/src/components/molecules/StripeCardForm/index.js +42 -0
- package/src/components/molecules/StripeCardForm/paymentForm.js +124 -0
- package/src/components/molecules/StripeCardForm/styles.js +73 -0
- package/src/components/molecules/StripeCardSelector/CardSelector.stories.js +12 -0
- package/src/components/molecules/StripeCardSelector/index.js +44 -0
- package/src/components/molecules/StripeCardSelector/styles.js +4 -0
- package/src/components/molecules/StripeCardSelector/utils.js +17 -0
- package/src/components/molecules/TagAndInput/index.js +10 -8
- package/src/components/organisms/Chat/Chat.stories.js +27 -7
- package/src/components/organisms/Chat/ContainerItems/index.js +18 -2
- package/src/components/organisms/Chat/ContainerItems/styles.js +10 -2
- package/src/components/organisms/Chat/ContentChat/index.js +88 -12
- package/src/components/organisms/Chat/Footer/index.js +11 -0
- package/src/components/organisms/Chat/index.js +46 -4
- package/src/components/organisms/FullProductNameHeader/index.js +1 -1
- package/src/components/organisms/Modal/styles.js +4 -1
- package/src/components/organisms/SideModal/SideModal.stories.js +23 -0
- package/src/components/organisms/SideModal/index.js +50 -0
- package/src/components/organisms/SideModal/styles.js +30 -0
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +181 -98
- package/src/components/pages/ProviderProductEdition/index.js +132 -129
- package/src/components/pages/ProviderProductEdition/styles.js +5 -1
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +38 -26
- package/src/components/pages/RetailerProductEdition/index.js +109 -135
- package/src/components/pages/RetailerProductEdition/styles.js +4 -0
- package/src/components/pages/RetailerProductEdition/utils.js +37 -0
- package/src/index.js +3 -0
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -36,14 +36,16 @@ export const TagAndInput = ({
|
|
|
36
36
|
className={"input-container"}
|
|
37
37
|
key={`generalTagInput-${inputType}`}
|
|
38
38
|
>
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
{label?.length && (
|
|
40
|
+
<div className="title-container">
|
|
41
|
+
<ScreenHeader
|
|
42
|
+
text={label}
|
|
43
|
+
headerType={"input-name-header"}
|
|
44
|
+
color={color}
|
|
45
|
+
/>
|
|
46
|
+
{showTooltip && <span className="tooltip">{label}</span>}
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
47
49
|
<GeneralInput
|
|
48
50
|
inputId={inputId}
|
|
49
51
|
inputType={inputType}
|
|
@@ -148,17 +148,37 @@ chatTicket_userTECH.args = {
|
|
|
148
148
|
chatType: "ticket",
|
|
149
149
|
chatContainerType: "fixed",
|
|
150
150
|
chatData: {
|
|
151
|
-
id:
|
|
152
|
-
ticketOwnerUserId:
|
|
153
|
-
|
|
154
|
-
statusTicket: "PENDING",
|
|
151
|
+
id: 171,
|
|
152
|
+
ticketOwnerUserId: 52,
|
|
153
|
+
statusTicket: "IN_PROGRESS",
|
|
155
154
|
currentUser: {
|
|
156
155
|
token:
|
|
157
|
-
"eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.
|
|
158
|
-
id:
|
|
159
|
-
companyId:
|
|
156
|
+
"eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI3M2NjOGQ0MC1jODQxLTQyMmEtYTJmMi1lNjlkN2ZlMjZlYmYiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwiY29nbml0bzp1c2VybmFtZSI6IjczY2M4ZDQwLWM4NDEtNDIyYS1hMmYyLWU2OWQ3ZmUyNmViZiIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiIwYWNiYTdlYy01OGJhLTQyNGYtOTM5OC02ZGMxOGI1YTRkODYiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4ODk0MzcxNywibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY4ODk0NzMxNywiaWF0IjoxNjg4OTQzNzE3LCJlbWFpbCI6Im9hcmVuYXNAY29udGVudG9oLmNvbSJ9.SHeA5EMqLdqlTuDBTpJ3l_lAAqjMlOT2Dm9U9yf-Y3-4FR-3cwQ_16sdsmGCjJpwkhdYBEyuQbFkY1xnQHOBLMow0izWD4CDlhlNXkWBE_3DjgCspyPMlz31Lfik2ddnkHp3HQeLwucC4uyum3N-roQA7HkuWQHSBIplp6b-Xd44OmN9X-V_kseN3QOX6o7kxNFjwZL_DUzTJUdMDOtIXXIKYO2FLkR1eWJDNdvee5FEIWAxJXfaSZ__Awawfi5k93ILXrPX7QVt78lOH3THMyiPTtfiOOwMhoSQz_k5DIuofE8FM_1-nLNajM18pI49wPQ_-k3ltCjChjqy-OlERQ",
|
|
157
|
+
id: 65,
|
|
158
|
+
companyId: 2,
|
|
160
159
|
isUserTech: true,
|
|
161
160
|
},
|
|
162
161
|
},
|
|
163
162
|
classNameContainerFixed: "chatTicket",
|
|
164
163
|
};
|
|
164
|
+
|
|
165
|
+
// ejemplo del chat para los cambios de status del producto.
|
|
166
|
+
export const chatProduct_status = Template.bind({});
|
|
167
|
+
chatProduct_status.args = {
|
|
168
|
+
chatType: "product_status",
|
|
169
|
+
chatContainerType: "popUp",
|
|
170
|
+
chatData: {
|
|
171
|
+
id: 37414,
|
|
172
|
+
version: 7,
|
|
173
|
+
retailerId: 70,
|
|
174
|
+
status: "AA",
|
|
175
|
+
orderId: 15189,
|
|
176
|
+
userToken:
|
|
177
|
+
"eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI5YTIxMzEyOC02NDgyLTRjMTYtYTRiNi02ZTY0ZjIyNWIxYmQiLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwiY29nbml0bzp1c2VybmFtZSI6IjlhMjEzMTI4LTY0ODItNGMxNi1hNGI2LTZlNjRmMjI1YjFiZCIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiJhOWFhMDQ4Zi05YzRjLTQxODMtYWUzMS03OWVjNjBhY2NjZGYiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4MzU4ODM4OSwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY4MzU5MTk4OSwiaWF0IjoxNjgzNTg4Mzg5LCJlbWFpbCI6ImlzbWFlbDk3bG9wZXpAZ21haWwuY29tIn0.k9FQfRR02XC3WWfOzWhrbJGmp69AmCHJEIrgtXKhIwC69trdphSm1AKkZnDJMsEdkpUgjF_zAOsa_xYRxO6goXy7WXVc_p7N-yFHlkhZrRyn3LEFKaLzD8vVqlWx4kgfSERm7KhI1AxPmrA-lw8eF6Axvqn3PvuszAw89_WhPOcnOt8vU0MxAVhLgS8oM6vyHFmHEHWQ2FnSYYed9sEvAxGh_B44aIgWeDteQGeGdYhsm6rUcxgkrskywZJp9FW5VgYXuDcC5NpvomMMRy_v95UV897JzCHl__sK2Z9ahm0eczVN3tAc0GbKnlN96ZrGTQ_nmNHbuMDPQBPXH5HXZQ",
|
|
178
|
+
currentUser: {
|
|
179
|
+
id: 37,
|
|
180
|
+
companyId: 2,
|
|
181
|
+
isUserTech: false,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
};
|
|
@@ -22,6 +22,7 @@ import { Tooltip } from "../../../atoms/Tooltip";
|
|
|
22
22
|
import { Slide, Zoom } from "@mui/material";
|
|
23
23
|
import { useRef } from "react";
|
|
24
24
|
import { ImagePreview } from "../../../atoms/ImagePreview";
|
|
25
|
+
import { Status } from "../../../atoms/Status";
|
|
25
26
|
import { isUserTech } from "../../../../global-files/handle_userTech";
|
|
26
27
|
import { container } from "aws-amplify";
|
|
27
28
|
|
|
@@ -55,7 +56,10 @@ export const ContainerItems = (props) => {
|
|
|
55
56
|
|
|
56
57
|
useEffect(() => {
|
|
57
58
|
if (!items) return;
|
|
58
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
["merchant_product", "order_product", "product_status"].includes(chatType)
|
|
61
|
+
)
|
|
62
|
+
renderItems();
|
|
59
63
|
else if (chatType === "ticket") renderItemsTicket();
|
|
60
64
|
else setCustomItems([]);
|
|
61
65
|
}, [items]);
|
|
@@ -130,6 +134,16 @@ export const ContainerItems = (props) => {
|
|
|
130
134
|
return <label className="item-statusTicket">{item.value}</label>;
|
|
131
135
|
};
|
|
132
136
|
|
|
137
|
+
const renderStatusItem = (item) => {
|
|
138
|
+
const splitText = item.value.split("|");
|
|
139
|
+
let message = [];
|
|
140
|
+
splitText.forEach((text, i) => {
|
|
141
|
+
if (i === 1 || i === 3) message.push(<Status statusType={text} />);
|
|
142
|
+
else message.push(text);
|
|
143
|
+
});
|
|
144
|
+
return <label className="item-statusItem">{message}</label>;
|
|
145
|
+
};
|
|
146
|
+
|
|
133
147
|
const renderStatusTicketNeutral = (item) => {
|
|
134
148
|
return (
|
|
135
149
|
<Tooltip
|
|
@@ -304,7 +318,7 @@ export const ContainerItems = (props) => {
|
|
|
304
318
|
>
|
|
305
319
|
<li
|
|
306
320
|
className={
|
|
307
|
-
(ownMessage ? "own-message " : "") +
|
|
321
|
+
(ownMessage && item.type !== "status" ? "own-message " : "") +
|
|
308
322
|
(lastUserId === item.userId ? "sameUser" : "")
|
|
309
323
|
}
|
|
310
324
|
>
|
|
@@ -339,6 +353,8 @@ export const ContainerItems = (props) => {
|
|
|
339
353
|
? renderComment(item)
|
|
340
354
|
: item.type === "img"
|
|
341
355
|
? renderImg(item)
|
|
356
|
+
: item.type === "status"
|
|
357
|
+
? renderStatusItem(item)
|
|
342
358
|
: item.type === "file"
|
|
343
359
|
? renderFile(item, ownMessage)
|
|
344
360
|
: item.type === "statusTicket" &&
|
|
@@ -158,7 +158,8 @@ export const Container = styled.div`
|
|
|
158
158
|
.item-message,
|
|
159
159
|
.item-comment,
|
|
160
160
|
.item-file,
|
|
161
|
-
.item-statusTicket
|
|
161
|
+
.item-statusTicket,
|
|
162
|
+
.item-statusItem {
|
|
162
163
|
border-radius: 10px;
|
|
163
164
|
padding: 10px;
|
|
164
165
|
font-family: ${FontFamily.RobotoRegular}, sans-serif;
|
|
@@ -173,10 +174,17 @@ export const Container = styled.div`
|
|
|
173
174
|
.item-file {
|
|
174
175
|
background-color: #8386ee;
|
|
175
176
|
}
|
|
176
|
-
.item-statusTicket
|
|
177
|
+
.item-statusTicket,
|
|
178
|
+
.item-statusItem {
|
|
177
179
|
background-color: #85bc5b;
|
|
178
180
|
}
|
|
179
181
|
|
|
182
|
+
.item-statusItem {
|
|
183
|
+
display: flex;
|
|
184
|
+
gap: 3px;
|
|
185
|
+
align-items: center;
|
|
186
|
+
}
|
|
187
|
+
|
|
180
188
|
.item-message {
|
|
181
189
|
&.different-company {
|
|
182
190
|
border: 1px solid #e33aa9;
|
|
@@ -86,7 +86,8 @@ export const ContentChat = (props) => {
|
|
|
86
86
|
|
|
87
87
|
// al cargar el componente
|
|
88
88
|
useEffect(() => {
|
|
89
|
-
if (dataChat && showPopUpChat) {
|
|
89
|
+
//if (dataChat && showPopUpChat) {
|
|
90
|
+
if (Object.keys(dataChat || {}).length) {
|
|
90
91
|
stopUpdate();
|
|
91
92
|
if (dataChat.code) {
|
|
92
93
|
setErrorChat({
|
|
@@ -100,6 +101,7 @@ export const ContentChat = (props) => {
|
|
|
100
101
|
}
|
|
101
102
|
if (chatType === "merchant_product") getInitialMerchantProduct();
|
|
102
103
|
else if (chatType === "order_product") getInitialOrderProduct();
|
|
104
|
+
else if (chatType === "product_status") getInitialProductStatus();
|
|
103
105
|
else getInitialTicket();
|
|
104
106
|
}
|
|
105
107
|
if (!showPopUpChat) {
|
|
@@ -126,6 +128,8 @@ export const ContentChat = (props) => {
|
|
|
126
128
|
} else if (chatType === "order_product") {
|
|
127
129
|
if (companies) getUpdateLatestOrderProduct(true);
|
|
128
130
|
else getInitialOrderProduct();
|
|
131
|
+
} else if (chatType === "product_status") {
|
|
132
|
+
getInitialProductStatus();
|
|
129
133
|
} else {
|
|
130
134
|
if (singleChat.items) getUpdateLatestTicket(true);
|
|
131
135
|
else getInitialTicket();
|
|
@@ -135,6 +139,47 @@ export const ContentChat = (props) => {
|
|
|
135
139
|
/*=======================================================================
|
|
136
140
|
PETICION GET INICIAL SEGUN EL TIPO DE CHAT
|
|
137
141
|
======================================================================= */
|
|
142
|
+
const getInitialProductStatus = async () => {
|
|
143
|
+
const paramsQuery = {
|
|
144
|
+
articleData: JSON.stringify({
|
|
145
|
+
articleId: JSON.stringify(dataChat.id),
|
|
146
|
+
version: JSON.stringify(dataChat.version),
|
|
147
|
+
retailerId: JSON.stringify(dataChat.retailerId),
|
|
148
|
+
status: dataChat.status,
|
|
149
|
+
})
|
|
150
|
+
};
|
|
151
|
+
const paramsHeaders = { Authorization: dataChat.userToken };
|
|
152
|
+
const response = await fetchGET(
|
|
153
|
+
process.env.REACT_APP_READ_MESSAGES,
|
|
154
|
+
paramsQuery,
|
|
155
|
+
paramsHeaders
|
|
156
|
+
);
|
|
157
|
+
if (!response.body) {
|
|
158
|
+
setErrorChat({
|
|
159
|
+
existError: true,
|
|
160
|
+
code: 400,
|
|
161
|
+
message: response.message,
|
|
162
|
+
errorDetail: response.errorDetail,
|
|
163
|
+
});
|
|
164
|
+
setIsLoading(false);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
// success
|
|
168
|
+
setStartUpdate((prev) => prev + 1);
|
|
169
|
+
setCurrentUser({
|
|
170
|
+
id: response.body.data.currentUserId,
|
|
171
|
+
companyId: response.body.data.currentCompanyId,
|
|
172
|
+
});
|
|
173
|
+
setLastUpdateDate(response.body.data.lastUpdateDate);
|
|
174
|
+
setAllUsers(response.body.users);
|
|
175
|
+
setSingleChat({
|
|
176
|
+
items: response.body.items,
|
|
177
|
+
enabledLoadMore: response.body.items.length === 50,
|
|
178
|
+
});
|
|
179
|
+
setErrorChat({ existError: false });
|
|
180
|
+
setIsLoading(false);
|
|
181
|
+
};
|
|
182
|
+
|
|
138
183
|
const getInitialMerchantProduct = async () => {
|
|
139
184
|
const paramsQuery = {
|
|
140
185
|
getType: "initial",
|
|
@@ -568,14 +613,14 @@ export const ContentChat = (props) => {
|
|
|
568
613
|
};
|
|
569
614
|
|
|
570
615
|
/*=======================================================================
|
|
571
|
-
FUNCION QUE EJECUTA EL MICROSERVICIO CREATE-ITEM
|
|
616
|
+
FUNCION QUE EJECUTA EL MICROSERVICIO CREATE-ITEM
|
|
572
617
|
Este metodo recibe los items que queremos agregar al chat.
|
|
573
618
|
requiere:
|
|
574
|
-
=> items: [ { type , value } , ... ]
|
|
619
|
+
=> items: [ { type , value } , ... ]
|
|
575
620
|
NOTA: si se quiere agregar un mensaje mandar un array con un object
|
|
576
|
-
example: [ {
|
|
577
|
-
type: "message" ,
|
|
578
|
-
value: "mi mensaje"
|
|
621
|
+
example: [ {
|
|
622
|
+
type: "message" ,
|
|
623
|
+
value: "mi mensaje"
|
|
579
624
|
} ]
|
|
580
625
|
======================================================================= */
|
|
581
626
|
const createItemsChat = async (items = []) => {
|
|
@@ -611,12 +656,14 @@ export const ContentChat = (props) => {
|
|
|
611
656
|
// enviar items a la BD
|
|
612
657
|
if (chatType === "merchant_product") {
|
|
613
658
|
errorCreate = await createItemsMerchantProduct(items);
|
|
659
|
+
} else if (chatType === "product_status") {
|
|
660
|
+
errorCreate = await createItemsProductStatus(items);
|
|
614
661
|
} else if (chatType === "order_product") {
|
|
615
662
|
errorCreate = await createItemsOrderProduct(items);
|
|
616
663
|
} else errorCreate = await createItemsTicket(items);
|
|
617
664
|
|
|
618
665
|
// actualizar chat para que aparezcan los items enviados
|
|
619
|
-
if (
|
|
666
|
+
if (["merchant_product", "product_status"].includes(chatType)) {
|
|
620
667
|
await getUpdateLatestMerchantProduct();
|
|
621
668
|
} else if (chatType === "order_product") {
|
|
622
669
|
await getUpdateLatestOrderProduct();
|
|
@@ -629,9 +676,10 @@ export const ContentChat = (props) => {
|
|
|
629
676
|
};
|
|
630
677
|
|
|
631
678
|
const createItemsMerchantProduct = async (items = []) => {
|
|
632
|
-
const { id, version } = dataChat;
|
|
679
|
+
const { id, version, orderId } = dataChat;
|
|
633
680
|
const { id: retailerId } = activeRetailer;
|
|
634
681
|
const paramsBody = { id, version, items, retailerId };
|
|
682
|
+
if (chatType === "product_status") paramsBody["orderId"] = orderId;
|
|
635
683
|
const paramsHeaders = { Authorization: dataChat.userToken };
|
|
636
684
|
const response = await fetchPOST(
|
|
637
685
|
process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
|
|
@@ -645,6 +693,23 @@ export const ContentChat = (props) => {
|
|
|
645
693
|
};
|
|
646
694
|
}
|
|
647
695
|
};
|
|
696
|
+
const createItemsProductStatus = async (items = []) => {
|
|
697
|
+
const { id, version, orderId, status } = dataChat;
|
|
698
|
+
const { id: retailerId } = activeRetailer;
|
|
699
|
+
const paramsBody = { id, version, items, retailerId, orderId, status };
|
|
700
|
+
const paramsHeaders = { Authorization: dataChat.userToken };
|
|
701
|
+
const response = await fetchPOST(
|
|
702
|
+
process.env.REACT_APP_CREATE_MESSAGES,
|
|
703
|
+
paramsBody,
|
|
704
|
+
paramsHeaders
|
|
705
|
+
);
|
|
706
|
+
if (!response.body) {
|
|
707
|
+
return {
|
|
708
|
+
message: response.message,
|
|
709
|
+
errorDetail: response.errorDetail,
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
};
|
|
648
713
|
|
|
649
714
|
const createItemsOrderProduct = async (items = []) => {
|
|
650
715
|
const paramsBody = {
|
|
@@ -692,7 +757,11 @@ export const ContentChat = (props) => {
|
|
|
692
757
|
SECCION DE FUNCIONES
|
|
693
758
|
======================================================================= */
|
|
694
759
|
const isSingleChat = () => {
|
|
695
|
-
if (
|
|
760
|
+
if (
|
|
761
|
+
chatType === "merchant_product" ||
|
|
762
|
+
chatType === "ticket" ||
|
|
763
|
+
chatType === "product_status"
|
|
764
|
+
) {
|
|
696
765
|
return true;
|
|
697
766
|
}
|
|
698
767
|
if (companies && Object.keys(companies).length < 2) return true;
|
|
@@ -807,7 +876,7 @@ export const ContentChat = (props) => {
|
|
|
807
876
|
// mostrar chat?
|
|
808
877
|
let items;
|
|
809
878
|
let enabledLoadMore;
|
|
810
|
-
if (["merchant_product", "ticket"].includes(chatType)) {
|
|
879
|
+
if (["merchant_product", "ticket", "product_status"].includes(chatType)) {
|
|
811
880
|
items = singleChat.items;
|
|
812
881
|
enabledLoadMore = singleChat.enabledLoadMore;
|
|
813
882
|
}
|
|
@@ -849,7 +918,9 @@ export const ContentChat = (props) => {
|
|
|
849
918
|
activeCompanyId={activeCompanyId}
|
|
850
919
|
ticketCompany={ticketCompany}
|
|
851
920
|
currentUser={
|
|
852
|
-
["merchant_product", "order_product"].includes(
|
|
921
|
+
["merchant_product", "order_product", "product_status"].includes(
|
|
922
|
+
chatType
|
|
923
|
+
)
|
|
853
924
|
? currentUser
|
|
854
925
|
: dataChat.currentUser
|
|
855
926
|
}
|
|
@@ -888,6 +959,12 @@ export const ContentChat = (props) => {
|
|
|
888
959
|
? { id: dataChat.id, version: currentArticle.version }
|
|
889
960
|
: chatType === "ticket"
|
|
890
961
|
? { id: dataChat.id }
|
|
962
|
+
: chatType === "product_status"
|
|
963
|
+
? {
|
|
964
|
+
id: dataChat.id,
|
|
965
|
+
version: dataChat.version,
|
|
966
|
+
retailerId: dataChat.retailerId,
|
|
967
|
+
}
|
|
891
968
|
: undefined
|
|
892
969
|
}
|
|
893
970
|
chatCompany={getChatCompany()}
|
|
@@ -930,7 +1007,6 @@ export const ContentChat = (props) => {
|
|
|
930
1007
|
}}
|
|
931
1008
|
/>
|
|
932
1009
|
)}
|
|
933
|
-
|
|
934
1010
|
{/* body */}
|
|
935
1011
|
{renderBodyChat()}
|
|
936
1012
|
</Container>
|
|
@@ -169,6 +169,17 @@ export const Footer = (props) => {
|
|
|
169
169
|
errorMessage = "El ID del ticket no es valido";
|
|
170
170
|
}
|
|
171
171
|
break;
|
|
172
|
+
case "product_status":
|
|
173
|
+
if (
|
|
174
|
+
isValidNaturalNumber(dataChat?.id) &&
|
|
175
|
+
isValidNaturalNumber(dataChat?.version) &&
|
|
176
|
+
isValidNaturalNumber(dataChat?.retailerId)
|
|
177
|
+
) {
|
|
178
|
+
fileKey += `productStatus/${dataChat.id}-${dataChat?.version}-${dataChat?.retailerId}/`;
|
|
179
|
+
} else {
|
|
180
|
+
errorMessage = "El ID del ticket no es valido";
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
172
183
|
|
|
173
184
|
default:
|
|
174
185
|
errorMessage =
|