contentoh-components-library 21.4.27 → 21.4.29

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.
Files changed (29) hide show
  1. package/.env.development +1 -0
  2. package/dist/assets/fonts/roboto/LICENSE.txt +202 -0
  3. package/dist/components/molecules/StripeCardForm/StripeCardForm.stories.js +2 -1
  4. package/dist/components/molecules/StripeCardForm/index.js +9 -2
  5. package/dist/components/molecules/StripeCardForm/paymentForm.js +4 -1
  6. package/dist/components/molecules/StripeCardForm/styles.js +4 -1
  7. package/dist/components/molecules/StripeCardSelector/index.js +15 -2
  8. package/dist/components/molecules/StripeCardSelector/styles.js +4 -1
  9. package/dist/components/organisms/Chat/ContentChat/styles.js +1 -1
  10. package/dist/components/organisms/Chat/Footer/styles.js +1 -1
  11. package/dist/components/organisms/Chat/styles.js +1 -1
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +112 -54
  13. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +1 -1
  14. package/dist/components/pages/RetailerProductEdition/index.js +68 -74
  15. package/package.json +3 -3
  16. package/src/components/atoms/Card/index.js +1 -1
  17. package/src/components/molecules/StripeCardForm/StripeCardForm.stories.js +1 -0
  18. package/src/components/molecules/StripeCardForm/index.js +4 -1
  19. package/src/components/molecules/StripeCardForm/paymentForm.js +2 -1
  20. package/src/components/molecules/StripeCardForm/styles.js +2 -1
  21. package/src/components/molecules/StripeCardSelector/index.js +16 -3
  22. package/src/components/molecules/StripeCardSelector/styles.js +3 -1
  23. package/src/components/organisms/Chat/ContentChat/styles.js +0 -1
  24. package/src/components/organisms/Chat/Footer/styles.js +4 -0
  25. package/src/components/organisms/Chat/styles.js +1 -1
  26. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +112 -60
  27. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +1 -1
  28. package/src/components/pages/RetailerProductEdition/index.js +42 -47
  29. package/src/index.js +0 -1
@@ -37,7 +37,7 @@ var _GalleryElement = require("../../molecules/GalleryElement");
37
37
 
38
38
  var _fileSaver = require("file-saver");
39
39
 
40
- var _data2 = require("../../../global-files/data");
40
+ var _data = require("../../../global-files/data");
41
41
 
42
42
  var _GalleryHeader = require("../../molecules/GalleryHeader");
43
43
 
@@ -541,7 +541,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
541
541
  }
542
542
 
543
543
  _context2.next = 3;
544
- return (0, _data2.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article, product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_category), auditableVersion.version);
544
+ return (0, _data.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article, product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_category), auditableVersion.version);
545
545
 
546
546
  case 3:
547
547
  _auditServices = _context2.sent;
@@ -581,7 +581,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
581
581
  case 0:
582
582
  _context3.prev = 0;
583
583
  _context3.next = 3;
584
- return (0, _data2.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_article, product === null || product === void 0 ? void 0 : (_product$article5 = product.article) === null || _product$article5 === void 0 ? void 0 : _product$article5.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article6 = product.article) === null || _product$article6 === void 0 ? void 0 : _product$article6.id_category), version);
584
+ return (0, _data.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_article, product === null || product === void 0 ? void 0 : (_product$article5 = product.article) === null || _product$article5 === void 0 ? void 0 : _product$article5.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article6 = product.article) === null || _product$article6 === void 0 ? void 0 : _product$article6.id_category), version);
585
585
 
586
586
  case 3:
587
587
  _services = _context3.sent;
@@ -598,7 +598,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
598
598
  init: _services[2]
599
599
  });
600
600
  if (((_services$ = _services[2]) === null || _services$ === void 0 ? void 0 : (_services$$values = _services$.values) === null || _services$$values === void 0 ? void 0 : _services$$values.length) > 0) setActiveImage(0);
