contentoh-components-library 21.6.23 → 21.6.25

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.
@@ -2,6 +2,25 @@ import styled from "styled-components";
2
2
  import "../../../global-files/global-styles.css";
3
3
  import { GlobalColors, FontFamily } from "../../../global-files/variables";
4
4
 
5
+ // Rosa ContentOh. Va aquí y no en variables.js porque cambiar la constante
6
+ // global tocaría todos los componentes que ya la usan; este modal es lo que hay
7
+ // que alinear con la marca.
8
+ const PINK = "#E13AA8";
9
+ const PINK_RGB = "225, 58, 168";
10
+
11
+ // accent-color pinta el relleno de checkboxes y radios con el color de marca en
12
+ // vez del azul del sistema, sin reemplazarlos por divs: siguen siendo controles
13
+ // nativos, con su foco y su navegación por teclado intactos.
14
+ const controls = `
15
+ input[type="checkbox"],
16
+ input[type="radio"] {
17
+ accent-color: ${PINK};
18
+ width: 15px;
19
+ height: 15px;
20
+ cursor: pointer;
21
+ }
22
+ `;
23
+
5
24
  export const Overlay = styled.div`
6
25
  position: fixed;
7
26
  inset: 0;
@@ -13,6 +32,7 @@ export const Overlay = styled.div`
13
32
  `;
14
33
 
15
34
  export const Panel = styled.div`
35
+ ${controls}
16
36
  display: flex;
17
37
  flex-direction: column;
18
38
  width: min(680px, 92vw);
@@ -33,13 +53,13 @@ export const Header = styled.div`
33
53
  h2 {
34
54
  margin: 0;
35
55
  font-family: ${FontFamily.Raleway_700};
36
- font-size: 16px;
56
+ font-size: 17px;
37
57
  color: ${GlobalColors.deep_gray};
38
58
  }
39
59
 
40
60
  p {
41
61
  margin: 4px 0 0;
42
- font-size: 12px;
62
+ font-size: 13px;
43
63
  color: ${GlobalColors.gray};
44
64
  }
45
65
 
@@ -47,7 +67,7 @@ export const Header = styled.div`
47
67
  border: none;
48
68
  background: none;
49
69
  cursor: pointer;
50
- font-size: 20px;
70
+ font-size: 21px;
51
71
  line-height: 1;
52
72
  color: ${GlobalColors.gray};
53
73
  }
@@ -65,16 +85,16 @@ export const ModeSwitch = styled.div`
65
85
  border: 1px solid ${GlobalColors.s2};
66
86
  background-color: ${GlobalColors.white};
67
87
  font-family: ${FontFamily.Raleway_600};
68
- font-size: 12px;
88
+ font-size: 13px;
69
89
  color: ${GlobalColors.gray};
70
90
  cursor: pointer;
71
91
  text-align: left;
72
92
  }
73
93
 
74
94
  button.active {
75
- border-color: ${GlobalColors.original_magenta};
76
- color: ${GlobalColors.original_magenta};
77
- background-color: rgba(${GlobalColors.rgb_color_pink}, 0.08);
95
+ border-color: ${PINK};
96
+ color: ${PINK};
97
+ background-color: rgba(${PINK_RGB}, 0.08);
78
98
  }
79
99
  `;
80
100
 
@@ -82,6 +102,25 @@ export const Body = styled.div`
82
102
  flex: 1;
83
103
  overflow-y: auto;
84
104
  padding: 0 24px;
105
+
106
+ .apply-all {
107
+ display: flex;
108
+ align-items: flex-start;
109
+ gap: 8px;
110
+ margin-bottom: 12px;
111
+ padding: 10px 12px;
112
+ border-radius: 6px;
113
+ background-color: ${GlobalColors.s2};
114
+ font-size: 13px;
115
+ color: ${GlobalColors.deep_gray};
116
+ cursor: pointer;
117
+ }
118
+
119
+ .apply-all .hint {
120
+ display: block;
121
+ font-size: 12px;
122
+ color: ${GlobalColors.gray};
123
+ }
85
124
  `;
86
125
 
87
126
  export const SearchRow = styled.form`
@@ -96,7 +135,7 @@ export const SearchRow = styled.form`
96
135
  border: 1px solid ${GlobalColors.s2};
97
136
  border-radius: 6px;
98
137
  font-family: ${FontFamily.Raleway};
99
- font-size: 12px;
138
+ font-size: 13px;
100
139
  color: ${GlobalColors.deep_gray};
101
140
  }
