contentoh-components-library 21.6.32 → 21.6.33
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/dist/ai/prompts/attribute.prompt.js +28 -0
- package/dist/ai/prompts/description.prompt.js +33 -0
- package/dist/ai/schemas/attribute.schema.js +35 -0
- package/dist/ai/schemas/description.schema.js +27 -0
- package/dist/components/atoms/InheritanceTag/InheritanceTag.stories.js +5 -5
- package/dist/components/atoms/InheritanceTag/index.js +6 -6
- package/dist/components/organisms/InputGroup/index.js +12 -1
- package/dist/components/organisms/LinkVariantsModal/index.js +269 -356
- package/dist/components/organisms/LinkVariantsModal/styles.js +14 -5
- package/dist/components/organisms/PropagateChangesModal/index.js +12 -13
- package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +5 -5
- package/dist/components/pages/ProviderProductEdition/context/reducers/inputs.js +5 -2
- package/dist/components/pages/ProviderProductEdition/index.js +76 -33
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +5 -5
- package/dist/components/pages/RetailerProductEdition/context/reducers/inputs.js +5 -2
- package/dist/components/pages/RetailerProductEdition/index.js +75 -35
- package/package.json +1 -1
- package/src/components/atoms/InheritanceTag/InheritanceTag.stories.js +3 -3
- package/src/components/atoms/InheritanceTag/index.js +6 -6
- package/src/components/organisms/InputGroup/index.js +12 -0
- package/src/components/organisms/LinkVariantsModal/index.js +260 -287
- package/src/components/organisms/LinkVariantsModal/styles.js +65 -32
- package/src/components/organisms/PropagateChangesModal/index.js +19 -17
- package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +4 -4
- package/src/components/pages/ProviderProductEdition/context/reducers/inputs.js +13 -1
- package/src/components/pages/ProviderProductEdition/index.js +48 -20
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +4 -4
- package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +13 -1
- package/src/components/pages/RetailerProductEdition/index.js +48 -20
|
@@ -181,7 +181,7 @@ const RetailerProductEditionView = ({
|
|
|
181
181
|
const [statusArray, setStatusArray] = useState([]);
|
|
182
182
|
const [rejectAll, setRejectAll] = useState(false);
|
|
183
183
|
|
|
184
|
-
//
|
|
184
|
+
// Padre/hijo: mismo comportamiento que la ficha de la aplicación de clientes.
|
|
185
185
|
const [showLinkVariants, setShowLinkVariants] = useState(false);
|
|
186
186
|
const [family, setFamily] = useState(null);
|
|
187
187
|
const [showFamily, setShowFamily] = useState(false);
|
|
@@ -782,7 +782,7 @@ const RetailerProductEditionView = ({
|
|
|
782
782
|
};
|
|
783
783
|
|
|
784
784
|
/*
|
|
785
|
-
Trae la familia:
|
|
785
|
+
Trae la familia: los hijos del producto, o sus hermanos si el abierto es
|
|
786
786
|
una de ellas. Se pide al abrir la sección y no al montar la pantalla: la
|
|
787
787
|
mayoría de los productos no son familia.
|
|
788
788
|
*/
|
|
@@ -824,16 +824,16 @@ const RetailerProductEditionView = ({
|
|
|
824
824
|
}, [state.product?.id_article]);
|
|
825
825
|
|
|
826
826
|
// El conteo sale de la familia recién consultada, no del producto.
|
|
827
|
-
const
|
|
827
|
+
const hijosDelProducto = family?.error
|
|
828
828
|
? 0
|
|
829
829
|
: (family?.variants ?? []).filter((v) => !v.isCurrent).length;
|
|
830
830
|
|
|
831
|
-
const
|
|
831
|
+
const esHijoDeOtro = family?.error
|
|
832
832
|
? !!state.product?.parentArticleId
|
|
833
833
|
: !!family?.parent;
|
|
834
834
|
|
|
835
835
|
/*
|
|
836
|
-
En Creators la lista de familia es INFORMATIVA: no se salta a
|
|
836
|
+
En Creators la lista de familia es INFORMATIVA: no se salta a otro producto.
|
|
837
837
|
|
|
838
838
|
Saltar exige precargar el producto destino, y el endpoint que hace eso en la
|
|
839
839
|
aplicación de clientes —read-articles-v2— filtra por la compañía del usuario:
|
|
@@ -842,7 +842,7 @@ const RetailerProductEditionView = ({
|
|
|
842
842
|
|
|
843
843
|
Navegar sin precargar sería peor que no ofrecerlo: esta pantalla lee el
|
|
844
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
|
|
845
|
+
producto anterior, dando a entender que se cambió de producto cuando no.
|
|
846
846
|
|
|
847
847
|
Para habilitarlo hace falta una forma de traer un producto por id sin filtro
|
|
848
848
|
de compañía, respetando el alcance del perfil interno (§5.1 del contrato).
|
|
@@ -882,18 +882,42 @@ const RetailerProductEditionView = ({
|
|
|
882
882
|
Acción "Volver a heredar" de los chips. Repinta en sitio con lo que devuelve
|
|
883
883
|
el endpoint: recargar la ficha se llevaría lo que haya sin guardar.
|
|
884
884
|
*/
|
|
885
|
-
|
|
885
|
+
/*
|
|
886
|
+
`kind` distingue de qué pestaña salió el chip. Las descripciones viven en
|
|
887
|
+
`rel_article_description` y la ficha técnica en `article_data`: el endpoint
|
|
888
|
+
recibe una lista o la otra.
|
|
889
|
+
*/
|
|
890
|
+
const handleOnRestoreInheritance = async (attributeId, kind = "attribute") => {
|
|
886
891
|
if (!attributeId || !state.product?.id_article) return;
|
|
887
892
|
|
|
893
|
+
const esDescripcion = kind === "description";
|
|
894
|
+
|
|
888
895
|
try {
|
|
889
896
|
const res = await axios.post(
|
|
890
897
|
`${process.env.REACT_APP_VARIANTS_ENDPOINT}/restore`,
|
|
891
|
-
{
|
|
898
|
+
{
|
|
899
|
+
articleId: state.product.id_article,
|
|
900
|
+
...(esDescripcion
|
|
901
|
+
? { descriptions: [Number(attributeId)] }
|
|
902
|
+
: { attributes: [Number(attributeId)] }),
|
|
903
|
+
},
|
|
892
904
|
{ headers: { Authorization: token } }
|
|
893
905
|
);
|
|
894
906
|
|
|
895
907
|
const data = readPayload(res);
|
|
896
908
|
|
|
909
|
+
if (esDescripcion) {
|
|
910
|
+
dispatch({
|
|
911
|
+
type: "UPDATE_DESCRIPTIONS_INPUTS",
|
|
912
|
+
payload: (data.descriptionValues || []).map((item) => ({
|
|
913
|
+
attributeId: item.id_description,
|
|
914
|
+
value: item.value,
|
|
915
|
+
isOverridden: 0,
|
|
916
|
+
})),
|
|
917
|
+
});
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
|
|
897
921
|
dispatch({
|
|
898
922
|
type: "UPDATE_DATASHEETS_INPUTS",
|
|
899
923
|
payload: (data.values || []).map((item) => ({
|
|
@@ -933,10 +957,10 @@ const RetailerProductEditionView = ({
|
|
|
933
957
|
await saveDescriptions(token);
|
|
934
958
|
break;
|
|
935
959
|
case "Ficha técnica": {
|
|
936
|
-
// Guardar un padre con
|
|
937
|
-
// paso el cambio se queda solo en el padre y
|
|
960
|
+
// Guardar un padre con hijos abre la decisión de propagar. Sin este
|
|
961
|
+
// paso el cambio se queda solo en el padre y los hijos se van
|
|
938
962
|
// separando de él sin que nadie lo note.
|
|
939
|
-
const esPadre =
|
|
963
|
+
const esPadre = hijosDelProducto > 0;
|
|
940
964
|
const cambios = cambiosDeFichaTecnica();
|
|
941
965
|
|
|
942
966
|
if (esPadre && cambios.length > 0) {
|
|
@@ -1930,9 +1954,9 @@ const RetailerProductEditionView = ({
|
|
|
1930
1954
|
</div>
|
|
1931
1955
|
|
|
1932
1956
|
<div className="product-information">
|
|
1933
|
-
{/* Solo si el producto NO es ya
|
|
1957
|
+
{/* Solo si el producto NO es ya hijo de alguien: ligarlo otra vez
|
|
1934
1958
|
devolvería VARIANT_ALREADY_LINKED sin excepción. */}
|
|
1935
|
-
{!
|
|
1959
|
+
{!esHijoDeOtro && (
|
|
1936
1960
|
<div className="variants-actions">
|
|
1937
1961
|
<button
|
|
1938
1962
|
type="button"
|
|
@@ -1941,7 +1965,7 @@ const RetailerProductEditionView = ({
|
|
|
1941
1965
|
>
|
|
1942
1966
|
Ligar productos
|
|
1943
1967
|
</button>
|
|
1944
|
-
{
|
|
1968
|
+
{hijosDelProducto > 0 && (
|
|
1945
1969
|
<button
|
|
1946
1970
|
type="button"
|
|
1947
1971
|
className="variants-count"
|
|
@@ -1951,15 +1975,15 @@ const RetailerProductEditionView = ({
|
|
|
1951
1975
|
loadFamily();
|
|
1952
1976
|
}}
|
|
1953
1977
|
>
|
|
1954
|
-
{
|
|
1955
|
-
{
|
|
1978
|
+
{hijosDelProducto} hijo
|
|
1979
|
+
{hijosDelProducto === 1 ? "" : "s"}
|
|
1956
1980
|
<span aria-hidden="true">{showFamily ? " ▴" : " ▾"}</span>
|
|
1957
1981
|
</button>
|
|
1958
1982
|
)}
|
|
1959
1983
|
</div>
|
|
1960
1984
|
)}
|
|
1961
1985
|
|
|
1962
|
-
{
|
|
1986
|
+
{esHijoDeOtro && (
|
|
1963
1987
|
<div className="variants-actions">
|
|
1964
1988
|
<button
|
|
1965
1989
|
type="button"
|
|
@@ -1970,7 +1994,7 @@ const RetailerProductEditionView = ({
|
|
|
1970
1994
|
loadFamily();
|
|
1971
1995
|
}}
|
|
1972
1996
|
>
|
|
1973
|
-
|
|
1997
|
+
Hijo de otro producto
|
|
1974
1998
|
<span aria-hidden="true">{showFamily ? " ▴" : " ▾"}</span>
|
|
1975
1999
|
</button>
|
|
1976
2000
|
</div>
|
|
@@ -2000,7 +2024,7 @@ const RetailerProductEditionView = ({
|
|
|
2000
2024
|
className={`family-row${variant.isCurrent ? " current" : ""}`}
|
|
2001
2025
|
>
|
|
2002
2026
|
<span className="role">
|
|
2003
|
-
{variant.isCurrent ? "Estás aquí" : "
|
|
2027
|
+
{variant.isCurrent ? "Estás aquí" : "Hijo"}
|
|
2004
2028
|
</span>
|
|
2005
2029
|
<span className="name">{variant.name}</span>
|
|
2006
2030
|
<span className="upc">{variant.upc}</span>
|
|
@@ -2008,7 +2032,7 @@ const RetailerProductEditionView = ({
|
|
|
2008
2032
|
))}
|
|
2009
2033
|
|
|
2010
2034
|
{family && !family.error && !family.variants?.length && (
|
|
2011
|
-
<p className="loading">Este producto no tiene
|
|
2035
|
+
<p className="loading">Este producto no tiene hijos.</p>
|
|
2012
2036
|
)}
|
|
2013
2037
|
</div>
|
|
2014
2038
|
)}
|
|
@@ -2095,6 +2119,10 @@ const RetailerProductEditionView = ({
|
|
|
2095
2119
|
activeSection={state.active_tab}
|
|
2096
2120
|
inputGroup={state.descriptions_inputs[0]}
|
|
2097
2121
|
updatedDescriptions={state.updated_descriptions_inputs}
|
|
2122
|
+
/* El parentesco es del producto, no del servicio: los
|
|
2123
|
+
dos endpoints lo devuelven igual. */
|
|
2124
|
+
variant={state.services?.datasheets?.variant}
|
|
2125
|
+
onRestoreInheritance={handleOnRestoreInheritance}
|
|
2098
2126
|
articleId={state.product?.id_article}
|
|
2099
2127
|
version={state.product.version}
|
|
2100
2128
|
auditInputGroup={auditDescriptions[0]}
|