601
- (0, _data2.getPercentage)({
601
+ (0, _data.getPercentage)({
602
602
  data: [product]
603
603
  }).then(function (res) {
604
604
  return setPercentages(res[0]);
@@ -723,7 +723,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
723
723
  getComments();
724
724
  _context6.t0 = setUserGroups;
725
725
  _context6.next = 6;
726
- return (0, _data2.fetchUsers)(token);
726
+ return (0, _data.fetchUsers)(token);
727
727
 
728
728
  case 6:
729
729
  _context6.t1 = _context6.sent;
@@ -1347,7 +1347,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1347
1347
 
1348
1348
  var sendToFacilitator = /*#__PURE__*/function () {
1349
1349
  var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(result) {
1350
- var concept, productTemp, evalStatus, articleId, orderId, data, res, _message, specialistDone, _JSON$parse5, newStatus, newOrderStatus, newArticleStatus, messageToChat, _data;
1350
+ var concept, productTemp, evalStatus, articleId, orderId, body, res, _message, specialistDone, _JSON$parse5, newStatus, newOrderStatus, newArticleStatus, messageToChat, data;
1351
1351
 
1352
1352
  return _regenerator.default.wrap(function _callee11$(_context11) {
1353
1353
  while (1) {
@@ -1360,22 +1360,24 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1360
1360
  evalStatus = retailerStatus;
1361
1361
  articleId = product.article.id_article;
1362
1362
  orderId = product.orderId;
1363
- data = {
1364
- articleId: articleId,
1365
- orderId: orderId,
1366
- concept: concept,
1367
- evalStatus: evalStatus,
1368
- retailerId: activeRetailer.id
1363
+ body = {
1364
+ orderArticleRetailers: [{
1365
+ orderId: orderId,
1366
+ articleId: articleId,
1367
+ retailersIds: [activeRetailer.id]
1368
+ }],
1369
+ isAproved: false,
1370
+ service: concept
1369
1371
  };
1370
1372
 
1371
1373
  if (!result) {
1372
- _context11.next = 16;
1374
+ _context11.next = 17;
1373
1375
  break;
1374
1376
  }
1375
1377
 
1376
- data.result = result;
1378
+ body.isAproved = result === "A";
1377
1379
  _context11.next = 12;
1378
- return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1380
+ return _axios.default.post("".concat(process.env.REACT_APP_EVALUATION_REFACTOR), body, {
1379
1381
  headers: {
1380
1382
  Authorization: token
1381
1383
  }
@@ -1383,11 +1385,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1383
1385
 
1384
1386
  case 12:
1385
1387
  res = _context11.sent;
1388
+ console.log(JSON.parse(res.data.body), "res");
1386
1389
  getServices();
1387
- _context11.next = 21;
1390
+ _context11.next = 22;
1388
1391
  break;
1389
1392
 
1390
- case 16:
1393
+ case 17:
1391
1394
  specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
1392
1395
 
1393
1396
  if (specialistDone) {
@@ -1398,25 +1401,25 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1398
1401
  getSectionIcon();
1399
1402
  }
1400
1403
 
1401
- _context11.next = 20;
1402
- return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1404
+ _context11.next = 21;
1405
+ return _axios.default.post("".concat(process.env.REACT_APP_EVALUATION_REFACTOR), body, {
1403
1406
  headers: {
1404
1407
  Authorization: token
1405
1408
  }
1406
1409
  });
1407
1410
 
1408
- case 20:
1411
+ case 21:
1409
1412
  res = _context11.sent;
1410
1413
 
1411
- case 21:
1414
+ case 22:
1412
1415
  if (!(res.data.statusCode === 200)) {
1413
- _context11.next = 34;
1416
+ _context11.next = 35;
1414
1417
  break;
1415
1418
  }
1416
1419
 
1417
1420
  _JSON$parse5 = JSON.parse(res.data.body), newStatus = _JSON$parse5.newStatus, newOrderStatus = _JSON$parse5.newOrderStatus, newArticleStatus = _JSON$parse5.newArticleStatus;
1418
1421
  messageToChat = (0, _utils.createMessage)(product.retailers, activeRetailer.id, evalStatus, newStatus, activeTab);
1419
- _data = {
1422
+ data = {
1420
1423
  paramsBody: {
1421
1424
  id: product.article.id_article,
1422
1425
  version: version,
@@ -1431,38 +1434,38 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1431
1434
  Authorization: token
1432
1435
  }
1433
1436
  };
1434
- _context11.next = 27;
1435
- return (0, _utils.sendMessage)(_data);
1437
+ _context11.next = 28;
1438
+ return (0, _utils.sendMessage)(data);
1436
1439
 
1437
- case 27:
1440
+ case 28:
1438
1441
  if (newOrderStatus) productTemp.status = newArticleStatus[articleId];
1439
1442
  productTemp["".concat(concept, "_status")] = newStatus;
1440
- _context11.next = 31;
1443
+ _context11.next = 32;
1441
1444
  return loadData();
1442
1445
 
1443
- case 31:
1446
+ case 32:
1444
1447
  if (_message) setMessage(_message);
1445
1448
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1446
1449
  setProduct(productTemp);
1447
1450
 
1448
- case 34:
1449
- _context11.next = 39;
1451
+ case 35:
1452
+ _context11.next = 40;
1450
1453
  break;
1451
1454
 
1452
- case 36:
1453
- _context11.prev = 36;
1455
+ case 37:
1456
+ _context11.prev = 37;
1454
1457
  _context11.t0 = _context11["catch"](1);
1455
1458
  console.log(_context11.t0);
1456
1459
 
1457
- case 39:
1460
+ case 40:
1458
1461
  setLoading(false);
1459
1462
 
1460
- case 40:
1463
+ case 41:
1461
1464
  case "end":
1462
1465
  return _context11.stop();
1463
1466
  }
1464
1467
  }
1465
- }, _callee11, null, [[1, 36]]);
1468
+ }, _callee11, null, [[1, 37]]);
1466
1469
  }));
1467
1470
 
1468
1471
  return function sendToFacilitator(_x) {
@@ -1818,7 +1821,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1818
1821
 
1819
1822
  var validateAll = /*#__PURE__*/function () {
1820
1823
  var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(result) {
1821
- var evaluationArray, conceptArray, messages, productTemp, messagesResponse;
1824
+ var _product$id_order, evaluationArray, conceptArray, messages, body, productTemp, messagesResponse;
1825
+
1822
1826
  return _regenerator.default.wrap(function _callee15$(_context15) {
1823
1827
  while (1) {
1824
1828
  switch (_context15.prev = _context15.next) {
@@ -1826,7 +1830,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1826
1830
  _context15.prev = 0;
1827
1831
  setLoading(true);
1828
1832
  evaluationArray = [];
1829
- conceptArray = [];
1833
+ conceptArray = ["description", "datasheet", "images"];
1830
1834
  _context15.t0 = user.id_role;
1831
1835
  _context15.next = _context15.t0 === 4 ? 7 : _context15.t0 === 5 ? 9 : 11;
1832
1836
  break;
@@ -1846,38 +1850,28 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1846
1850
  case 13:
1847
1851
  messages = [];
1848
1852
  servicesData === null || servicesData === void 0 ? void 0 : servicesData.forEach(function (ret) {
1849
- if (conceptArray.includes(ret.service)) {
1850
- var _product$id_order;
1851
-
1852
- var data = {
1853
- articleId: product.article.id_article,
1854
- orderId: (_product$id_order = product.id_order) !== null && _product$id_order !== void 0 ? _product$id_order : product.orderId,
1855
- concept: ret.service,
1856
- result: result,
1857
- evalStatus: ret.status,
1858
- retailerId: ret.id_retailer
1859
- };
1860
-
1861
- if (product["".concat(ret.service, "_status")] !== "NS") {
1862
- var _message2 = (0, _utils.createMessage)(product.retailers, ret.id_retailer, product["".concat(ret.service, "_status")], "".concat(result, "A"), ret.service);
1863
-
1864
- messages.push(createComment([{
1865
- type: "status",
1866
- value: _message2
1867
- }], ret.id_retailer));
1853
+ if (!retailersIds.includes(ret.id_retailer)) retailersIds.push(ret.id_retailer);
1854
+ });
1855
+ body = {
1856
+ orderArticleRetailers: [{
1857
+ orderId: (_product$id_order = product.id_order) !== null && _product$id_order !== void 0 ? _product$id_order : product.orderId,
1858
+ articleId: product.article.id_article,
1859
+ retailersIds: retailersIds
1860
+ }],
1861
+ isAproved: isAproved
1862
+ };
1863
+ conceptArray.forEach(function (concept) {
1864
+ body.service = concept;
1865
+ evaluationArray.push(_axios.default.post("".concat(process.env.REACT_APP_EVALUATION_REFACTOR), body, {
1866
+ headers: {
1867
+ Authorization: token
1868
1868
  }
1869
-
1870
- evaluationArray.push(_axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1871
- headers: {
1872
- Authorization: token
1873
- }
1874
- }));
1875
- }
1869
+ }));
1876
1870
  });
1877
- _context15.next = 17;
1871
+ _context15.next = 19;
1878
1872
  return Promise.all(evaluationArray);
1879
1873
 
1880
- case 17:
1874
+ case 19:
1881
1875
  productTemp = product;
1882
1876
  productTemp.status = "".concat(result, "A");
1883
1877
  productTemp.datasheet_status = productTemp.datasheet_status === "NS" ? "NS" : "".concat(result, "A");
@@ -1885,29 +1879,29 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1885
1879
  productTemp.images_status = productTemp.images_status === "NS" ? "NS" : "".concat(result, "A");
1886
1880
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1887
1881
  setProduct(productTemp);
1888
- _context15.next = 26;
1882
+ _context15.next = 28;
1889
1883
  return Promise.all(messages);
1890
1884
 
1891
- case 26:
1885
+ case 28:
1892
1886
  messagesResponse = _context15.sent;
1893
- _context15.next = 29;
1887
+ _context15.next = 31;
1894
1888
  return loadData();
1895
1889
 
1896
- case 29:
1897
- _context15.next = 34;
1890
+ case 31:
1891
+ _context15.next = 36;
1898
1892
  break;
1899
1893
 
1900
- case 31:
1901
- _context15.prev = 31;
1894
+ case 33:
1895
+ _context15.prev = 33;
1902
1896
  _context15.t1 = _context15["catch"](0);
1903
1897
  console.log(_context15.t1);
1904
1898
 
1905
- case 34:
1899
+ case 36:
1906
1900
  case "end":
1907
1901
  return _context15.stop();
1908
1902
  }
1909
1903
  }
1910
- }, _callee15, null, [[0, 31]]);
1904
+ }, _callee15, null, [[0, 33]]);
1911
1905
  }));
1912
1906
 
1913
1907
  return function validateAll(_x4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.27",
3
+ "version": "21.4.29",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -16,8 +16,8 @@
16
16
  "@mui/material": "^5.12.0",
17
17
  "@mui/styled-engine-sc": "^5.12.0",
18
18
  "@storybook/addon-postcss": "^2.0.0",
19
- "@stripe/react-stripe-js": "^2.1.1",
20
- "@stripe/stripe-js": "^1.54.1",
19
+ "@stripe/react-stripe-js": "^2.2.0",
20
+ "@stripe/stripe-js": "^2.1.4",
21
21
  "@testing-library/jest-dom": "^5.11.4",
22
22
  "@testing-library/react": "^11.1.0",
23
23
  "@testing-library/user-event": "^12.1.10",
@@ -1,6 +1,6 @@
1
1
  import { Container } from "./styles";
2
2
  import { CheckBox } from "../CheckBox";
3
- import { CardCvcElement, useStripe } from "@stripe/react-stripe-js";
3
+ import { useStripe } from "@stripe/react-stripe-js";
4
4
 
5
5
  export const Card = ({
6
6
  card = {},
@@ -10,4 +10,5 @@ export const StripeCardFormDefault = Template.bind({});
10
10
  StripeCardFormDefault.args = {
11
11
  customerId: "cus_KuEt6R6vwmN09f",
12
12
  jwt: "eyJraWQiOiJkQWJkZCtlclwvTlwveVRQUWNvUlVyOCtrNUd2M1hMM2N1MWUzQ09zWExVRnc9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmNTkyN2Y4ZS1jYmY3LTQ5MjItOWUwOS1lNjllYzBiMjczMWEiLCJjb2duaXRvOmdyb3VwcyI6WyJ1c3VhcmlvX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfWE1aUWRxa0dqIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjpmYWxzZSwiY29nbml0bzp1c2VybmFtZSI6ImY1OTI3ZjhlLWNiZjctNDkyMi05ZTA5LWU2OWVjMGIyNzMxYSIsImNvZ25pdG86cm9sZXMiOlsiYXJuOmF3czppYW06Ojg5ODY3MDIzMjgwNzpyb2xlXC9jb250ZW50b2gtZGV2LXVzLWVhc3QtMS1sYW1iZGFSb2xlIl0sImF1ZCI6IjVhYzh0cGdzNmdic3ExM2ZydnJwaWVlcDQwIiwiZXZlbnRfaWQiOiI5ZjQzNjAwMC0wYzgyLTRjNzYtYWEzNi1kM2Q1NGJjZTZiMTMiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY4NTU2OTUyMywibmFtZSI6IklzbWFlbCBMb3BleiIsInBob25lX251bWJlciI6Iis1MjMxMTEzNjYzMzYiLCJleHAiOjE2ODU1NzMxMjMsImlhdCI6MTY4NTU2OTUyMywiZW1haWwiOiJpbG9wZXpAY29udGVudG9oLmNvbSJ9.EotcxmtkUpBxwlXa3bo25iLAmRcT0kj1G3PVITVB_0ZtF8UC19rJIMTNSc1hYkl8cbfCuB_vkjYCAxi4b2SOru5MdMTRhgNjcQTVbiwIYww-QdUWq0WSv84nW_HaRoxCJ8ezm-wBZgUTpcD3VFuynUICbODKKHUfxVdKdVoAM6GGE6ymSbO7-0C7ZumoWEqaZ22BF4G1H-JvLkR-tL5iqXa2N-QCnNoteFmHstBfH6Sp5UZhPav1VBEGRmwdFfUnC-Xc-aNeIFwgWCXMsOXFWbbmWeh0uNF-Btu-QEJ7VkCu4pbElqHWJKBYLCx1zqDBrKrsrNxyvQlxsJ9NSOae8Q",
13
+ isSelected: true,
13
14
  };
@@ -12,6 +12,8 @@ export const StripeCardForm = ({
12
12
  setStripe,
13
13
  setModalErrorCard,
14
14
  setMsj,
15
+ isSelected = false,
16
+ onClick,
15
17
  }) => {
16
18
  const [stripeLoaded, setStripeLoaded] = useState(false);
17
19
 
@@ -24,7 +26,7 @@ export const StripeCardForm = ({
24
26
  }, []);
25
27
 
26
28
  return stripeLoaded ? (
27
- <Container>
29
+ <Container onClick={() => onClick && onClick()}>
28
30
  <Elements stripe={stripeApiKey}>
29
31
  <PaymentForm
30
32
  labelForm={"Pago con tarjeta"}
@@ -33,6 +35,7 @@ export const StripeCardForm = ({
33
35
  setStripe={setStripe}
34
36
  setModalErrorCard={setModalErrorCard}
35
37
  setMsj={setMsj}
38
+ isSelected={isSelected}
36
39
  />
37
40
  </Elements>
38
41
  </Container>
@@ -16,6 +16,7 @@ export const PaymentForm = ({
16
16
  setStripe,
17
17
  setModalErrorCard,
18
18
  setMsj,
19
+ isSelected = false,
19
20
  }) => {
20
21
  const stripe = useStripe();
21
22
  const elements = useElements();
@@ -86,7 +87,7 @@ export const PaymentForm = ({
86
87
  };
87
88
 
88
89
  return (
89
- <PaymentFormContainer>
90
+ <PaymentFormContainer isSelected={isSelected}>
90
91
  <h2>{labelForm}</h2>
91
92
  <div className="card-fields">
92
93
  <div className="element card-name">
@@ -12,7 +12,7 @@ export const PaymentFormContainer = styled.form`
12
12
  font-size: 15px;
13
13
  line-height: 20px;
14
14
  color: #262626;
15
- font-family: ${FontFamily.Lato};
15
+ font-family: ${FontFamily.RobotoMedium};
16
16
 
17
17
  & + * {
18
18
  margin-top: 10px;
@@ -70,4 +70,5 @@ export const PaymentFormContainer = styled.form`
70
70
  }
71
71
  }
72
72
  }
73
+ ${({ isSelected }) => isSelected && `border-color: #E33AA9;`}
73
74
  `;
@@ -7,7 +7,13 @@ import { Card } from "../../atoms/Card";
7
7
  import { Loading } from "../../atoms/Loading";
8
8
  const stripeApiKey = loadStripe(`${process.env.REACT_APP_KEY_STRIPE}`);
9
9
 
10
- export const CardSelector = ({ jwt, setCard, setStripe }) => {
10
+ export const CardSelector = ({
11
+ jwt,
12
+ setCard,
13
+ setStripe,
14
+ isSelected = false,
15
+ onClick,
16
+ }) => {
11
17
  const [stripeLoaded, setStripeLoaded] = useState(false);
12
18
  const [cards, setCards] = useState([]);
13
19
  const [selectedCard, setSelectedCard] = useState("");
@@ -18,12 +24,19 @@ export const CardSelector = ({ jwt, setCard, setStripe }) => {
18
24
  const cardsResponse = await getAllCards(jwt);
19
25
  setCards(cardsResponse);
20
26
  };
27
+
21
28
  useEffect(() => {
22
- loadStripeJS();
29
+ // loadStripeJS();
30
+ stripeApiKey.then(() => {
31
+ setStripeLoaded(true);
32
+ getAllCards(jwt).then((cardsResponse) => {
33
+ setCards(cardsResponse);
34
+ });
35
+ });
23
36
  }, []);
24
37
 
25
38
  return stripeLoaded ? (
26
- <Container>
39
+ <Container isSelected={isSelected} onClick={() => onClick && onClick()}>
27
40
  <h2>Tarjetas guardadas</h2>
28
41
  <Elements stripe={stripeApiKey}>
29
42
  {cards.map((card) => (
@@ -1,4 +1,6 @@
1
1
  import styled from "styled-components";
2
2
  import { PaymentFormContainer } from "../StripeCardForm/styles";
3
3
 
4
- export const Container = styled(PaymentFormContainer)``;
4
+ export const Container = styled(PaymentFormContainer)`
5
+ ${({ isSelected }) => isSelected && `border-color: #E33AA9;`}
6
+ `;
@@ -38,7 +38,6 @@ export const Container = styled.div`
38
38
  color: #808080;
39
39
  }
40
40
  }
41
-
42
41
  @media (max-width: 600px) {
43
42
  min-width: 300px;
44
43
  }
@@ -65,6 +65,10 @@ export const Container = styled.div`
65
65
  overflow: hidden;
66
66
  padding: 0px;
67
67
  }
68
+
69
+ @media (max-width: 600px) {
70
+ width: 90%;
71
+ }
68
72
  `;
69
73
 
70
74
  export const ContainerMain = styled.div`
@@ -12,7 +12,7 @@ export const ContainerFixed = styled.div`
12
12
  border: 1px solid #f0f0f0;
13
13
  z-index: 1000;
14
14
  padding: 0px;
15
- @media (max-width: 1024px) {
15
+ @media (max-width: 1024px) {
16
16
  width: auto;
17
17
  max-width: 100%;
18
18
  }