contentoh-components-library 21.2.104 → 21.2.106
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 -2
- package/.env.production +25 -25
- package/dist/assets/images/customSelect/starIcon.svg +14 -0
- package/dist/assets/images/defaultImages/Spinner.gif +0 -0
- package/dist/assets/images/defaultImages/notFound.svg +124 -0
- package/dist/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +72 -0
- package/dist/components/atoms/ButtonFileChooser/index.js +118 -0
- package/dist/components/atoms/ButtonFileChooser/styles.js +20 -0
- package/dist/components/atoms/ButtonV2/ButtonV2.stories.js +66 -0
- package/dist/components/atoms/ButtonV2/index.js +110 -0
- package/dist/components/atoms/ButtonV2/styles.js +53 -0
- package/dist/components/atoms/CustomIcon/CustomIcon.stories.js +50 -0
- package/dist/components/atoms/CustomIcon/index.js +40 -0
- package/dist/components/atoms/CustomIcon/styles.js +33 -0
- package/dist/components/atoms/GeneralButton/index.js +2 -6
- package/dist/components/atoms/IconFile/IconFile.stories.js +48 -0
- package/dist/components/atoms/IconFile/index.js +249 -0
- package/dist/components/atoms/IconFile/styles.js +23 -0
- package/dist/components/atoms/Image/Image.stories.js +73 -0
- package/dist/components/atoms/Image/index.js +76 -0
- package/dist/components/atoms/Image/styles.js +43 -0
- package/dist/components/atoms/ImageLink/ImageLink.stories.js +63 -0
- package/dist/components/atoms/ImageLink/index.js +77 -0
- package/dist/components/atoms/ImageLink/styles.js +40 -0
- package/dist/components/atoms/ImagePreview/ImagePreview.stories.js +70 -0
- package/dist/components/atoms/ImagePreview/index.js +222 -0
- package/dist/components/atoms/ImagePreview/styles.js +44 -0
- package/dist/components/atoms/InputText/InputText.stories.js +60 -0
- package/dist/components/atoms/InputText/index.js +66 -0
- package/dist/components/atoms/InputText/styles.js +32 -0
- package/dist/components/atoms/NotFound/NotFound.stories.js +36 -0
- package/dist/components/atoms/NotFound/index.js +75 -0
- package/dist/components/atoms/NotFound/styles.js +20 -0
- package/dist/components/atoms/Select/VersionSelect.js +1 -2
- package/dist/components/atoms/SelectItemV2/SelectItemV2.stories.js +45 -0
- package/dist/components/atoms/SelectItemV2/index.js +57 -0
- package/dist/components/atoms/SelectItemV2/styles.js +30 -0
- package/dist/components/atoms/Tooltip/Tooltip.stories.js +66 -0
- package/dist/components/atoms/Tooltip/index.js +72 -0
- package/dist/components/atoms/Tooltip/styles.js +20 -0
- package/dist/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +66 -0
- package/dist/components/molecules/ButtonDownloadFile/index.js +179 -0
- package/dist/components/molecules/ButtonDownloadFile/styles.js +23 -0
- package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +21 -22
- package/dist/components/molecules/CustomSelect/SelectItem.js +10 -1
- package/dist/components/molecules/Dropdown/Dropdown.stories.js +98 -0
- package/dist/components/molecules/Dropdown/index.js +150 -0
- package/dist/components/molecules/Dropdown/styles.js +26 -0
- package/dist/components/molecules/HeaderTop/index.js +10 -5
- package/dist/components/molecules/HeaderTop/styles.js +1 -1
- package/dist/components/molecules/ImageTooltip/ImageTooltip.stories.js +82 -0
- package/dist/components/molecules/ImageTooltip/index.js +85 -0
- package/dist/components/molecules/ImageTooltip/styles.js +33 -0
- package/dist/components/molecules/SelectV2/SelectV2.stories.js +119 -0
- package/dist/components/molecules/SelectV2/index.js +298 -0
- package/dist/components/molecules/SelectV2/styles.js +42 -0
- package/dist/components/organisms/Chat/Chat.stories.js +215 -0
- package/dist/components/organisms/Chat/ChatLists/ChatLists.stories.js +83 -0
- package/dist/components/organisms/Chat/ChatLists/index.js +160 -0
- package/dist/components/organisms/Chat/ChatLists/styles.js +29 -0
- package/dist/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +176 -0
- package/dist/components/organisms/Chat/ContainerItems/index.js +569 -0
- package/dist/components/organisms/Chat/ContainerItems/styles.js +20 -0
- package/dist/components/organisms/Chat/ContentChat/ContentChat.stories.js +142 -0
- package/dist/components/organisms/Chat/ContentChat/index.js +1422 -0
- package/dist/components/organisms/Chat/ContentChat/styles.js +20 -0
- package/dist/components/organisms/Chat/Footer/Footer.stories.js +43 -0
- package/dist/components/organisms/Chat/Footer/index.js +984 -0
- package/dist/components/organisms/Chat/Footer/styles.js +32 -0
- package/dist/components/organisms/Chat/Header/Header.stories.js +96 -0
- package/dist/components/organisms/Chat/Header/index.js +84 -0
- package/dist/components/organisms/Chat/Header/styles.js +20 -0
- package/dist/components/organisms/Chat/index.js +327 -0
- package/dist/components/organisms/Chat/styles.js +29 -0
- package/dist/components/organisms/CreateVersion/RenderChilds.js +11 -11
- package/dist/components/organisms/CreateVersion/index.js +89 -30
- package/dist/components/organisms/Modal/Modal.stories.js +66 -0
- package/dist/components/organisms/Modal/index.js +95 -0
- package/dist/components/organisms/Modal/styles.js +20 -0
- package/dist/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
- package/dist/components/organisms/OrderDetail/index.js +11 -20
- package/dist/components/organisms/OrderDetail/styles.js +1 -1
- package/dist/components/organisms/OrderDetail/utils/Table/styles.js +1 -1
- package/dist/components/organisms/OrderDetail/utils/Table/utils.js +15 -45
- package/dist/components/organisms/VersionSelector/index.js +2 -28
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +147 -69
- package/dist/components/pages/ProviderProductEdition/index.js +22 -2
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +67 -77
- package/dist/components/pages/RetailerProductEdition/index.js +24 -5
- package/dist/global-files/fonts.css +12 -0
- package/dist/global-files/handle_http.js +383 -0
- package/dist/global-files/utils.js +472 -0
- package/dist/global-files/variables.js +2 -0
- package/dist/index.js +254 -46
- package/package.json +12 -1
- package/src/assets/images/customSelect/starIcon.svg +14 -0
- package/src/assets/images/defaultImages/Spinner.gif +0 -0
- package/src/assets/images/defaultImages/notFound.svg +124 -0
- package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +47 -0
- package/src/components/atoms/ButtonFileChooser/index.js +69 -0
- package/src/components/atoms/ButtonFileChooser/styles.js +4 -0
- package/src/components/atoms/ButtonV2/ButtonV2.stories.js +53 -0
- package/src/components/atoms/ButtonV2/index.js +85 -0
- package/src/components/atoms/ButtonV2/styles.js +217 -0
- package/src/components/atoms/CustomIcon/CustomIcon.stories.js +36 -0
- package/src/components/atoms/CustomIcon/index.js +41 -0
- package/src/components/atoms/CustomIcon/styles.js +85 -0
- package/src/components/atoms/GeneralButton/index.js +1 -4
- package/src/components/atoms/IconFile/IconFile.stories.js +35 -0
- package/src/components/atoms/IconFile/index.js +119 -0
- package/src/components/atoms/IconFile/styles.js +67 -0
- package/src/components/atoms/Image/Image.stories.js +51 -0
- package/src/components/atoms/Image/index.js +55 -0
- package/src/components/atoms/Image/styles.js +34 -0
- package/src/components/atoms/ImageLink/ImageLink.stories.js +43 -0
- package/src/components/atoms/ImageLink/index.js +57 -0
- package/src/components/atoms/ImageLink/styles.js +30 -0
- package/src/components/atoms/ImagePreview/ImagePreview.stories.js +52 -0
- package/src/components/atoms/ImagePreview/index.js +191 -0
- package/src/components/atoms/ImagePreview/styles.js +77 -0
- package/src/components/atoms/InputText/InputText.stories.js +39 -0
- package/src/components/atoms/InputText/index.js +61 -0
- package/src/components/atoms/InputText/styles.js +89 -0
- package/src/components/atoms/NotFound/NotFound.stories.js +19 -0
- package/src/components/atoms/NotFound/index.js +52 -0
- package/src/components/atoms/NotFound/styles.js +55 -0
- package/src/components/atoms/Select/VersionSelect.js +2 -4
- package/src/components/atoms/SelectItemV2/SelectItemV2.stories.js +26 -0
- package/src/components/atoms/SelectItemV2/index.js +61 -0
- package/src/components/atoms/SelectItemV2/styles.js +90 -0
- package/src/components/atoms/Tooltip/Tooltip.stories.js +51 -0
- package/src/components/atoms/Tooltip/index.js +59 -0
- package/src/components/atoms/Tooltip/styles.js +42 -0
- package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +54 -0
- package/src/components/molecules/ButtonDownloadFile/index.js +111 -0
- package/src/components/molecules/ButtonDownloadFile/styles.js +66 -0
- package/src/components/molecules/CustomSelect/CustomSelect.stories.js +20 -12
- package/src/components/molecules/CustomSelect/SelectItem.js +7 -0
- package/src/components/molecules/Dropdown/Dropdown.stories.js +103 -0
- package/src/components/molecules/Dropdown/index.js +150 -0
- package/src/components/molecules/Dropdown/styles.js +75 -0
- package/src/components/molecules/HeaderTop/index.js +11 -6
- package/src/components/molecules/HeaderTop/styles.js +4 -0
- package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +68 -0
- package/src/components/molecules/ImageTooltip/index.js +63 -0
- package/src/components/molecules/ImageTooltip/styles.js +18 -0
- package/src/components/molecules/SelectV2/SelectV2.stories.js +114 -0
- package/src/components/molecules/SelectV2/index.js +335 -0
- package/src/components/molecules/SelectV2/styles.js +105 -0
- package/src/components/organisms/Chat/Chat.stories.js +199 -0
- package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +65 -0
- package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
- package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
- package/src/components/organisms/Chat/ChatLists/index.js +141 -0
- package/src/components/organisms/Chat/ChatLists/styles.js +162 -0
- package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +142 -0
- package/src/components/organisms/Chat/ContainerItems/index.js +549 -0
- package/src/components/organisms/Chat/ContainerItems/styles.js +328 -0
- package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +102 -0
- package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
- package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
- package/src/components/organisms/Chat/ContentChat/index.js +900 -0
- package/src/components/organisms/Chat/ContentChat/styles.js +41 -0
- package/src/components/organisms/Chat/Footer/Footer.stories.js +22 -0
- package/src/components/organisms/Chat/Footer/index.js +669 -0
- package/src/components/organisms/Chat/Footer/styles.js +286 -0
- package/src/components/organisms/Chat/Header/Header.stories.js +66 -0
- package/src/components/organisms/Chat/Header/index.js +94 -0
- package/src/components/organisms/Chat/Header/styles.js +49 -0
- package/src/components/organisms/Chat/index.js +294 -0
- package/src/components/organisms/Chat/styles.js +42 -0
- package/src/components/organisms/CreateVersion/RenderChilds.js +34 -28
- package/src/components/organisms/CreateVersion/index.js +36 -16
- package/src/components/organisms/Modal/Modal.stories.js +55 -0
- package/src/components/organisms/Modal/index.js +97 -0
- package/src/components/organisms/Modal/styles.js +103 -0
- package/src/components/organisms/OrderDetail/OrderDetail.stories.js +1 -1
- package/src/components/organisms/OrderDetail/index.js +12 -19
- package/src/components/organisms/OrderDetail/styles.js +0 -1
- package/src/components/organisms/OrderDetail/utils/Table/styles.js +0 -30
- package/src/components/organisms/OrderDetail/utils/Table/utils.js +15 -30
- package/src/components/organisms/VersionSelector/index.js +3 -18
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +166 -75
- package/src/components/pages/ProviderProductEdition/index.js +21 -2
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +67 -79
- package/src/components/pages/RetailerProductEdition/index.js +14 -2
- package/src/global-files/customHooks.js +2 -2
- package/src/global-files/fonts.css +12 -0
- package/src/global-files/handle_http.js +231 -0
- package/src/global-files/utils.js +300 -0
- package/src/global-files/variables.js +2 -0
- package/src/index.js +16 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContainerBtnPopUpChat,
|
|
3
|
+
ContainerFixed,
|
|
4
|
+
ContainerPopUp,
|
|
5
|
+
} from "./styles";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
8
|
+
import { ContentChat } from "./ContentChat";
|
|
9
|
+
import { faComments as IconChat } from "@fortawesome/free-solid-svg-icons";
|
|
10
|
+
import { Slide } from "@mui/material";
|
|
11
|
+
import {
|
|
12
|
+
isStringEmpty,
|
|
13
|
+
isValidNaturalNumber,
|
|
14
|
+
} from "../../../global-files/utils";
|
|
15
|
+
|
|
16
|
+
export const Chat = (props) => {
|
|
17
|
+
const {
|
|
18
|
+
chatType, // "merchant_product" | "order_product" | "ticket"
|
|
19
|
+
chatContainerType, // ("fixed") | ("popUp")
|
|
20
|
+
chatData, // {} => aqui poner los datos requeridos segun el tipo de chat
|
|
21
|
+
classNameContainerFixed, // clases CSS del envoltoria chat fixed
|
|
22
|
+
} = props;
|
|
23
|
+
const [showPopUpChat, setShowPopUpChat] = useState(false);
|
|
24
|
+
const [data, setData] = useState();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
switch (chatType) {
|
|
28
|
+
case "merchant_product":
|
|
29
|
+
validateChatMerchantProduct();
|
|
30
|
+
break;
|
|
31
|
+
case "order_product":
|
|
32
|
+
validateChatOrderProduct();
|
|
33
|
+
break;
|
|
34
|
+
case "ticket":
|
|
35
|
+
validateChatTicket();
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
setData({
|
|
39
|
+
code: 404,
|
|
40
|
+
message: `El tipo de chat especificado "${chatType}" no es valido`,
|
|
41
|
+
errorDetail: "",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [chatType]);
|
|
45
|
+
|
|
46
|
+
// validar props que se requieren para el tipo de chat "order_product"
|
|
47
|
+
const validateChatOrderProduct = () => {
|
|
48
|
+
const {
|
|
49
|
+
userToken, // string
|
|
50
|
+
id, // number
|
|
51
|
+
orderId, // number
|
|
52
|
+
retailerId, // number
|
|
53
|
+
} = chatData;
|
|
54
|
+
|
|
55
|
+
// validar token del user
|
|
56
|
+
if (isStringEmpty(userToken)) {
|
|
57
|
+
setDataError("El token del usuario no es valido");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// validar ID del producto
|
|
61
|
+
if (!isValidNaturalNumber(id)) {
|
|
62
|
+
setDataError("El ID del producto no es valido");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// validar el ID de la OT en donde se encuentra el producto
|
|
66
|
+
if (!isValidNaturalNumber(orderId)) {
|
|
67
|
+
setDataError("El ID de la orden del producto no es valido");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// validar el ID de la cadena asociada al producto en la OT
|
|
71
|
+
if (!isValidNaturalNumber(retailerId)) {
|
|
72
|
+
setDataError("La cadena relacionada al producto no es valida");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setData({
|
|
76
|
+
userToken,
|
|
77
|
+
id,
|
|
78
|
+
orderId,
|
|
79
|
+
retailerId,
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// validar props que se requieren para el tipo de chat "merchants_product"
|
|
84
|
+
const validateChatMerchantProduct = () => {
|
|
85
|
+
const {
|
|
86
|
+
userToken, // string
|
|
87
|
+
id, // number
|
|
88
|
+
version, // number
|
|
89
|
+
} = chatData;
|
|
90
|
+
|
|
91
|
+
// validar token del user
|
|
92
|
+
if (isStringEmpty(userToken)) {
|
|
93
|
+
setDataError("El token del usuario no es valido");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// validar ID del producto
|
|
97
|
+
if (!isValidNaturalNumber(id)) {
|
|
98
|
+
setDataError("El ID del producto no es valido");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// validar la version del producto
|
|
102
|
+
if (!isValidNaturalNumber(version)) {
|
|
103
|
+
setDataError("La version del producto no es valida");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setData({
|
|
107
|
+
userToken,
|
|
108
|
+
id,
|
|
109
|
+
version,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// validar props que se requieren para el tipo de chat "ticket"
|
|
114
|
+
const validateChatTicket = () => {
|
|
115
|
+
const {
|
|
116
|
+
currentUser /* {
|
|
117
|
+
id: number ,
|
|
118
|
+
companyId: number ,
|
|
119
|
+
isUserTech: boolean ,
|
|
120
|
+
} */,
|
|
121
|
+
id, // number
|
|
122
|
+
statusTicket, // (string) "IN_PROGRESS" | "PENDING" | "COMPLETED"
|
|
123
|
+
ticketOwnerUserId, // number
|
|
124
|
+
} = chatData;
|
|
125
|
+
|
|
126
|
+
// validar si ID del usuario conectado
|
|
127
|
+
if (!isValidNaturalNumber(currentUser?.id)) {
|
|
128
|
+
setDataError("Tu ID de usuario no fue especificado");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// validar si ID de la compañia del usuario conectado
|
|
132
|
+
if (!isValidNaturalNumber(currentUser?.companyId)) {
|
|
133
|
+
setDataError("El ID de tu compañia no fue especificado");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// validar si el usuario conectado es de tecnologia o no
|
|
137
|
+
if (
|
|
138
|
+
currentUser?.isUserTech === undefined ||
|
|
139
|
+
typeof currentUser.isUserTech !== "boolean"
|
|
140
|
+
) {
|
|
141
|
+
setDataError("Tu tipo de usuario no fue especificado");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// validar ID del ticket
|
|
145
|
+
if (!isValidNaturalNumber(id)) {
|
|
146
|
+
setDataError("El ID del ticket no es valido");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// validar ID del usuario que creó el ticket
|
|
150
|
+
if (!isValidNaturalNumber(ticketOwnerUserId)) {
|
|
151
|
+
setDataError(
|
|
152
|
+
"El ID del usuario al que le pertenece el ticket no es valido"
|
|
153
|
+
);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// validar el status del chat
|
|
157
|
+
if (isStringEmpty(statusTicket)) {
|
|
158
|
+
setDataError("El estatus del ticket no es valido");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
let statusChat = "open";
|
|
162
|
+
if (statusTicket === "COMPLETED") statusChat = "closed";
|
|
163
|
+
|
|
164
|
+
// convertir user TECH a NORMAL si es el propietario del ticket
|
|
165
|
+
let isUserTech = currentUser.isUserTech;
|
|
166
|
+
if (isUserTech && currentUser.id == ticketOwnerUserId) {
|
|
167
|
+
isUserTech = false;
|
|
168
|
+
}
|
|
169
|
+
setData({
|
|
170
|
+
currentUser: {
|
|
171
|
+
...currentUser,
|
|
172
|
+
isUserTech,
|
|
173
|
+
},
|
|
174
|
+
id,
|
|
175
|
+
statusChat,
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const setDataError = (errorDetail) => {
|
|
180
|
+
setData({
|
|
181
|
+
code: 404,
|
|
182
|
+
message: `No se especificaron algunos datos requeridos para el tipo de chat "${chatType}"`,
|
|
183
|
+
errorDetail,
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
const createItem = async (valueType, valueInput) => {
|
|
189
|
+
clearTimeout(processUpdateID);
|
|
190
|
+
let currentItems = items.slice();
|
|
191
|
+
let paramsBody = {};
|
|
192
|
+
let paramsHeaders = {};
|
|
193
|
+
switch (chatType.toLowerCase()) {
|
|
194
|
+
case "order_product": //------------------------------------------
|
|
195
|
+
paramsBody = {
|
|
196
|
+
articleId: articleId,
|
|
197
|
+
valueType: valueType,
|
|
198
|
+
value: valueInput,
|
|
199
|
+
isOrderProduct: "1",
|
|
200
|
+
orderId: orderId,
|
|
201
|
+
retailerId: retailerId,
|
|
202
|
+
};
|
|
203
|
+
paramsHeaders = { Authorization: userToken };
|
|
204
|
+
break;
|
|
205
|
+
|
|
206
|
+
default:
|
|
207
|
+
// merchants_products--------------------------------------
|
|
208
|
+
paramsBody = {
|
|
209
|
+
articleId: articleId,
|
|
210
|
+
articleVersion: articleVersion,
|
|
211
|
+
valueType: valueType,
|
|
212
|
+
value: valueInput,
|
|
213
|
+
isOrderProduct: "0",
|
|
214
|
+
};
|
|
215
|
+
paramsHeaders = { Authorization: userToken };
|
|
216
|
+
}
|
|
217
|
+
const response = await fetchPOST(
|
|
218
|
+
process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
|
|
219
|
+
paramsBody,
|
|
220
|
+
paramsHeaders
|
|
221
|
+
);
|
|
222
|
+
if (!response.body) {
|
|
223
|
+
let itemType =
|
|
224
|
+
valueType === "txt"
|
|
225
|
+
? "el mensaje"
|
|
226
|
+
: valueType === "img"
|
|
227
|
+
? "la imagen"
|
|
228
|
+
: "el archivo";
|
|
229
|
+
showModalAlert(
|
|
230
|
+
`No fue posible agregar ${itemType} en el chat`,
|
|
231
|
+
response.errorDetail,
|
|
232
|
+
"error"
|
|
233
|
+
);
|
|
234
|
+
setItems(currentItems);
|
|
235
|
+
} else {
|
|
236
|
+
if (currentItems?.length == 0) {
|
|
237
|
+
// console.log("NUEVO ITEM <> NUEVO INITIAL");
|
|
238
|
+
await getInitial();
|
|
239
|
+
} else {
|
|
240
|
+
// console.log("NUEVO ITEM <> NUEVO UPDATE");
|
|
241
|
+
await getUpdate();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<>
|
|
249
|
+
{chatContainerType?.toLowerCase() === "fixed" ? (
|
|
250
|
+
<>
|
|
251
|
+
{/* chat tipo fixed */}
|
|
252
|
+
<ContainerFixed className={classNameContainerFixed}>
|
|
253
|
+
<ContentChat
|
|
254
|
+
chatType={chatType?.toLowerCase()}
|
|
255
|
+
chatContainerType={"fixed"}
|
|
256
|
+
dataChat={data}
|
|
257
|
+
showBtnClose={false}
|
|
258
|
+
/>
|
|
259
|
+
</ContainerFixed>
|
|
260
|
+
</>
|
|
261
|
+
) : (
|
|
262
|
+
<>
|
|
263
|
+
{/* chat tipo popUp */}
|
|
264
|
+
<ContainerBtnPopUpChat>
|
|
265
|
+
<ButtonV2
|
|
266
|
+
className={"container-btn-popUpChat"}
|
|
267
|
+
type={"whiteS2"}
|
|
268
|
+
size={14}
|
|
269
|
+
borderType={"circle"}
|
|
270
|
+
icon={IconChat}
|
|
271
|
+
onClick={async (event) => {
|
|
272
|
+
setShowPopUpChat(!showPopUpChat);
|
|
273
|
+
}}
|
|
274
|
+
/>
|
|
275
|
+
</ContainerBtnPopUpChat>
|
|
276
|
+
|
|
277
|
+
<Slide direction={"left"} in={showPopUpChat} timeout={400}>
|
|
278
|
+
<ContainerPopUp>
|
|
279
|
+
<ContentChat
|
|
280
|
+
chatType={chatType?.toLowerCase()}
|
|
281
|
+
chatContainerType={"popUp"}
|
|
282
|
+
dataChat={data}
|
|
283
|
+
showBtnClose={true}
|
|
284
|
+
onClickBtnClose={() => {
|
|
285
|
+
setShowPopUpChat(false);
|
|
286
|
+
}}
|
|
287
|
+
/>
|
|
288
|
+
</ContainerPopUp>
|
|
289
|
+
</Slide>
|
|
290
|
+
</>
|
|
291
|
+
)}
|
|
292
|
+
</>
|
|
293
|
+
);
|
|
294
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { GlobalColors, FontFamily } from "../../../global-files/variables";
|
|
3
|
+
|
|
4
|
+
// Container para chat fixed
|
|
5
|
+
export const ContainerFixed = styled.div`
|
|
6
|
+
width: auto;
|
|
7
|
+
max-width: 550px;
|
|
8
|
+
min-width: 325px;
|
|
9
|
+
height: 100%;
|
|
10
|
+
flex-grow: 2;
|
|
11
|
+
background-color: white;
|
|
12
|
+
border: 1px solid #f0f0f0;
|
|
13
|
+
z-index: 1000;
|
|
14
|
+
padding: 0px;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const ContainerBtnPopUpChat = styled.div`
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
height: 34px;
|
|
20
|
+
width: 34px;
|
|
21
|
+
|
|
22
|
+
.container-btn-popUpChat {
|
|
23
|
+
height: inherit;
|
|
24
|
+
width: inherit;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const ContainerPopUp = styled.div`
|
|
30
|
+
position: fixed;
|
|
31
|
+
top: 20px;
|
|
32
|
+
right: 23px;
|
|
33
|
+
bottom: 20px;
|
|
34
|
+
box-shadow: 0px 2px 10px 0px #00000073;
|
|
35
|
+
z-index: 1000;
|
|
36
|
+
width: calc(100% - 50px);
|
|
37
|
+
max-width: 550px;
|
|
38
|
+
min-width: 325px;
|
|
39
|
+
border-radius: 10px;
|
|
40
|
+
background: white;
|
|
41
|
+
padding: 0px;
|
|
42
|
+
`;
|
|
@@ -21,25 +21,27 @@ export const Children = (
|
|
|
21
21
|
<img src={createVersionImg} alt="create version icon" />
|
|
22
22
|
<ScreenHeader
|
|
23
23
|
fontFamily={FontFamily.Raleway_500}
|
|
24
|
-
headerType="product-name-header"
|
|
24
|
+
headerType={"product-name-header"}
|
|
25
25
|
color={GlobalColors.white}
|
|
26
|
-
text="Crea una nueva versión"
|
|
26
|
+
text={"Crea una nueva versión"}
|
|
27
27
|
/>
|
|
28
28
|
<ScreenHeader
|
|
29
29
|
fontFamily={FontFamily.Raleway}
|
|
30
|
-
headerType="retailer-name-header"
|
|
30
|
+
headerType={"retailer-name-header"}
|
|
31
31
|
color={GlobalColors.white}
|
|
32
|
-
text=
|
|
32
|
+
text={
|
|
33
|
+
"Puedes elegir el contenido de versiones anteriores o crear una versión desde cero"
|
|
34
|
+
}
|
|
33
35
|
/>
|
|
34
36
|
<div className="buttons-container">
|
|
35
37
|
<Button
|
|
36
|
-
label="Versión desde cero"
|
|
37
|
-
buttonType="general-transparent-button"
|
|
38
|
+
label={"Versión desde cero"}
|
|
39
|
+
buttonType={"general-transparent-button"}
|
|
38
40
|
onClick={() => setStep("empty-version")}
|
|
39
41
|
/>
|
|
40
42
|
<Button
|
|
41
|
-
label="Versión personalizada"
|
|
42
|
-
buttonType="general-default-button"
|
|
43
|
+
label={"Versión personalizada"}
|
|
44
|
+
buttonType={"general-default-button"}
|
|
43
45
|
onClick={() => setStep("create-version")}
|
|
44
46
|
/>
|
|
45
47
|
</div>
|
|
@@ -51,25 +53,27 @@ export const Children = (
|
|
|
51
53
|
<img src={genericModalWarning} alt="warning icon" />
|
|
52
54
|
<ScreenHeader
|
|
53
55
|
fontFamily={FontFamily.Raleway_500}
|
|
54
|
-
headerType="product-name-header"
|
|
56
|
+
headerType={"product-name-header"}
|
|
55
57
|
color={GlobalColors.white}
|
|
56
|
-
text=
|
|
58
|
+
text={
|
|
59
|
+
"Si creas una versión desde cero perderas la información actual"
|
|
60
|
+
}
|
|
57
61
|
/>
|
|
58
62
|
<ScreenHeader
|
|
59
63
|
fontFamily={FontFamily.Raleway}
|
|
60
|
-
headerType="retailer-name-header"
|
|
64
|
+
headerType={"retailer-name-header"}
|
|
61
65
|
color={GlobalColors.white}
|
|
62
|
-
text="¿Deseas Continuar?"
|
|
66
|
+
text={"¿Deseas Continuar?"}
|
|
63
67
|
/>
|
|
64
68
|
<div className="buttons-container">
|
|
65
69
|
<Button
|
|
66
|
-
label="Atrás"
|
|
67
|
-
buttonType="general-transparent-button"
|
|
70
|
+
label={"Atrás"}
|
|
71
|
+
buttonType={"general-transparent-button"}
|
|
68
72
|
onClick={() => setStep("version-options")}
|
|
69
73
|
/>
|
|
70
74
|
<Button
|
|
71
|
-
label="Continuar"
|
|
72
|
-
buttonType="general-default-button"
|
|
75
|
+
label={"Continuar"}
|
|
76
|
+
buttonType={"general-default-button"}
|
|
73
77
|
onClick={() => createVersion(true)}
|
|
74
78
|
/>
|
|
75
79
|
</div>
|
|
@@ -80,16 +84,18 @@ export const Children = (
|
|
|
80
84
|
<CreateVersion>
|
|
81
85
|
<ScreenHeader
|
|
82
86
|
fontFamily={FontFamily.Raleway_500}
|
|
83
|
-
headerType="retailer-name-header"
|
|
87
|
+
headerType={"retailer-name-header"}
|
|
84
88
|
color={GlobalColors.white}
|
|
85
|
-
text=
|
|
89
|
+
text={
|
|
90
|
+
"Elige el contenido que deseas utilizar de versiones anteriores"
|
|
91
|
+
}
|
|
86
92
|
/>
|
|
87
93
|
<div className="version-selector">
|
|
88
94
|
<div className="selector">
|
|
89
95
|
<VersionSelect
|
|
90
96
|
versions={versions}
|
|
91
|
-
label="Ficha técnica"
|
|
92
|
-
id="datasheet"
|
|
97
|
+
label={"Ficha técnica"}
|
|
98
|
+
id={"datasheet"}
|
|
93
99
|
selectedVersions={selectedVersions}
|
|
94
100
|
onChange={(e) => onChange(e)}
|
|
95
101
|
/>
|
|
@@ -97,8 +103,8 @@ export const Children = (
|
|
|
97
103
|
<div className="selector">
|
|
98
104
|
<VersionSelect
|
|
99
105
|
versions={versions}
|
|
100
|
-
label="Descripción"
|
|
101
|
-
id="description"
|
|
106
|
+
label={"Descripción"}
|
|
107
|
+
id={"description"}
|
|
102
108
|
selectedVersions={selectedVersions}
|
|
103
109
|
onChange={(e) => onChange(e)}
|
|
104
110
|
/>
|
|
@@ -106,8 +112,8 @@ export const Children = (
|
|
|
106
112
|
<div className="selector">
|
|
107
113
|
<VersionSelect
|
|
108
114
|
versions={versions}
|
|
109
|
-
label="Imágenes"
|
|
110
|
-
id="image"
|
|
115
|
+
label={"Imágenes"}
|
|
116
|
+
id={"image"}
|
|
111
117
|
selectedVersions={selectedVersions}
|
|
112
118
|
onChange={(e) => onChange(e)}
|
|
113
119
|
/>
|
|
@@ -115,13 +121,13 @@ export const Children = (
|
|
|
115
121
|
</div>
|
|
116
122
|
<div className="buttons-container">
|
|
117
123
|
<Button
|
|
118
|
-
label="Atrás"
|
|
119
|
-
buttonType="general-transparent-button"
|
|
124
|
+
label={"Atrás"}
|
|
125
|
+
buttonType={"general-transparent-button"}
|
|
120
126
|
onClick={() => setStep("version-options")}
|
|
121
127
|
/>
|
|
122
128
|
<Button
|
|
123
|
-
label="Continuar"
|
|
124
|
-
buttonType="general-default-button"
|
|
129
|
+
label={"Continuar"}
|
|
130
|
+
buttonType={"general-default-button"}
|
|
125
131
|
onClick={() => createVersion()}
|
|
126
132
|
/>
|
|
127
133
|
</div>
|
|
@@ -5,32 +5,48 @@ import { useEffect, useState } from "react";
|
|
|
5
5
|
import { Children } from "./RenderChilds";
|
|
6
6
|
import axios from "axios";
|
|
7
7
|
|
|
8
|
-
export const CreateVersion = ({
|
|
9
|
-
articleId,
|
|
10
|
-
version,
|
|
11
|
-
setShowCreateVersion,
|
|
12
|
-
versionsList,
|
|
13
|
-
realoadVersion,
|
|
14
|
-
jwt,
|
|
15
|
-
}) => {
|
|
8
|
+
export const CreateVersion = ({ idArticle, version, setShowCreateVersion }) => {
|
|
16
9
|
const [step, setStep] = useState("version-options");
|
|
10
|
+
const [versions, setVersions] = useState([]);
|
|
17
11
|
const [selectedVersions, setSelectedVersions] = useState({
|
|
18
12
|
datasheet: version,
|
|
19
13
|
description: version,
|
|
20
14
|
image: version,
|
|
21
15
|
});
|
|
22
16
|
|
|
17
|
+
const getVersions = async () => {
|
|
18
|
+
try {
|
|
19
|
+
const response = await axios({
|
|
20
|
+
method: "get",
|
|
21
|
+
url: `${process.env.REACT_APP_VERSIONS_ENDPOINT}?articleId=${idArticle}&provider=true`,
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: sessionStorage.getItem("jwt"),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
setVersions(JSON.parse(response.data.body).data);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.log(error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
23
32
|
const createVersion = async (isEmpty) => {
|
|
24
33
|
try {
|
|
25
|
-
let data = {
|
|
34
|
+
let data = {
|
|
35
|
+
articleId: idArticle,
|
|
36
|
+
isEmpty,
|
|
37
|
+
};
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
isEmpty && (data["version"] = selectedVersions);
|
|
28
40
|
|
|
29
|
-
await axios
|
|
30
|
-
|
|
41
|
+
await axios({
|
|
42
|
+
method: "post",
|
|
43
|
+
url: process.env.REACT_APP_VERSIONS_ENDPOINT,
|
|
44
|
+
data: data,
|
|
45
|
+
headers: {
|
|
46
|
+
Authorization: sessionStorage.getItem("jwt"),
|
|
47
|
+
},
|
|
31
48
|
});
|
|
32
49
|
setShowCreateVersion(false);
|
|
33
|
-
realoadVersion && realoadVersion();
|
|
34
50
|
} catch (error) {
|
|
35
51
|
console.log(error);
|
|
36
52
|
}
|
|
@@ -39,13 +55,17 @@ export const CreateVersion = ({
|
|
|
39
55
|
const onChange = (e) => {
|
|
40
56
|
setSelectedVersions({
|
|
41
57
|
...selectedVersions,
|
|
42
|
-
[e.target.name]: parseInt(e.target.value),
|
|
58
|
+
[e.target.name]: parseInt(e.target.value.slice(-1)),
|
|
43
59
|
});
|
|
44
60
|
};
|
|
45
61
|
|
|
62
|
+
useEffect(async () => {
|
|
63
|
+
await getVersions();
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
46
66
|
return (
|
|
47
67
|
<Container>
|
|
48
|
-
<div
|
|
68
|
+
<div className="modal-container">
|
|
49
69
|
<div className="button-container">
|
|
50
70
|
<Button
|
|
51
71
|
image={closeIcon}
|
|
@@ -57,7 +77,7 @@ export const CreateVersion = ({
|
|
|
57
77
|
{Children(
|
|
58
78
|
step,
|
|
59
79
|
setStep,
|
|
60
|
-
|
|
80
|
+
versions,
|
|
61
81
|
selectedVersions,
|
|
62
82
|
onChange,
|
|
63
83
|
createVersion
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Modal } from "./index";
|
|
2
|
+
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Components/organisms/Modal",
|
|
6
|
+
component: Modal,
|
|
7
|
+
argTypes: {
|
|
8
|
+
icon: {
|
|
9
|
+
options: [undefined, "error", "warning", "success", "info"],
|
|
10
|
+
control: { type: "select" },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Template = (args) => <Modal {...args} />;
|
|
16
|
+
|
|
17
|
+
export const modalDefault = Template.bind({});
|
|
18
|
+
modalDefault.args = {
|
|
19
|
+
show: false,
|
|
20
|
+
title: "Titulo del modal",
|
|
21
|
+
icon: undefined,
|
|
22
|
+
message: `descripcion amplia sobre el componente
|
|
23
|
+
modal white para saber como se ven varias lineas
|
|
24
|
+
de codigo`,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const modalWithButtons = Template.bind({});
|
|
28
|
+
modalWithButtons.args = {
|
|
29
|
+
show: false,
|
|
30
|
+
title: "Titulo del modal",
|
|
31
|
+
icon: undefined,
|
|
32
|
+
message: `descripcion amplia sobre el componente
|
|
33
|
+
modal white para saber como se ven varias lineas
|
|
34
|
+
de codigo`,
|
|
35
|
+
buttons: [
|
|
36
|
+
<ButtonV2
|
|
37
|
+
key={"btn-Cancelar"}
|
|
38
|
+
type={"white"}
|
|
39
|
+
label={"Cancelar"}
|
|
40
|
+
size={12}
|
|
41
|
+
onClick={(event) => {
|
|
42
|
+
alert("cancelar");
|
|
43
|
+
}}
|
|
44
|
+
/>,
|
|
45
|
+
<ButtonV2
|
|
46
|
+
key={"btn-Aceptar"}
|
|
47
|
+
type={"pink"}
|
|
48
|
+
label={"Aceptar"}
|
|
49
|
+
size={12}
|
|
50
|
+
onClick={(event) => {
|
|
51
|
+
alert("aceptar");
|
|
52
|
+
}}
|
|
53
|
+
/>,
|
|
54
|
+
],
|
|
55
|
+
};
|