contentoh-components-library 21.6.23 → 21.6.24
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.test +1 -0
- package/dist/_utils/helper.js +47 -2
- package/dist/components/organisms/LinkVariantsModal/index.js +800 -340
- package/dist/components/organisms/LinkVariantsModal/styles.js +22 -10
- package/dist/components/pages/ProviderProductEdition/index.js +193 -110
- package/package.json +1 -1
- package/src/_utils/helper.js +40 -0
- package/src/components/organisms/LinkVariantsModal/index.js +681 -279
- package/src/components/organisms/LinkVariantsModal/styles.js +176 -40
- package/src/components/pages/ProviderProductEdition/index.js +71 -9
|
@@ -82,6 +82,25 @@ export const Body = styled.div`
|
|
|
82
82
|
flex: 1;
|
|
83
83
|
overflow-y: auto;
|
|
84
84
|
padding: 0 24px;
|
|
85
|
+
|
|
86
|
+
.apply-all {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: flex-start;
|
|
89
|
+
gap: 8px;
|
|
90
|
+
margin-bottom: 12px;
|
|
91
|
+
padding: 10px 12px;
|
|
92
|
+
border-radius: 6px;
|
|
93
|
+
background-color: ${GlobalColors.s2};
|
|
94
|
+
font-size: 12px;
|
|
95
|
+
color: ${GlobalColors.deep_gray};
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.apply-all .hint {
|
|
100
|
+
display: block;
|
|
101
|
+
font-size: 11px;
|
|
102
|
+
color: ${GlobalColors.gray};
|
|
103
|
+
}
|
|
85
104
|
`;
|
|
86
105
|
|
|
87
106
|
export const SearchRow = styled.form`
|
|
@@ -145,6 +164,14 @@ export const List = styled.ul`
|
|
|
145
164
|
color: ${GlobalColors.gray};
|
|
146
165
|
}
|
|
147
166
|
|
|
167
|
+
.logo {
|
|
168
|
+
width: 24px;
|
|
169
|
+
height: 24px;
|
|
170
|
+
object-fit: contain;
|
|
171
|
+
border-radius: 3px;
|
|
172
|
+
flex-shrink: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
148
175
|
.count {
|
|
149
176
|
margin-left: auto;
|
|
150
177
|
font-size: 11px;
|
|
@@ -263,45 +290,6 @@ export const Footer = styled.div`
|
|
|
263
290
|
}
|
|
264
291
|
`;
|
|
265
292
|
|
|
266
|
-
export const SectionHead = styled.div`
|
|
267
|
-
display: flex;
|
|
268
|
-
align-items: center;
|
|
269
|
-
gap: 8px;
|
|
270
|
-
margin-bottom: 6px;
|
|
271
|
-
|
|
272
|
-
.toggle {
|
|
273
|
-
flex: 1;
|
|
274
|
-
display: flex;
|
|
275
|
-
align-items: center;
|
|
276
|
-
gap: 8px;
|
|
277
|
-
border: none;
|
|
278
|
-
background: none;
|
|
279
|
-
padding: 0;
|
|
280
|
-
cursor: pointer;
|
|
281
|
-
font-family: ${FontFamily.Raleway_600};
|
|
282
|
-
font-size: 13px;
|
|
283
|
-
color: ${GlobalColors.deep_gray};
|
|
284
|
-
text-align: left;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.toggle .count {
|
|
288
|
-
font-family: ${FontFamily.Raleway_500};
|
|
289
|
-
font-size: 11px;
|
|
290
|
-
color: ${GlobalColors.gray};
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.all {
|
|
294
|
-
border: none;
|
|
295
|
-
background: none;
|
|
296
|
-
padding: 0;
|
|
297
|
-
cursor: pointer;
|
|
298
|
-
font-family: ${FontFamily.Raleway_500};
|
|
299
|
-
font-size: 11px;
|
|
300
|
-
color: ${GlobalColors.original_magenta};
|
|
301
|
-
text-decoration: underline;
|
|
302
|
-
}
|
|
303
|
-
`;
|
|
304
|
-
|
|
305
293
|
export const ImageGrid = styled.div`
|
|
306
294
|
display: grid;
|
|
307
295
|
grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
|
|
@@ -324,6 +312,10 @@ export const ImageGrid = styled.div`
|
|
|
324
312
|
background-color: rgba(${GlobalColors.rgb_color_pink}, 0.06);
|
|
325
313
|
}
|
|
326
314
|
|
|
315
|
+
label.locked {
|
|
316
|
+
cursor: default;
|
|
317
|
+
}
|
|
318
|
+
|
|
327
319
|
label input {
|
|
328
320
|
position: absolute;
|
|
329
321
|
top: 8px;
|
|
@@ -350,11 +342,13 @@ export const ImageGrid = styled.div`
|
|
|
350
342
|
|
|
351
343
|
export const AddRetailer = styled.div`
|
|
352
344
|
display: flex;
|
|
345
|
+
flex-wrap: wrap;
|
|
353
346
|
gap: 8px;
|
|
354
347
|
margin-bottom: 16px;
|
|
355
348
|
|
|
356
349
|
select {
|
|
357
|
-
flex: 1;
|
|
350
|
+
flex: 1 1 140px;
|
|
351
|
+
min-width: 0;
|
|
358
352
|
height: 32px;
|
|
359
353
|
padding: 0 8px;
|
|
360
354
|
border: 1px solid ${GlobalColors.s2};
|
|
@@ -377,8 +371,150 @@ export const AddRetailer = styled.div`
|
|
|
377
371
|
cursor: pointer;
|
|
378
372
|
}
|
|
379
373
|
|
|
374
|
+
select:disabled {
|
|
375
|
+
opacity: 0.5;
|
|
376
|
+
cursor: default;
|
|
377
|
+
}
|
|
378
|
+
|
|
380
379
|
button:disabled {
|
|
381
380
|
opacity: 0.4;
|
|
382
381
|
cursor: default;
|
|
383
382
|
}
|
|
384
383
|
`;
|
|
384
|
+
|
|
385
|
+
export const Block = styled.section`
|
|
386
|
+
margin-bottom: 20px;
|
|
387
|
+
padding-bottom: 16px;
|
|
388
|
+
border-bottom: 1px solid ${GlobalColors.s2};
|
|
389
|
+
|
|
390
|
+
&:last-of-type {
|
|
391
|
+
border-bottom: none;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
h3 {
|
|
395
|
+
display: flex;
|
|
396
|
+
align-items: center;
|
|
397
|
+
gap: 8px;
|
|
398
|
+
margin: 0 0 8px;
|
|
399
|
+
font-family: ${FontFamily.Raleway_600};
|
|
400
|
+
font-size: 13px;
|
|
401
|
+
color: ${GlobalColors.deep_gray};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
h3 .paso {
|
|
405
|
+
display: inline-flex;
|
|
406
|
+
align-items: center;
|
|
407
|
+
justify-content: center;
|
|
408
|
+
width: 18px;
|
|
409
|
+
height: 18px;
|
|
410
|
+
border-radius: 50%;
|
|
411
|
+
background-color: ${GlobalColors.original_magenta};
|
|
412
|
+
color: ${GlobalColors.white};
|
|
413
|
+
font-size: 10px;
|
|
414
|
+
}
|
|
415
|
+
`;
|
|
416
|
+
|
|
417
|
+
export const Choices = styled.div`
|
|
418
|
+
display: flex;
|
|
419
|
+
flex-direction: column;
|
|
420
|
+
gap: 2px;
|
|
421
|
+
margin-bottom: 10px;
|
|
422
|
+
|
|
423
|
+
label {
|
|
424
|
+
display: flex;
|
|
425
|
+
align-items: flex-start;
|
|
426
|
+
gap: 8px;
|
|
427
|
+
padding: 4px 0;
|
|
428
|
+
font-size: 12px;
|
|
429
|
+
color: ${GlobalColors.deep_gray};
|
|
430
|
+
cursor: pointer;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
label .hint {
|
|
434
|
+
display: block;
|
|
435
|
+
font-size: 11px;
|
|
436
|
+
color: ${GlobalColors.gray};
|
|
437
|
+
}
|
|
438
|
+
`;
|
|
439
|
+
|
|
440
|
+
export const Paging = styled.div`
|
|
441
|
+
display: flex;
|
|
442
|
+
align-items: center;
|
|
443
|
+
justify-content: space-between;
|
|
444
|
+
gap: 12px;
|
|
445
|
+
margin: -8px 0 16px;
|
|
446
|
+
font-family: ${FontFamily.Raleway_500};
|
|
447
|
+
font-size: 11px;
|
|
448
|
+
color: ${GlobalColors.gray};
|
|
449
|
+
|
|
450
|
+
button {
|
|
451
|
+
border: 1px solid ${GlobalColors.s2};
|
|
452
|
+
border-radius: 6px;
|
|
453
|
+
background: none;
|
|
454
|
+
padding: 5px 12px;
|
|
455
|
+
cursor: pointer;
|
|
456
|
+
font-family: ${FontFamily.Raleway_600};
|
|
457
|
+
font-size: 11px;
|
|
458
|
+
color: ${GlobalColors.original_magenta};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
button:disabled {
|
|
462
|
+
opacity: 0.5;
|
|
463
|
+
cursor: default;
|
|
464
|
+
}
|
|
465
|
+
`;
|
|
466
|
+
|
|
467
|
+
export const Tabs = styled.div`
|
|
468
|
+
display: flex;
|
|
469
|
+
flex-wrap: wrap;
|
|
470
|
+
gap: 6px;
|
|
471
|
+
margin-bottom: 16px;
|
|
472
|
+
padding-bottom: 12px;
|
|
473
|
+
border-bottom: 1px solid ${GlobalColors.s2};
|
|
474
|
+
|
|
475
|
+
button {
|
|
476
|
+
display: inline-flex;
|
|
477
|
+
align-items: center;
|
|
478
|
+
gap: 6px;
|
|
479
|
+
max-width: 200px;
|
|
480
|
+
padding: 6px 10px;
|
|
481
|
+
border: 1px solid ${GlobalColors.s2};
|
|
482
|
+
border-radius: 6px;
|
|
483
|
+
background-color: ${GlobalColors.white};
|
|
484
|
+
cursor: pointer;
|
|
485
|
+
font-family: ${FontFamily.Raleway_500};
|
|
486
|
+
font-size: 11px;
|
|
487
|
+
color: ${GlobalColors.gray};
|
|
488
|
+
overflow: hidden;
|
|
489
|
+
text-overflow: ellipsis;
|
|
490
|
+
white-space: nowrap;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
button.active {
|
|
494
|
+
border-color: ${GlobalColors.original_magenta};
|
|
495
|
+
color: ${GlobalColors.original_magenta};
|
|
496
|
+
background-color: rgba(${GlobalColors.rgb_color_pink}, 0.08);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
button .orden {
|
|
500
|
+
display: inline-flex;
|
|
501
|
+
align-items: center;
|
|
502
|
+
justify-content: center;
|
|
503
|
+
width: 16px;
|
|
504
|
+
height: 16px;
|
|
505
|
+
border-radius: 50%;
|
|
506
|
+
background-color: ${GlobalColors.s2};
|
|
507
|
+
font-size: 9px;
|
|
508
|
+
flex-shrink: 0;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
button.active .orden {
|
|
512
|
+
background-color: ${GlobalColors.original_magenta};
|
|
513
|
+
color: ${GlobalColors.white};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
button .listo {
|
|
517
|
+
color: ${GlobalColors.original_magenta};
|
|
518
|
+
flex-shrink: 0;
|
|
519
|
+
}
|
|
520
|
+
`;
|
|
@@ -78,6 +78,7 @@ const ProviderProductEditionView = ({
|
|
|
78
78
|
const [showLinkVariants, setShowLinkVariants] = useState(false);
|
|
79
79
|
const [family, setFamily] = useState(null);
|
|
80
80
|
const [showFamily, setShowFamily] = useState(false);
|
|
81
|
+
const [loadingVariant, setLoadingVariant] = useState(null);
|
|
81
82
|
const [showRejectModal, setShowRejectModal] = useState(false);
|
|
82
83
|
const [headerTop, setHeaderTop] = useState(0);
|
|
83
84
|
const [assig, setAssig] = useState({});
|
|
@@ -722,10 +723,64 @@ const ProviderProductEditionView = ({
|
|
|
722
723
|
}
|
|
723
724
|
};
|
|
724
725
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
726
|
+
/*
|
|
727
|
+
Abre otra variante de la familia.
|
|
728
|
+
|
|
729
|
+
Esta pantalla no lee el producto de la URL: lo lee de sessionStorage, donde
|
|
730
|
+
lo dejó el listado al hacer clic. Así que navegar a /products/:id sin más
|
|
731
|
+
cambia la barra de direcciones y deja el producto anterior en pantalla.
|
|
732
|
+
|
|
733
|
+
Por eso primero se trae el producto por su ID —no por su UPC: hay 12,024 UPC
|
|
734
|
+
repetidos entre artículos activos y 5,579 de esos casos caen dentro de la
|
|
735
|
+
misma compañía, así que el UPC no identifica— y se deja en sessionStorage con
|
|
736
|
+
la misma forma que usa el listado. Después se navega.
|
|
737
|
+
|
|
738
|
+
Es un rodeo, y lo es porque el origen del dato está mal puesto. Arreglarlo de
|
|
739
|
+
raíz —que la ficha lea de la URL— toca todas las plataformas y no cabe aquí.
|
|
740
|
+
*/
|
|
741
|
+
const openVariant = async (articleId) => {
|
|
742
|
+
setLoadingVariant(articleId);
|
|
743
|
+
try {
|
|
744
|
+
const res = await axios.get(
|
|
745
|
+
`${process.env.REACT_APP_NEW_ARTICLES_ENDPOINT}`,
|
|
746
|
+
{
|
|
747
|
+
params: { listType: "general", filterByArticleId: articleId },
|
|
748
|
+
headers: { Authorization: token },
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
|
|
752
|
+
// read-articles-v2 responde { count, data: [...] }.
|
|
753
|
+
const { data } = readPayload(res);
|
|
754
|
+
const encontrado = (data ?? []).find(
|
|
755
|
+
(item) => Number(item.id_article) === Number(articleId)
|
|
756
|
+
);
|
|
757
|
+
|
|
758
|
+
if (encontrado) {
|
|
759
|
+
sessionStorage.setItem(
|
|
760
|
+
"productSelected",
|
|
761
|
+
JSON.stringify({
|
|
762
|
+
...encontrado,
|
|
763
|
+
article: { id_article: encontrado.id_article },
|
|
764
|
+
})
|
|
765
|
+
);
|
|
766
|
+
sessionStorage.setItem(
|
|
767
|
+
"productEdit",
|
|
768
|
+
JSON.stringify({
|
|
769
|
+
ArticleId: encontrado.id_article,
|
|
770
|
+
idCategory: encontrado.id_category,
|
|
771
|
+
product: encontrado,
|
|
772
|
+
})
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
} catch (error) {
|
|
776
|
+
// Si la consulta falla se navega igual: la pantalla mostrará el producto
|
|
777
|
+
// que hubiera en sessionStorage, que es el comportamiento de siempre.
|
|
778
|
+
// Peor sería dejar el clic sin efecto y que pareciera que no responde.
|
|
779
|
+
console.error("openVariant: ", error);
|
|
780
|
+
} finally {
|
|
781
|
+
setLoadingVariant(null);
|
|
782
|
+
window.location.assign(`/products/${articleId}/datasheet`);
|
|
783
|
+
}
|
|
729
784
|
};
|
|
730
785
|
|
|
731
786
|
/*
|
|
@@ -1274,8 +1329,6 @@ const ProviderProductEditionView = ({
|
|
|
1274
1329
|
articleName={state.product?.name}
|
|
1275
1330
|
articleUpc={state.product?.upc}
|
|
1276
1331
|
activeRetailerId={state.active_retailer?.id_retailer}
|
|
1277
|
-
retailersAvailable={state.product?.retailersAvailable}
|
|
1278
|
-
categoriesAvailable={state.product?.categoriesAvailable}
|
|
1279
1332
|
token={token}
|
|
1280
1333
|
onClose={() => setShowLinkVariants(false)}
|
|
1281
1334
|
onLinked={handleOnLinkedVariants}
|
|
@@ -1531,9 +1584,14 @@ const ProviderProductEditionView = ({
|
|
|
1531
1584
|
<button
|
|
1532
1585
|
type="button"
|
|
1533
1586
|
className="family-row parent"
|
|
1587
|
+
disabled={loadingVariant !== null}
|
|
1534
1588
|
onClick={() => openVariant(family.parent.articleId)}
|
|
1535
1589
|
>
|
|
1536
|
-
<span className="role">
|
|
1590
|
+
<span className="role">
|
|
1591
|
+
{loadingVariant === family.parent.articleId
|
|
1592
|
+
? "Abriendo…"
|
|
1593
|
+
: "Producto padre"}
|
|
1594
|
+
</span>
|
|
1537
1595
|
<span className="name">{family.parent.name}</span>
|
|
1538
1596
|
<span className="upc">{family.parent.upc}</span>
|
|
1539
1597
|
</button>
|
|
@@ -1544,11 +1602,15 @@ const ProviderProductEditionView = ({
|
|
|
1544
1602
|
key={variant.articleId}
|
|
1545
1603
|
type="button"
|
|
1546
1604
|
className={`family-row${variant.isCurrent ? " current" : ""}`}
|
|
1547
|
-
disabled={variant.isCurrent}
|
|
1605
|
+
disabled={variant.isCurrent || loadingVariant !== null}
|
|
1548
1606
|
onClick={() => openVariant(variant.articleId)}
|
|
1549
1607
|
>
|
|
1550
1608
|
<span className="role">
|
|
1551
|
-
{variant.
|
|
1609
|
+
{loadingVariant === variant.articleId
|
|
1610
|
+
? "Abriendo…"
|
|
1611
|
+
: variant.isCurrent
|
|
1612
|
+
? "Estás aquí"
|
|
1613
|
+
: "Variante"}
|
|
1552
1614
|
</span>
|
|
1553
1615
|
<span className="name">{variant.name}</span>
|
|
1554
1616
|
<span className="upc">{variant.upc}</span>
|