contentoh-components-library 21.6.31 → 21.6.32

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.
@@ -18,9 +18,9 @@ var _templateObject;
18
18
  // Rosa ContentOh, el mismo del modal de ligar productos.
19
19
  var PINK = "#E13AA8";
20
20
 
21
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n height: 100%;\n flex: 1;\n overflow: auto;\n\n .data-container {\n display: flex;\n flex: 0%;\n height: calc(100% - ", "px);\n .image-data-panel {\n width: 340px;\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .product-information {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .services-information-container {\n height: 100%;\n overflow: auto;\n }\n\n .image-services {\n aside {\n display: grid;\n grid-template-columns: repeat(auto-fill, 179px);\n column-gap: 15px;\n row-gap: 15px;\n padding: 20px;\n }\n }\n\n .commentary-box {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n padding: 10px;\n padding-left: 0;\n\n .action-buttons{\n display: flex;\n flex-direction: column;\n gap: 1rem;\n }\n\n .commentary {\n display: flex;\n align-items: flex-end;\n\n .input-container {\n width: 500px;\n\n .quill {\n height: 100px;\n }\n\n & + * {\n margin-left: 5px;\n }\n }\n\n .buttons-box {\n display: flex;\n width: 210px;\n flex-wrap: wrap;\n\n .general-transparent-button {\n & + * {\n margin-top: 5px;\n }\n }\n\n .general-transparent-button,\n .general-green-button,\n .general-button-disabled {\n width: fit-content;\n min-width: 201px;\n height: 40px;\n }\n }\n }\n }\n\n .feedback-box {\n display: flex;\n }\n\n .required-inputs-message {\n font-family: ", ";\n font-size: 13px;\n color: ", ";\n padding: 10px;\n display: flex;\n align-items: center;\n\n p + * {\n margin-top: 10px;\n }\n\n button {\n min-width: fit-content;\n }\n }\n }\n }\n #modal-message-box {\n width: 400px;\n height: 100px;\n }\n .container {\n width: 100%;\n height: 90%;\n .dropzone {\n height: 100%;\n width: 100%;\n position: relative;\n transition: all 0.5s ease;\n\n &.drag-active {\n background-color: rgba(", ", 0.05);\n border: 2px dashed ", ";\n border-radius: 8px;\n\n aside {\n opacity: 0.3;\n pointer-events: none;\n }\n }\n\n .drag-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(", ", 0.1);\n border-radius: 8px;\n pointer-events: none;\n z-index: 10;\n\n p {\n font-family: ", ";\n font-size: 24px;\n font-weight: 600;\n color: ", ";\n text-align: center;\n padding: 20px;\n background-color: ", ";\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n }\n }\n }\n\n .variants-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n\n .link-variants {\n border: 1px solid ", ";\n border-radius: 6px;\n background: none;\n padding: 6px 12px;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n cursor: pointer;\n }\n\n .variants-count {\n border: none;\n background: none;\n padding: 0;\n cursor: pointer;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n text-decoration: underline;\n }\n }\n\n .variants-family {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-bottom: 10px;\n padding: 8px;\n border: 1px solid ", ";\n border-radius: 6px;\n\n .loading {\n margin: 0;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n }\n\n .family-row {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 6px 8px;\n border: none;\n border-radius: 4px;\n background: none;\n cursor: pointer;\n text-align: left;\n font-family: ", ";\n font-size: 12px;\n color: ", ";\n }\n\n .family-row:hover:not(:disabled) {\n background-color: ", ";\n }\n\n .family-row:disabled {\n cursor: default;\n opacity: 0.7;\n }\n\n .family-row .role {\n min-width: 96px;\n font-size: 10px;\n color: ", ";\n }\n\n .family-row.current .role {\n color: ", ";\n }\n\n .family-row .name {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .family-row .upc {\n font-size: 11px;\n color: ", ";\n }\n }\n"])), function (_ref) {
21
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n height: 100%;\n flex: 1;\n overflow: auto;\n\n .data-container {\n display: flex;\n flex: 0%;\n height: calc(100% - ", "px);\n .image-data-panel {\n width: 340px;\n\n & + * {\n margin-left: 10px;\n }\n }\n\n .product-information {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .services-information-container {\n height: 100%;\n overflow: auto;\n }\n\n .image-services {\n aside {\n display: grid;\n grid-template-columns: repeat(auto-fill, 179px);\n column-gap: 15px;\n row-gap: 15px;\n padding: 20px;\n }\n }\n\n .commentary-box {\n display: flex;\n justify-content: space-between;\n align-items: flex-end;\n padding: 10px;\n padding-left: 0;\n\n .action-buttons{\n display: flex;\n flex-direction: column;\n gap: 1rem;\n }\n\n .commentary {\n display: flex;\n align-items: flex-end;\n\n .input-container {\n width: 500px;\n\n .quill {\n height: 100px;\n }\n\n & + * {\n margin-left: 5px;\n }\n }\n\n .buttons-box {\n display: flex;\n width: 210px;\n flex-wrap: wrap;\n\n .general-transparent-button {\n & + * {\n margin-top: 5px;\n }\n }\n\n .general-transparent-button,\n .general-green-button,\n .general-button-disabled {\n width: fit-content;\n min-width: 201px;\n height: 40px;\n }\n }\n }\n }\n\n .feedback-box {\n display: flex;\n }\n\n .required-inputs-message {\n font-family: ", ";\n font-size: 13px;\n color: ", ";\n padding: 10px;\n display: flex;\n align-items: center;\n\n p + * {\n margin-top: 10px;\n }\n\n button {\n min-width: fit-content;\n }\n }\n }\n }\n #modal-message-box {\n width: 400px;\n height: 100px;\n }\n .container {\n width: 100%;\n height: 90%;\n .dropzone {\n height: 100%;\n width: 100%;\n position: relative;\n transition: all 0.5s ease;\n\n &.drag-active {\n background-color: rgba(", ", 0.05);\n border: 2px dashed ", ";\n border-radius: 8px;\n\n aside {\n opacity: 0.3;\n pointer-events: none;\n }\n }\n\n .drag-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(", ", 0.1);\n border-radius: 8px;\n pointer-events: none;\n z-index: 10;\n\n p {\n font-family: ", ";\n font-size: 24px;\n font-weight: 600;\n color: ", ";\n text-align: center;\n padding: 20px;\n background-color: ", ";\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n }\n }\n }\n\n .variants-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 8px;\n\n .link-variants {\n border: 1px solid ", ";\n border-radius: 6px;\n background: none;\n padding: 6px 12px;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n cursor: pointer;\n }\n\n .variants-count {\n border: none;\n background: none;\n padding: 0;\n cursor: pointer;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n text-decoration: underline;\n }\n }\n\n .variants-family {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin-bottom: 10px;\n padding: 8px;\n border: 1px solid ", ";\n border-radius: 6px;\n\n .loading {\n margin: 0;\n font-family: ", ";\n font-size: 11px;\n color: ", ";\n }\n\n .family-row {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 6px 8px;\n border-radius: 4px;\n text-align: left;\n font-family: ", ";\n font-size: 12px;\n color: ", ";\n }\n\n\n .family-row .role {\n min-width: 96px;\n font-size: 10px;\n color: ", ";\n }\n\n .family-row.current .role {\n color: ", ";\n }\n\n .family-row .name {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .family-row .upc {\n font-size: 11px;\n color: ", ";\n }\n }\n"])), function (_ref) {
22
22
  var headerTop = _ref.headerTop;
23
23
  return headerTop;
24
- }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_gray, _variables.GlobalColors.rgb_color_pink, _variables.GlobalColors.color_pink, _variables.GlobalColors.rgb_color_pink, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_pink, _variables.GlobalColors.white, PINK, _variables.FontFamily.Raleway_600, PINK, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.GlobalColors.s2, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.FontFamily.Raleway_500, _variables.GlobalColors.deep_gray, _variables.GlobalColors.s2, PINK, _variables.GlobalColors.gray, _variables.GlobalColors.gray);
24
+ }, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_gray, _variables.GlobalColors.rgb_color_pink, _variables.GlobalColors.color_pink, _variables.GlobalColors.rgb_color_pink, _variables.FontFamily.AvenirNext, _variables.GlobalColors.color_pink, _variables.GlobalColors.white, PINK, _variables.FontFamily.Raleway_600, PINK, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.GlobalColors.s2, _variables.FontFamily.Raleway_500, _variables.GlobalColors.gray, _variables.FontFamily.Raleway_500, _variables.GlobalColors.deep_gray, PINK, _variables.GlobalColors.gray, _variables.GlobalColors.gray);
25
25
 
