contentoh-components-library 21.3.93 → 21.3.94
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/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/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/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/FullProductNameHeader/index.js +2 -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 +175 -188
- 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 +273 -265
- 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/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/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/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 -10
- 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/FullProductNameHeader/index.js +1 -1
- 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 +129 -132
- 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 +135 -109
- 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/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
|
@@ -24,20 +24,15 @@ import descriptionSent from "../../../assets/images/modalsSVGs/descriptionSent.s
|
|
|
24
24
|
import imagesSent from "../../../assets/images/modalsSVGs/uploadingImages.svg";
|
|
25
25
|
import { TagAndInput } from "../../molecules/TagAndInput/index";
|
|
26
26
|
import { Button } from "../../atoms/GeneralButton";
|
|
27
|
+
import { Commentary } from "../../atoms/Commentary";
|
|
27
28
|
import { GenericModal } from "../../atoms/GenericModal";
|
|
28
29
|
import { ScreenHeader } from "../../atoms/ScreenHeader";
|
|
29
30
|
import { Loading } from "../../atoms/Loading";
|
|
30
31
|
import succes from "../../../assets/images/genericModal/genericModalCheck.svg";
|
|
32
|
+
import errorModal from "../../../assets/images/genericModal/errorModal.svg";
|
|
31
33
|
import { VersionSelector } from "../../organisms/VersionSelector";
|
|
32
34
|
import { useCloseModal } from "../../../global-files/customHooks";
|
|
33
|
-
import {
|
|
34
|
-
getAuditVersion,
|
|
35
|
-
getInputsData,
|
|
36
|
-
createMessage,
|
|
37
|
-
sendMessage,
|
|
38
|
-
} from "./utils";
|
|
39
|
-
import { Modal } from "../../organisms/Modal";
|
|
40
|
-
import { ButtonV2 } from "../../atoms/ButtonV2";
|
|
35
|
+
import { getAuditVersion, getInputsData } from "./utils";
|
|
41
36
|
|
|
42
37
|
const reducerImages = (state, action) => {
|
|
43
38
|
let { values, attrForImgs, inputsByRetailer } = state;
|
|
@@ -137,7 +132,6 @@ export const RetailerProductEdition = ({
|
|
|
137
132
|
const [datasheets, setDatasheets] = useState([]);
|
|
138
133
|
const [images, setImages] = useReducer(reducerImages, {});
|
|
139
134
|
const [showModal, setShowModal] = useState(false);
|
|
140
|
-
const [showRejectModal, setShowRejectModal] = useState(false);
|
|
141
135
|
const { getRootProps, getInputProps } = useDropzone({
|
|
142
136
|
accept: "image/*",
|
|
143
137
|
noKeyboard: true,
|
|
@@ -224,7 +218,6 @@ export const RetailerProductEdition = ({
|
|
|
224
218
|
const [auditDescriptions, setAuditDescriptions] = useState([]);
|
|
225
219
|
const [auditImages, setAuditImages] = useState([]);
|
|
226
220
|
const [compare, setCompare] = useState(false);
|
|
227
|
-
const [valRejAll, setValRejAll] = useState(false);
|
|
228
221
|
|
|
229
222
|
useEffect(async () => {
|
|
230
223
|
const { id_article } = product?.article || {};
|
|
@@ -862,25 +855,6 @@ export const RetailerProductEdition = ({
|
|
|
862
855
|
const { newStatus, newOrderStatus, newArticleStatus } = JSON.parse(
|
|
863
856
|
res.data.body
|
|
864
857
|
);
|
|
865
|
-
const messageToChat = createMessage(
|
|
866
|
-
product.retailers,
|
|
867
|
-
activeRetailer.id,
|
|
868
|
-
evalStatus,
|
|
869
|
-
newStatus,
|
|
870
|
-
activeTab
|
|
871
|
-
);
|
|
872
|
-
|
|
873
|
-
const data = {
|
|
874
|
-
paramsBody: {
|
|
875
|
-
id: product.article.id_article,
|
|
876
|
-
version: version,
|
|
877
|
-
items: [{ type: "status", value: messageToChat }],
|
|
878
|
-
retailerId: activeRetailer.id,
|
|
879
|
-
status: product.status,
|
|
880
|
-
},
|
|
881
|
-
paramsHeader: { Authorization: token },
|
|
882
|
-
};
|
|
883
|
-
await sendMessage(data);
|
|
884
858
|
if (newOrderStatus) productTemp.status = newArticleStatus[articleId];
|
|
885
859
|
productTemp[`${concept}_status`] = newStatus;
|
|
886
860
|
await loadData();
|
|
@@ -923,19 +897,35 @@ export const RetailerProductEdition = ({
|
|
|
923
897
|
return product?.article[`id_auditor`] === user.id_user;
|
|
924
898
|
};
|
|
925
899
|
|
|
926
|
-
const createComment = async (
|
|
900
|
+
const createComment = async (e, body, tab) => {
|
|
901
|
+
let concept = "";
|
|
902
|
+
switch (activeTab) {
|
|
903
|
+
case "Ficha técnica":
|
|
904
|
+
concept = "datasheet";
|
|
905
|
+
break;
|
|
906
|
+
case "Imágenes":
|
|
907
|
+
concept = "images";
|
|
908
|
+
break;
|
|
909
|
+
|
|
910
|
+
default:
|
|
911
|
+
concept = "description";
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
927
914
|
const data = {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
status: product.status,
|
|
934
|
-
},
|
|
935
|
-
paramsHeader: { Authorization: token },
|
|
915
|
+
articleId: product?.article?.id_article,
|
|
916
|
+
orderId: product?.orderId,
|
|
917
|
+
message: body?.replace(/<.*?\/?>/gm, ""),
|
|
918
|
+
concept: concept,
|
|
919
|
+
version: version,
|
|
936
920
|
};
|
|
921
|
+
await axios.post(`${process.env.REACT_APP_COMMENTS_ENDPOINT}`, data, {
|
|
922
|
+
headers: {
|
|
923
|
+
Authorization: token,
|
|
924
|
+
},
|
|
925
|
+
});
|
|
926
|
+
await getComments(tab);
|
|
937
927
|
setMessage("");
|
|
938
|
-
|
|
928
|
+
setComponentsArray([]);
|
|
939
929
|
};
|
|
940
930
|
|
|
941
931
|
const getRequired = (services) => {
|
|
@@ -1217,8 +1207,6 @@ export const RetailerProductEdition = ({
|
|
|
1217
1207
|
break;
|
|
1218
1208
|
}
|
|
1219
1209
|
|
|
1220
|
-
const messages = [];
|
|
1221
|
-
|
|
1222
1210
|
servicesData?.forEach((ret) => {
|
|
1223
1211
|
if (conceptArray.includes(ret.service)) {
|
|
1224
1212
|
let data = {
|
|
@@ -1229,21 +1217,6 @@ export const RetailerProductEdition = ({
|
|
|
1229
1217
|
evalStatus: ret.status,
|
|
1230
1218
|
retailerId: ret.id_retailer,
|
|
1231
1219
|
};
|
|
1232
|
-
if (product[`${ret.service}_status`] !== "NS") {
|
|
1233
|
-
const message = createMessage(
|
|
1234
|
-
product.retailers,
|
|
1235
|
-
ret.id_retailer,
|
|
1236
|
-
product[`${ret.service}_status`],
|
|
1237
|
-
`${result}A`,
|
|
1238
|
-
ret.service
|
|
1239
|
-
);
|
|
1240
|
-
messages.push(
|
|
1241
|
-
createComment(
|
|
1242
|
-
[{ type: "status", value: message }],
|
|
1243
|
-
ret.id_retailer
|
|
1244
|
-
)
|
|
1245
|
-
);
|
|
1246
|
-
}
|
|
1247
1220
|
evaluationArray.push(
|
|
1248
1221
|
axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
|
|
1249
1222
|
headers: {
|
|
@@ -1253,19 +1226,19 @@ export const RetailerProductEdition = ({
|
|
|
1253
1226
|
);
|
|
1254
1227
|
}
|
|
1255
1228
|
});
|
|
1229
|
+
|
|
1256
1230
|
await Promise.all(evaluationArray);
|
|
1257
1231
|
|
|
1258
1232
|
const productTemp = product;
|
|
1259
1233
|
productTemp.status = `${result}A`;
|
|
1260
1234
|
productTemp.datasheet_status =
|
|
1261
|
-
productTemp.datasheet_status === "
|
|
1235
|
+
productTemp.datasheet_status === "NA" ? "NA" : `${result}A`;
|
|
1262
1236
|
productTemp.description_status =
|
|
1263
|
-
productTemp.description_status === "
|
|
1237
|
+
productTemp.description_status === "NA" ? "NA" : `${result}A`;
|
|
1264
1238
|
productTemp.images_status =
|
|
1265
|
-
productTemp.images_status === "
|
|
1239
|
+
productTemp.images_status === "NA" ? "NA" : `${result}A`;
|
|
1266
1240
|
sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
|
|
1267
1241
|
setProduct(productTemp);
|
|
1268
|
-
const messagesResponse = await Promise.all(messages);
|
|
1269
1242
|
|
|
1270
1243
|
await loadData();
|
|
1271
1244
|
} catch (error) {
|
|
@@ -1281,10 +1254,8 @@ export const RetailerProductEdition = ({
|
|
|
1281
1254
|
setCompare={setCompare}
|
|
1282
1255
|
isAuditor={[1, 6].includes(user.id_role)}
|
|
1283
1256
|
withChat={location?.state?.withChat}
|
|
1284
|
-
|
|
1285
|
-
productSelected={product}
|
|
1257
|
+
productSelected={productSelected}
|
|
1286
1258
|
token={token}
|
|
1287
|
-
activeRetailer={activeRetailer}
|
|
1288
1259
|
/>
|
|
1289
1260
|
<div className="data-container">
|
|
1290
1261
|
<div className="image-data-panel">
|
|
@@ -1324,7 +1295,36 @@ export const RetailerProductEdition = ({
|
|
|
1324
1295
|
sendToFacilitator("A");
|
|
1325
1296
|
}}
|
|
1326
1297
|
reject={() => {
|
|
1327
|
-
|
|
1298
|
+
sendToFacilitator("R");
|
|
1299
|
+
setMessage("Rechazado");
|
|
1300
|
+
setComponentsArray([
|
|
1301
|
+
<img src={errorModal} />,
|
|
1302
|
+
<ScreenHeader
|
|
1303
|
+
text={"Agrega tu comentarios para enviar el rechazo"}
|
|
1304
|
+
headerType={"input-name-header"}
|
|
1305
|
+
color={"white"}
|
|
1306
|
+
/>,
|
|
1307
|
+
<TagAndInput
|
|
1308
|
+
label={"Caja de Comentario"}
|
|
1309
|
+
inputType={"textarea"}
|
|
1310
|
+
inputId={"modal-commentary-box"}
|
|
1311
|
+
index={0}
|
|
1312
|
+
color={"white"}
|
|
1313
|
+
/>,
|
|
1314
|
+
<Button
|
|
1315
|
+
buttonType={"general-default-button"}
|
|
1316
|
+
label={"Enviar comentario"}
|
|
1317
|
+
onClick={(e) =>
|
|
1318
|
+
createComment(
|
|
1319
|
+
e,
|
|
1320
|
+
document.querySelector(
|
|
1321
|
+
"#modal-commentary-box .ql-container .ql-editor > p"
|
|
1322
|
+
).innerHTML,
|
|
1323
|
+
activeTab
|
|
1324
|
+
)
|
|
1325
|
+
}
|
|
1326
|
+
/>,
|
|
1327
|
+
]);
|
|
1328
1328
|
}}
|
|
1329
1329
|
showApproveRejectAll={
|
|
1330
1330
|
approveRejectAllButtons() && (auditorAssigned() || userAssigned())
|
|
@@ -1334,8 +1334,36 @@ export const RetailerProductEdition = ({
|
|
|
1334
1334
|
}
|
|
1335
1335
|
approveAll={() => validateAll("A")}
|
|
1336
1336
|
rejectAll={() => {
|
|
1337
|
-
|
|
1338
|
-
|
|
1337
|
+
validateAll("R");
|
|
1338
|
+
setMessage("Rechazado");
|
|
1339
|
+
setComponentsArray([
|
|
1340
|
+
<img src={errorModal} />,
|
|
1341
|
+
<ScreenHeader
|
|
1342
|
+
text={"Agrega tu comentarios para enviar el rechazo"}
|
|
1343
|
+
headerType={"input-name-header"}
|
|
1344
|
+
color={"white"}
|
|
1345
|
+
/>,
|
|
1346
|
+
<TagAndInput
|
|
1347
|
+
label={"Caja de Comentario"}
|
|
1348
|
+
inputType={"textarea"}
|
|
1349
|
+
inputId={"modal-commentary-box"}
|
|
1350
|
+
index={0}
|
|
1351
|
+
color={"white"}
|
|
1352
|
+
/>,
|
|
1353
|
+
<Button
|
|
1354
|
+
buttonType={"general-default-button"}
|
|
1355
|
+
label={"Enviar comentario"}
|
|
1356
|
+
onClick={(e) =>
|
|
1357
|
+
createComment(
|
|
1358
|
+
e,
|
|
1359
|
+
document.querySelector(
|
|
1360
|
+
"#modal-commentary-box .ql-container .ql-editor > p"
|
|
1361
|
+
).innerHTML,
|
|
1362
|
+
activeTab
|
|
1363
|
+
)
|
|
1364
|
+
}
|
|
1365
|
+
/>,
|
|
1366
|
+
]);
|
|
1339
1367
|
}}
|
|
1340
1368
|
/>
|
|
1341
1369
|
<FullTabsMenu
|
|
@@ -1465,6 +1493,47 @@ export const RetailerProductEdition = ({
|
|
|
1465
1493
|
{(userAssigned(activeTab) || auditorAssigned()) &&
|
|
1466
1494
|
product[`${getConcept(activeTab)}_status`] !== "NS" && (
|
|
1467
1495
|
<div className="commentary-box">
|
|
1496
|
+
{!comment ? (
|
|
1497
|
+
<div className="commentary">
|
|
1498
|
+
<TagAndInput
|
|
1499
|
+
label={"Caja de Comentario"}
|
|
1500
|
+
inputType={"textarea"}
|
|
1501
|
+
inputCols={80}
|
|
1502
|
+
inputRows={4}
|
|
1503
|
+
inputId={"commentary-box"}
|
|
1504
|
+
index={0}
|
|
1505
|
+
/>
|
|
1506
|
+
<div className="buttons-box">
|
|
1507
|
+
<Button
|
|
1508
|
+
buttonType={"general-transparent-button"}
|
|
1509
|
+
label={"Enviar comentario"}
|
|
1510
|
+
onClick={(e) =>
|
|
1511
|
+
createComment(
|
|
1512
|
+
e,
|
|
1513
|
+
document.querySelector(
|
|
1514
|
+
"#commentary-box .ql-container .ql-editor > p"
|
|
1515
|
+
).innerHTML,
|
|
1516
|
+
activeTab
|
|
1517
|
+
)
|
|
1518
|
+
}
|
|
1519
|
+
/>
|
|
1520
|
+
</div>
|
|
1521
|
+
</div>
|
|
1522
|
+
) : (
|
|
1523
|
+
<div className="feedback-box">
|
|
1524
|
+
<Commentary
|
|
1525
|
+
comment={comment?.message?.replace(/<.*?\/?>/gm, "")}
|
|
1526
|
+
reviewed={crossComment}
|
|
1527
|
+
/>
|
|
1528
|
+
<Button
|
|
1529
|
+
buttonType={"circular-button accept-button"}
|
|
1530
|
+
onClick={async () => {
|
|
1531
|
+
setCrossComment(true);
|
|
1532
|
+
commentRevised();
|
|
1533
|
+
}}
|
|
1534
|
+
/>
|
|
1535
|
+
</div>
|
|
1536
|
+
)}
|
|
1468
1537
|
{[7, 8].includes(user.id_role) && (
|
|
1469
1538
|
<Button
|
|
1470
1539
|
buttonType={
|
|
@@ -1522,49 +1591,6 @@ export const RetailerProductEdition = ({
|
|
|
1522
1591
|
jwt={token}
|
|
1523
1592
|
/>
|
|
1524
1593
|
)}
|
|
1525
|
-
{showRejectModal && (
|
|
1526
|
-
<Modal
|
|
1527
|
-
title={`Agregar mensaje de rechazo para ${activeTab?.toLowerCase()}`}
|
|
1528
|
-
show={showRejectModal}
|
|
1529
|
-
customComponent={
|
|
1530
|
-
<TagAndInput
|
|
1531
|
-
inputType={"textarea"}
|
|
1532
|
-
inputId={"modal-message-box"}
|
|
1533
|
-
index={0}
|
|
1534
|
-
color={"white"}
|
|
1535
|
-
/>
|
|
1536
|
-
}
|
|
1537
|
-
buttons={[
|
|
1538
|
-
<ButtonV2
|
|
1539
|
-
key={"btn-Cancelar"}
|
|
1540
|
-
type={"white"}
|
|
1541
|
-
label={"Cancelar"}
|
|
1542
|
-
size={12}
|
|
1543
|
-
onClick={() => {
|
|
1544
|
-
setShowRejectModal(false);
|
|
1545
|
-
}}
|
|
1546
|
-
/>,
|
|
1547
|
-
<ButtonV2
|
|
1548
|
-
key={"btn-Aceptar"}
|
|
1549
|
-
type={"pink"}
|
|
1550
|
-
label={"Aceptar"}
|
|
1551
|
-
size={12}
|
|
1552
|
-
onClick={async () => {
|
|
1553
|
-
const body = document.querySelector(
|
|
1554
|
-
"#modal-message-box .ql-container .ql-editor > p"
|
|
1555
|
-
).innerHTML;
|
|
1556
|
-
const messages = [
|
|
1557
|
-
{ type: "message", value: body?.replace(/<.*?\/?>/gm, "") },
|
|
1558
|
-
];
|
|
1559
|
-
await createComment(messages, activeRetailer.id);
|
|
1560
|
-
valRejAll ? validateAll("R") : sendToFacilitator("R");
|
|
1561
|
-
setMessage("Rechazado");
|
|
1562
|
-
setShowRejectModal(false);
|
|
1563
|
-
}}
|
|
1564
|
-
/>,
|
|
1565
|
-
]}
|
|
1566
|
-
/>
|
|
1567
|
-
)}
|
|
1568
1594
|
</Container>
|
|
1569
1595
|
);
|
|
1570
1596
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import { fetchPOST } from "../../../global-files/handle_http";
|
|
3
2
|
|
|
4
3
|
export const getAuditVersion = async (articleId, setState, token) => {
|
|
5
4
|
const auditResponse = await axios.get(
|
|
@@ -33,39 +32,3 @@ export const getInputsData = (
|
|
|
33
32
|
setDescriptionState(descriptions);
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
|
-
|
|
37
|
-
export const translateService = (tab) => {
|
|
38
|
-
switch (tab) {
|
|
39
|
-
case "description":
|
|
40
|
-
case "Descripción":
|
|
41
|
-
return "Descripciones";
|
|
42
|
-
case "datasheet":
|
|
43
|
-
case "Ficha técnica":
|
|
44
|
-
return "Fichas técnicas";
|
|
45
|
-
case "images":
|
|
46
|
-
case "Imágenes":
|
|
47
|
-
return "Imágenes";
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const createMessage = (
|
|
52
|
-
retailers,
|
|
53
|
-
idRetailer,
|
|
54
|
-
oldStatus,
|
|
55
|
-
newStatus,
|
|
56
|
-
service
|
|
57
|
-
) => {
|
|
58
|
-
const [retailer] = retailers?.filter((ret) => ret.id === idRetailer) || [];
|
|
59
|
-
return `${translateService(service)} de ${
|
|
60
|
-
retailer.name
|
|
61
|
-
} |${oldStatus}| a |${newStatus}`;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const sendMessage = async (data) => {
|
|
65
|
-
const { paramsBody, paramsHeader } = data;
|
|
66
|
-
return fetchPOST(
|
|
67
|
-
process.env.REACT_APP_CREATE_MESSAGES,
|
|
68
|
-
paramsBody,
|
|
69
|
-
paramsHeader
|
|
70
|
-
);
|
|
71
|
-
};
|
package/src/index.js
CHANGED
|
@@ -63,8 +63,6 @@ export * from "./components/molecules/ButtonDownloadFile/index";
|
|
|
63
63
|
export * from "./components/molecules/ImageTooltip/index";
|
|
64
64
|
export * from "./components/molecules/SelectV2/index";
|
|
65
65
|
export * from "./components/molecules/Dropdown/index";
|
|
66
|
-
export * from "./components/molecules/StripeCardForm/index";
|
|
67
|
-
export * from "./components/molecules/StripeCardSelector/index";
|
|
68
66
|
|
|
69
67
|
//organisms
|
|
70
68
|
export * from "./components/organisms/ChangePassword/index";
|
|
@@ -81,7 +79,6 @@ export * from "./components/organisms/Modal/index";
|
|
|
81
79
|
export * from "./components/organisms/OrderDetail/index";
|
|
82
80
|
export * from "./components/organisms/RangeCalendar";
|
|
83
81
|
export * from "./components/organisms/TableResizable";
|
|
84
|
-
export * from "./components/organisms/SideModal/index";
|
|
85
82
|
|
|
86
83
|
//pages
|
|
87
84
|
export * from "./components/pages/ChangePasswordLogin";
|
|
@@ -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.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI5ZjQzNjAwMC0wYzgyLTRjNzYtYWEzNi1kM2Q1NGJjZTZiMTMiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4NTU2OTUyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2ODU1NzMxMjMsImlhdCI6MTY4NTU2OTUyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.EotcxmtkUpBxwlXa3bo25iLAmRcT0kj1G3PVITVB_0ZtF8UC19rJIMTNSc1hYkl8cbfCuB_vkjYCAxi4b2SOru5MdMTRhgNjcQTVbiwIYww-QdUWq0WSv84nW_HaRoxCJ8ezm-wBZgUTpcD3VFuynUICbODKKHUfxVdKdVoAM6GGE6ymSbO7-0C7ZumoWEqaZ22BF4G1H-JvLkR-tL5iqXa2N-QCnNoteFmHstBfH6Sp5UZhPav1VBEGRmwdFfUnC-Xc-aNeIFwgWCXMsOXFWbbmWeh0uNF-Btu-QEJ7VkCu4pbElqHWJKBYLCx1zqDBrKrsrNxyvQlxsJ9NSOae8Q",
|
|
13
|
-
};
|
|
@@ -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
|
-
`;
|