102
141
 
@@ -105,10 +144,10 @@ export const SearchRow = styled.form`
105
144
  padding: 0 18px;
106
145
  border: none;
107
146
  border-radius: 6px;
108
- background-color: ${GlobalColors.original_magenta};
147
+ background-color: ${PINK};
109
148
  color: ${GlobalColors.white};
110
149
  font-family: ${FontFamily.Raleway_600};
111
- font-size: 12px;
150
+ font-size: 13px;
112
151
  cursor: pointer;
113
152
  }
114
153
 
@@ -135,20 +174,28 @@ export const List = styled.ul`
135
174
  gap: 10px;
136
175
  padding: 10px 12px;
137
176
  cursor: pointer;
138
- font-size: 12px;
177
+ font-size: 13px;
139
178
  color: ${GlobalColors.deep_gray};
140
179
  }
141
180
 
142
181
  .meta {
143
182
  display: block;
144
- font-size: 11px;
183
+ font-size: 12px;
145
184
  color: ${GlobalColors.gray};
146
185
  }
147
186
 
187
+ .logo {
188
+ width: 24px;
189
+ height: 24px;
190
+ object-fit: contain;
191
+ border-radius: 3px;
192
+ flex-shrink: 0;
193
+ }
194
+
148
195
  .count {
149
196
  margin-left: auto;
150
- font-size: 11px;
151
- color: ${GlobalColors.original_magenta};
197
+ font-size: 12px;
198
+ color: ${PINK};
152
199
  white-space: nowrap;
153
200
  }
154
201
  `;
@@ -159,7 +206,7 @@ export const AttributeList = styled(List)`
159
206
 
160
207
  .note {
161
208
  display: block;
162
- font-size: 10px;
209
+ font-size: 11px;
163
210
  font-style: italic;
164
211
  color: ${GlobalColors.gray};
165
212
  }
@@ -167,7 +214,7 @@ export const AttributeList = styled(List)`
167
214
  .value {
168
215
  margin-left: auto;
169
216
  max-width: 45%;
170
- font-size: 11px;
217
+ font-size: 12px;
171
218
  color: ${GlobalColors.gray};
172
219
  overflow: hidden;
173
220
  text-overflow: ellipsis;
@@ -181,7 +228,7 @@ export const Section = styled.div`
181
228
  h3 {
182
229
  margin: 0 0 8px;
183
230
  font-family: ${FontFamily.Raleway_600};
184
- font-size: 13px;
231
+ font-size: 14px;
185
232
  color: ${GlobalColors.deep_gray};
186
233
  }
187
234
 
@@ -190,14 +237,14 @@ export const Section = styled.div`
190
237
  align-items: flex-start;
191
238
  gap: 8px;
192
239
  padding: 6px 0;
193
- font-size: 12px;
240
+ font-size: 13px;
194
241
  color: ${GlobalColors.deep_gray};
195
242
  cursor: pointer;
196
243
  }
197
244
 
198
245
  label.choice span.hint {
199
246
  display: block;
200
- font-size: 11px;
247
+ font-size: 12px;
201
248
  color: ${GlobalColors.gray};
202
249
  }
203
250
  `;
@@ -206,14 +253,14 @@ export const Message = styled.p`
206
253
  margin: 0 0 12px;
207
254
  padding: 10px 12px;
208
255
  border-radius: 6px;
209
- font-size: 12px;
256
+ font-size: 13px;
210
257
  line-height: 1.4;
211
258
  background-color: ${GlobalColors.s2};
212
259
  color: ${GlobalColors.deep_gray};
213
260
 
214
261
  &.error {
215
- background-color: rgba(${GlobalColors.rgb_color_pink}, 0.1);
216
- color: ${GlobalColors.original_magenta};
262
+ background-color: rgba(${PINK_RGB}, 0.1);
263
+ color: ${PINK};
217
264
  }
218
265
  `;
219
266
 
@@ -226,7 +273,7 @@ export const Footer = styled.div`
226
273
  border-top: 1px solid ${GlobalColors.s2};
227
274
 
228
275
  .summary {
229
- font-size: 12px;
276
+ font-size: 13px;
230
277
  color: ${GlobalColors.gray};
231
278
  }
232
279
 
@@ -241,7 +288,7 @@ export const Footer = styled.div`
241
288
  padding: 0 18px;
242
289
  border-radius: 6px;
243
290
  font-family: ${FontFamily.Raleway_600};
244
- font-size: 12px;
291
+ font-size: 13px;
245
292
  cursor: pointer;