26
26
  exports.Container = Container;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.6.31",
3
+ "version": "21.6.32",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -185,7 +185,6 @@ const RetailerProductEditionView = ({
185
185
  const [showLinkVariants, setShowLinkVariants] = useState(false);
186
186
  const [family, setFamily] = useState(null);
187
187
  const [showFamily, setShowFamily] = useState(false);
188
- const [loadingVariant, setLoadingVariant] = useState(null);
189
188
  const [pendingPropagation, setPendingPropagation] = useState(null);
190
189
  const [preparandoPropagacion, setPreparandoPropagacion] = useState(false);
191
190
 
@@ -787,8 +786,8 @@ const RetailerProductEditionView = ({
787
786
  una de ellas. Se pide al abrir la sección y no al montar la pantalla: la
788
787
  mayoría de los productos no son familia.
789
788
  */
790
- const loadFamily = async () => {
791
- if (family) return family;
789
+ const loadFamily = async (forzar = false) => {
790
+ if (family && !forzar) return family;
792
791
  try {
793
792
  const res = await axios.post(
794
793
  `${process.env.REACT_APP_VARIANTS_ENDPOINT}/family`,
@@ -806,43 +805,48 @@ const RetailerProductEditionView = ({
806
805
  };
807
806
 
808
807
  /*
809
- Abre otra variante. Esta pantalla lee el producto de sessionStorage, no de la
810
- URL, así que hay que dejarlo ahí antes de navegar; si no, cambia la dirección
811
- y sigue mostrando el producto anterior.
808
+ En Creators el parentesco se pregunta, no viene con el producto.
812
809
 
813
- Se pide por ID y no por UPC: hay 12,024 UPC repetidos entre artículos activos
814
- y 5,579 de esos casos caen dentro de la misma compañía.
810
+ Su listado sale del endpoint de reportes, que no trae `variantsCount` ni
811
+ `parentArticleId`: esas columnas se agregaron a las vistas pero DynamoDB no
812
+ las tiene hasta que se corra el recorrido de datos. Y aunque las tuviera,
813
+ dependería de lo actualizado que esté ese recorrido.
814
+
815
+ Preguntar a `family` cuesta una llamada por ficha y da el dato de la base, no
816
+ de una copia. Además aplica el alcance del perfil (§5.1): al equipo interno le
817
+ devuelve los productos solicitados a ContentOh, que es justo lo que puede
818
+ tocar.
815
819
  */
816
- const openVariant = async (articleId) => {
817
- setLoadingVariant(articleId);
818
- try {
819
- const res = await axios.get(`${process.env.REACT_APP_NEW_ARTICLES_ENDPOINT}`, {
820
- params: { listType: "general", filterByArticleId: articleId },
821
- headers: { Authorization: token },
822
- });
820
+ useEffect(() => {
821
+ if (!state.product?.id_article) return;
822
+ loadFamily(true);
823
+ // eslint-disable-next-line react-hooks/exhaustive-deps
824
+ }, [state.product?.id_article]);
823
825
 
824
- const { data } = readPayload(res);
825
- const encontrado = (data ?? []).find(
826
- (item) => Number(item.id_article) === Number(articleId)
827
- );
826
+ // El conteo sale de la familia recién consultada, no del producto.
827
+ const variantesDelProducto = family?.error
828
+ ? 0
829
+ : (family?.variants ?? []).filter((v) => !v.isCurrent).length;
828
830
 
829
- if (encontrado) {
830
- sessionStorage.setItem(
831
- "productSelected",
832
- JSON.stringify({
833
- ...encontrado,
834
- article: { id_article: encontrado.id_article },
835
- })
836
- );
837
- }
838
- } catch (error) {
839
- // Se navega igual: dejar el clic sin efecto parecería que no responde.
840
- console.error("openVariant: ", error);
841
- } finally {
842
- setLoadingVariant(null);
843
- window.location.assign("/EditProducts");
844
- }
845
- };
831
+ const esVarianteDeOtro = family?.error
832
+ ? !!state.product?.parentArticleId
833
+ : !!family?.parent;
834
+
835
+ /*
836
+ En Creators la lista de familia es INFORMATIVA: no se salta a otra variante.
837
+
838
+ Saltar exige precargar el producto destino, y el endpoint que hace eso en la
839
+ aplicación de clientes —read-articles-v2— filtra por la compañía del usuario:
840
+ `AND a.company_id = <la del usuario>`. El equipo interno pertenece a ContentOh
841
+ y trabaja productos de sus clientes, así que ahí no devuelve nada.
842
+
843
+ Navegar sin precargar sería peor que no ofrecerlo: esta pantalla lee el
844
+ producto de sessionStorage, así que cambiaría la URL y seguiría mostrando el
845
+ producto anterior, dando a entender que se cambió de variante cuando no.
846
+
847
+ Para habilitarlo hace falta una forma de traer un producto por id sin filtro
848
+ de compañía, respetando el alcance del perfil interno (§5.1 del contrato).
849
+ */
846
850
 
847
851
  /*
848
852
  Refresca tras ligar, sin recargar: el producto sale de sessionStorage, así que
@@ -932,7 +936,7 @@ const RetailerProductEditionView = ({
932
936
  // Guardar un padre con variantes abre la decisión de propagar. Sin este
933
937
  // paso el cambio se queda solo en el padre y las variantes se van
934
938
  // separando de él sin que nadie lo note.
935
- const esPadre = state.product?.variantsCount > 0;
939
+ const esPadre = variantesDelProducto > 0;
936
940
  const cambios = cambiosDeFichaTecnica();
937
941
 
938
942
  if (esPadre && cambios.length > 0) {
@@ -1928,7 +1932,7 @@ const RetailerProductEditionView = ({
1928
1932
  <div className="product-information">
1929
1933
  {/* Solo si el producto NO es ya variante de alguien: ligarlo otra vez
1930
1934
  devolvería VARIANT_ALREADY_LINKED sin excepción. */}
1931
- {!state.product?.parentArticleId && (
1935
+ {!esVarianteDeOtro && (
1932
1936
  <div className="variants-actions">
1933
1937
  <button
1934
1938
  type="button"
@@ -1937,7 +1941,7 @@ const RetailerProductEditionView = ({
1937
1941
  >
1938
1942
  Ligar productos
1939
1943
  </button>
1940
- {state.product?.variantsCount > 0 && (
1944
+ {variantesDelProducto > 0 && (
1941
1945
  <button
1942
1946
  type="button"
1943
1947
  className="variants-count"
@@ -1947,15 +1951,15 @@ const RetailerProductEditionView = ({
1947
1951
  loadFamily();
1948
1952
  }}
1949
1953
  >
1950
- {state.product.variantsCount} variante
1951
- {state.product.variantsCount === 1 ? "" : "s"}
1954
+ {variantesDelProducto} variante
1955
+ {variantesDelProducto === 1 ? "" : "s"}
1952
1956
  <span aria-hidden="true">{showFamily ? " ▴" : " ▾"}</span>
1953
1957
  </button>
1954
1958
  )}
1955
1959
  </div>
1956
1960
  )}
1957
1961
 
1958
- {state.product?.parentArticleId && (
1962
+ {esVarianteDeOtro && (
1959
1963
  <div className="variants-actions">
1960
1964
  <button
1961
1965
  type="button"
@@ -1983,40 +1987,24 @@ const RetailerProductEditionView = ({
1983
1987
  )}
1984
1988
 
1985
1989
  {family?.parent && (
1986
- <button
1987
- type="button"
1988
- className="family-row parent"
1989
- disabled={loadingVariant !== null}
1990
- onClick={() => openVariant(family.parent.articleId)}
1991
- >
1992
- <span className="role">
1993
- {loadingVariant === family.parent.articleId
1994
- ? "Abriendo…"
1995
- : "Producto padre"}
1996
- </span>
1990
+ <div className="family-row parent">
1991
+ <span className="role">Producto padre</span>
1997
1992
  <span className="name">{family.parent.name}</span>
1998
1993
  <span className="upc">{family.parent.upc}</span>
1999
- </button>
1994
+ </div>
2000
1995
  )}
2001
1996
 
2002
1997
  {family?.variants?.map((variant) => (
2003
- <button
1998
+ <div
2004
1999
  key={variant.articleId}
2005
- type="button"
2006
2000
  className={`family-row${variant.isCurrent ? " current" : ""}`}
2007
- disabled={variant.isCurrent || loadingVariant !== null}
2008
- onClick={() => openVariant(variant.articleId)}
2009
2001
  >
2010
2002
  <span className="role">
2011
- {loadingVariant === variant.articleId
2012
- ? "Abriendo…"
2013
- : variant.isCurrent
2014
- ? "Estás aquí"
2015
- : "Variante"}
2003
+ {variant.isCurrent ? "Estás aquí" : "Variante"}
2016
2004
  </span>
2017
2005
  <span className="name">{variant.name}</span>
2018
2006
  <span className="upc">{variant.upc}</span>
2019
- </button>
2007
+ </div>
2020
2008
  ))}
2021
2009
 
2022
2010
  {family && !family.error && !family.variants?.length && (
@@ -220,24 +220,13 @@ export const Container = styled.div`
220
220
  align-items: baseline;
221
221
  gap: 8px;
222
222
  padding: 6px 8px;
223
- border: none;
224
223
  border-radius: 4px;
225
- background: none;
226
- cursor: pointer;
227
224
  text-align: left;
228
225
  font-family: ${FontFamily.Raleway_500};
229
226
  font-size: 12px;
230
227
  color: ${GlobalColors.deep_gray};
231
228
  }
232
229
 
233
- .family-row:hover:not(:disabled) {
234
- background-color: ${GlobalColors.s2};
235
- }
236
-
237
- .family-row:disabled {
238
- cursor: default;
239
- opacity: 0.7;
240
- }
241
230
 
242
231
  .family-row .role {
243
232
  min-width: 96px;