246
293
  }
247
294
 
@@ -253,7 +300,7 @@ export const Footer = styled.div`
253
300
 
254
301
  button.primary {
255
302
  border: none;
256
- background-color: ${GlobalColors.original_magenta};
303
+ background-color: ${PINK};
257
304
  color: ${GlobalColors.white};
258
305
  }
259
306
 
@@ -263,45 +310,6 @@ export const Footer = styled.div`
263
310
  }
264
311
  `;
265
312
 
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
313
  export const ImageGrid = styled.div`
306
314
  display: grid;
307
315
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
@@ -320,8 +328,12 @@ export const ImageGrid = styled.div`
320
328
  }
321
329
 
322
330
  label.picked {
323
- border-color: ${GlobalColors.original_magenta};
324
- background-color: rgba(${GlobalColors.rgb_color_pink}, 0.06);
331
+ border-color: ${PINK};
332
+ background-color: rgba(${PINK_RGB}, 0.06);
333
+ }
334
+
335
+ label.locked {
336
+ cursor: default;
325
337
  }
326
338
 
327
339
  label input {
@@ -339,7 +351,7 @@ export const ImageGrid = styled.div`
339
351
  }
340
352
 
341
353
  label span {
342
- font-size: 10px;
354
+ font-size: 11px;
343
355
  color: ${GlobalColors.gray};
344
356
  text-align: center;
345
357
  overflow: hidden;
@@ -350,17 +362,19 @@ export const ImageGrid = styled.div`
350
362
 
351
363
  export const AddRetailer = styled.div`
352
364
  display: flex;
365
+ flex-wrap: wrap;
353
366
  gap: 8px;
354
367
  margin-bottom: 16px;
355
368
 
356
369
  select {
357
- flex: 1;
370
+ flex: 1 1 140px;
371
+ min-width: 0;
358
372
  height: 32px;
359
373
  padding: 0 8px;
360
374
  border: 1px solid ${GlobalColors.s2};
361
375
  border-radius: 6px;
362
376
  font-family: ${FontFamily.Raleway};
363
- font-size: 12px;
377
+ font-size: 13px;
364
378
  color: ${GlobalColors.deep_gray};
365
379
  background-color: ${GlobalColors.white};
366
380
  }
@@ -368,17 +382,159 @@ export const AddRetailer = styled.div`
368
382
  button {
369
383
  height: 32px;
370
384
  padding: 0 14px;
371
- border: 1px solid ${GlobalColors.original_magenta};
385
+ border: 1px solid ${PINK};
372
386
  border-radius: 6px;
373
387
  background: none;
374
388
  font-family: ${FontFamily.Raleway_600};
375
- font-size: 12px;
376
- color: ${GlobalColors.original_magenta};
389
+ font-size: 13px;
390
+ color: ${PINK};
377
391
  cursor: pointer;
378
392
  }
379
393
 
394
+ select:disabled {
395
+ opacity: 0.5;
396
+ cursor: default;
397
+ }
398
+
380
399
  button:disabled {
381
400
  opacity: 0.4;
382
401
  cursor: default;
383
402
  }
384
403
  `;
404
+
405
+ export const Block = styled.section`
406
+ margin-bottom: 20px;
407
+ padding-bottom: 16px;
408
+ border-bottom: 1px solid ${GlobalColors.s2};
409
+
410
+ &:last-of-type {
411
+ border-bottom: none;
412
+ }
413
+
414
+ h3 {
415
+ display: flex;
416
+ align-items: center;
417
+ gap: 8px;
418
+ margin: 0 0 8px;
419
+ font-family: ${FontFamily.Raleway_600};
420
+ font-size: 14px;
421
+ color: ${GlobalColors.deep_gray};
422
+ }
423
+
424
+ h3 .paso {
425
+ display: inline-flex;
426
+ align-items: center;
427
+ justify-content: center;
428
+ width: 18px;
429
+ height: 18px;
430
+ border-radius: 50%;
431
+ background-color: ${PINK};
432
+ color: ${GlobalColors.white};
433
+ font-size: 11px;
434
+ }
435
+ `;
436
+
437
+ export const Choices = styled.div`
438
+ display: flex;
439
+ flex-direction: column;
440
+ gap: 2px;
441
+ margin-bottom: 10px;
442
+
443
+ label {
444
+ display: flex;
445
+ align-items: flex-start;
446
+ gap: 8px;
447
+ padding: 4px 0;
448
+ font-size: 13px;
449
+ color: ${GlobalColors.deep_gray};
450
+ cursor: pointer;
451
+ }
452
+
453
+ label .hint {
454
+ display: block;
455
+ font-size: 12px;
456
+ color: ${GlobalColors.gray};
457
+ }
458
+ `;
459
+
460
+ export const Paging = styled.div`
461
+ display: flex;
462
+ align-items: center;
463
+ justify-content: space-between;
464
+ gap: 12px;
465
+ margin: -8px 0 16px;
466
+ font-family: ${FontFamily.Raleway_500};
467
+ font-size: 12px;
468
+ color: ${GlobalColors.gray};
469
+
470
+ button {
471
+ border: 1px solid ${GlobalColors.s2};
472
+ border-radius: 6px;
473
+ background: none;
474
+ padding: 5px 12px;
475
+ cursor: pointer;
476
+ font-family: ${FontFamily.Raleway_600};
477
+ font-size: 12px;
478
+ color: ${PINK};
479
+ }
480
+
481
+ button:disabled {
482
+ opacity: 0.5;
483
+ cursor: default;
484
+ }
485
+ `;
486
+
487
+ export const Tabs = styled.div`
488
+ display: flex;
489
+ flex-wrap: wrap;
490
+ gap: 6px;
491
+ margin-bottom: 16px;
492
+ padding-bottom: 12px;
493
+ border-bottom: 1px solid ${GlobalColors.s2};
494
+
495
+ button {
496
+ display: inline-flex;
497
+ align-items: center;
498
+ gap: 6px;
499
+ max-width: 200px;
500
+ padding: 6px 10px;
501
+ border: 1px solid ${GlobalColors.s2};
502
+ border-radius: 6px;
503
+ background-color: ${GlobalColors.white};
504
+ cursor: pointer;
505
+ font-family: ${FontFamily.Raleway_500};
506
+ font-size: 12px;
507
+ color: ${GlobalColors.gray};
508
+ overflow: hidden;
509
+ text-overflow: ellipsis;
510
+ white-space: nowrap;
511
+ }
512
+
513
+ button.active {
514
+ border-color: ${PINK};
515
+ color: ${PINK};
516
+ background-color: rgba(${PINK_RGB}, 0.08);
517
+ }
518
+
519
+ button .orden {
520
+ display: inline-flex;
521
+ align-items: center;
522
+ justify-content: center;
523
+ width: 16px;
524
+ height: 16px;
525
+ border-radius: 50%;
526
+ background-color: ${GlobalColors.s2};
527
+ font-size: 10px;
528
+ flex-shrink: 0;
529
+ }
530
+
531
+ button.active .orden {
532
+ background-color: ${PINK};
533
+ color: ${GlobalColors.white};
534
+ }
535
+
536
+ button .listo {
537
+ color: ${PINK};
538
+ flex-shrink: 0;
539
+ }
540
+ `;
@@ -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
- const openVariant = (articleId) => {
726
- // Se navega igual que el resto de la app, con el id en la ruta. Inventar
727
- // otra forma de abrir un producto es inventar otra forma de que se rompa.
728
- window.location.assign(`/products/${articleId}/datasheet`);
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">Producto padre</span>
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.isCurrent ? "Estás aquí" : "Variante"}
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>
@@ -1,6 +1,9 @@
1
1
  import styled from "styled-components";
2
2
  import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
3
 
4
+ // Rosa ContentOh, el mismo del modal de ligar productos.
5
+ const PINK = "#E13AA8";
6
+
4
7
  export const Container = styled.div`
5
8
  display: flex;
6
9
  flex-direction: column;
@@ -167,13 +170,13 @@ export const Container = styled.div`
167
170
  margin-bottom: 8px;
168
171
 
169
172
  .link-variants {
170
- border: 1px solid ${GlobalColors.original_magenta};
173
+ border: 1px solid ${PINK};
171
174
  border-radius: 6px;
172
175
  background: none;
173
176
  padding: 6px 12px;
174
177
  font-family: ${FontFamily.Raleway_600};
175
178
  font-size: 11px;
176
- color: ${GlobalColors.original_magenta};
179
+ color: ${PINK};
177
180
  cursor: pointer;
178
181
  }
179
182
 
@@ -232,7 +235,7 @@ export const Container = styled.div`
232
235
  .family-row .role {
233
236
  min-width: 96px;
234
237
  font-size: 10px;
235
- color: ${GlobalColors.original_magenta};
238
+ color: ${PINK};
236
239
  }
237
240
 
238
241
  .family-row.current .role {