contentoh-components-library 21.6.34 → 21.6.36
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/components/organisms/UnlinkVariantModal/index.js +178 -0
- package/dist/components/organisms/UnlinkVariantModal/styles.js +42 -0
- package/dist/components/pages/ProviderProductEdition/index.js +186 -59
- package/dist/components/pages/ProviderProductEdition/styles.js +2 -2
- package/dist/components/pages/RetailerProductEdition/index.js +468 -220
- package/dist/components/pages/RetailerProductEdition/styles.js +2 -2
- package/dist/components/pages/RetailerProductEdition/utils.js +8 -3
- package/dist/index.js +25 -12
- package/package.json +1 -1
- package/src/components/organisms/UnlinkVariantModal/index.js +141 -0
- package/src/components/organisms/UnlinkVariantModal/styles.js +106 -0
- package/src/components/pages/ProviderProductEdition/index.js +166 -37
- package/src/components/pages/ProviderProductEdition/styles.js +30 -0
- package/src/components/pages/RetailerProductEdition/index.js +251 -25
- package/src/components/pages/RetailerProductEdition/styles.js +41 -0
- package/src/components/pages/RetailerProductEdition/utils.js +10 -3
- package/src/index.js +1 -0
- package/.claude/launch.json +0 -15
- package/dist/ai/prompts/attribute.prompt.js +0 -28
- package/dist/ai/prompts/description.prompt.js +0 -33
- package/dist/ai/schemas/attribute.schema.js +0 -35
- package/dist/ai/schemas/description.schema.js +0 -27
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.UnlinkVariantModal = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
17
|
+
|
|
18
|
+
var _react = require("react");
|
|
19
|
+
|
|
20
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
21
|
+
|
|
22
|
+
var _api = require("../LinkVariantsModal/api");
|
|
23
|
+
|
|
24
|
+
var _styles = require("./styles");
|
|
25
|
+
|
|
26
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
Confirmación para romper un vínculo padre/hijo.
|
|
30
|
+
|
|
31
|
+
El servidor ya sabía hacerlo desde el principio —POST /variants/unlink—, pero
|
|
32
|
+
no había forma de pedirlo desde ninguna pantalla: la única manera de deshacer
|
|
33
|
+
una liga era DESACTIVAR al padre, que suelta a todos los hijos de golpe y no
|
|
34
|
+
se puede revertir. Esto es la versión de a uno.
|
|
35
|
+
|
|
36
|
+
La acción se pide siempre con el id del HIJO, que es quien tiene el vínculo en
|
|
37
|
+
`article.parent_article_id`. Por eso las dos direcciones —un hijo que se suelta
|
|
38
|
+
y un padre que suelta a un hijo— son la misma llamada; lo único que cambia es
|
|
39
|
+
el texto, porque no es lo mismo lo que el usuario cree estar haciendo.
|
|
40
|
+
|
|
41
|
+
props (* requerido):
|
|
42
|
+
- *childArticleId: el hijo que pierde el vínculo
|
|
43
|
+
- childName / childUpc: para nombrarlo en el diálogo
|
|
44
|
+
- parentName / parentUpc: de quién se desprende
|
|
45
|
+
- mode: "self" (esta ficha deja de ser hija) | "child" (esta ficha suelta a un hijo)
|
|
46
|
+
- *token, endpoint
|
|
47
|
+
- *onClose, onUnlinked
|
|
48
|
+
*/
|
|
49
|
+
var UnlinkVariantModal = function UnlinkVariantModal(_ref) {
|
|
50
|
+
var childArticleId = _ref.childArticleId,
|
|
51
|
+
childName = _ref.childName,
|
|
52
|
+
childUpc = _ref.childUpc,
|
|
53
|
+
parentName = _ref.parentName,
|
|
54
|
+
parentUpc = _ref.parentUpc,
|
|
55
|
+
_ref$mode = _ref.mode,
|
|
56
|
+
mode = _ref$mode === void 0 ? "self" : _ref$mode,
|
|
57
|
+
token = _ref.token,
|
|
58
|
+
_ref$endpoint = _ref.endpoint,
|
|
59
|
+
endpoint = _ref$endpoint === void 0 ? process.env.REACT_APP_VARIANTS_ENDPOINT : _ref$endpoint,
|
|
60
|
+
onClose = _ref.onClose,
|
|
61
|
+
onUnlinked = _ref.onUnlinked;
|
|
62
|
+
|
|
63
|
+
var _useState = (0, _react.useState)(false),
|
|
64
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
65
|
+
loading = _useState2[0],
|
|
66
|
+
setLoading = _useState2[1];
|
|
67
|
+
|
|
68
|
+
var _useState3 = (0, _react.useState)(null),
|
|
69
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
70
|
+
error = _useState4[0],
|
|
71
|
+
setError = _useState4[1];
|
|
72
|
+
|
|
73
|
+
var nombreHijo = childName || "Producto ".concat(childArticleId);
|
|
74
|
+
var nombrePadre = parentName || "el producto padre";
|
|
75
|
+
|
|
76
|
+
var submit = /*#__PURE__*/function () {
|
|
77
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
78
|
+
var res, data;
|
|
79
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
80
|
+
while (1) {
|
|
81
|
+
switch (_context.prev = _context.next) {
|
|
82
|
+
case 0:
|
|
83
|
+
setLoading(true);
|
|
84
|
+
setError(null);
|
|
85
|
+
_context.prev = 2;
|
|
86
|
+
_context.next = 5;
|
|
87
|
+
return _axios.default.post("".concat(endpoint, "/unlink"), {
|
|
88
|
+
articleIds: [childArticleId]
|
|
89
|
+
}, {
|
|
90
|
+
headers: {
|
|
91
|
+
Authorization: token
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
case 5:
|
|
96
|
+
res = _context.sent;
|
|
97
|
+
data = (0, _api.readPayload)(res);
|
|
98
|
+
onUnlinked === null || onUnlinked === void 0 ? void 0 : onUnlinked((0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
99
|
+
mode: mode,
|
|
100
|
+
childArticleId: childArticleId
|
|
101
|
+
}));
|
|
102
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
103
|
+
_context.next = 15;
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case 11:
|
|
107
|
+
_context.prev = 11;
|
|
108
|
+
_context.t0 = _context["catch"](2);
|
|
109
|
+
// El transporte siempre responde 200; el error de negocio viaja dentro.
|
|
110
|
+
setError(_context.t0 instanceof _api.ApiError || (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.name) === "ApiError" ? _context.t0.message : "No se pudo desvincular. Intenta de nuevo.");
|
|
111
|
+
setLoading(false);
|
|
112
|
+
|
|
113
|
+
case 15:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context.stop();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, _callee, null, [[2, 11]]);
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
return function submit() {
|
|
122
|
+
return _ref2.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
125
|
+
|
|
126
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Overlay, {
|
|
127
|
+
onClick: loading ? undefined : onClose,
|
|
128
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Panel, {
|
|
129
|
+
onClick: function onClick(event) {
|
|
130
|
+
return event.stopPropagation();
|
|
131
|
+
},
|
|
132
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Header, {
|
|
133
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
134
|
+
children: mode === "self" ? "Dejar de ser hijo de otro producto" : "Desvincular este hijo"
|
|
135
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
136
|
+
children: mode === "self" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
137
|
+
children: ["\xAB", nombreHijo, "\xBB dejar\xE1 de colgar de \xAB", nombrePadre, "\xBB", parentUpc ? " (UPC ".concat(parentUpc, ")") : "", "."]
|
|
138
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
139
|
+
children: ["\xAB", nombreHijo, "\xBB", childUpc ? " (UPC ".concat(childUpc, ")") : "", " dejar\xE1 de colgar de este producto."]
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Body, {
|
|
143
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
144
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
145
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
146
|
+
children: "No se borra nada."
|
|
147
|
+
}), " Todo lo que hered\xF3 \u2014atributos, descripciones, im\xE1genes y cadenas\u2014 se queda como informaci\xF3n propia del producto."]
|
|
148
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
149
|
+
children: "Desaparecen las marcas de \xABHeredado\xBB y \xABPropio\xBB: sin padre dejan de querer decir algo."
|
|
150
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
151
|
+
children: ["Deja de recibir la propagaci\xF3n", mode === "self" ? " de su padre" : " de este producto", ": lo que se edite de un lado ya no baja al otro."]
|
|
152
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
153
|
+
className: "aviso",
|
|
154
|
+
children: "Volver a ligarlos es a mano, y hay que elegir otra vez qu\xE9 hereda. Desvincular no se deshace solo."
|
|
155
|
+
})]
|
|
156
|
+
})
|
|
157
|
+
}), error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Message, {
|
|
158
|
+
children: error
|
|
159
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Footer, {
|
|
160
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
161
|
+
type: "button",
|
|
162
|
+
className: "secondary",
|
|
163
|
+
onClick: onClose,
|
|
164
|
+
disabled: loading,
|
|
165
|
+
children: "Cancelar"
|
|
166
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
167
|
+
type: "button",
|
|
168
|
+
className: "primary",
|
|
169
|
+
onClick: submit,
|
|
170
|
+
disabled: loading,
|
|
171
|
+
children: loading ? "Desvinculando…" : "Desvincular"
|
|
172
|
+
})]
|
|
173
|
+
})]
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
exports.UnlinkVariantModal = UnlinkVariantModal;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Panel = exports.Overlay = exports.Message = exports.Header = exports.Footer = exports.Body = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _variables = require("../../../global-files/variables");
|
|
15
|
+
|
|
16
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
17
|
+
|
|
18
|
+
var PINK = "#E13AA8";
|
|
19
|
+
|
|
20
|
+
var Overlay = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(40, 31, 51, 0.4);\n"])));
|
|
21
|
+
|
|
22
|
+
exports.Overlay = Overlay;
|
|
23
|
+
|
|
24
|
+
var Panel = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n width: min(460px, 92vw);\n border-radius: 10px;\n background-color: ", ";\n font-family: ", ";\n overflow: hidden;\n"])), _variables.GlobalColors.white, _variables.FontFamily.Raleway);
|
|
25
|
+
|
|
26
|
+
exports.Panel = Panel;
|
|
27
|
+
|
|
28
|
+
var Header = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n padding: 18px 22px 10px;\n\n h2 {\n margin: 0;\n font-family: ", ";\n font-size: 16px;\n color: ", ";\n }\n\n p {\n margin: 6px 0 0;\n font-size: 13px;\n line-height: 1.4;\n color: ", ";\n }\n"])), _variables.FontFamily.Raleway_600, _variables.GlobalColors.deep_gray, _variables.GlobalColors.gray);
|
|
29
|
+
|
|
30
|
+
exports.Header = Header;
|
|
31
|
+
|
|
32
|
+
var Body = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n padding: 4px 22px 8px;\n\n ul {\n margin: 0;\n padding-left: 18px;\n }\n\n li {\n margin-bottom: 6px;\n font-size: 13px;\n line-height: 1.4;\n color: ", ";\n }\n\n /* Lo \xFAnico que no se puede deshacer solo va marcado: el resto son\n consecuencias, esta es una advertencia. */\n li.aviso {\n color: ", ";\n }\n"])), _variables.GlobalColors.deep_gray, PINK);
|
|
33
|
+
|
|
34
|
+
exports.Body = Body;
|
|
35
|
+
|
|
36
|
+
var Message = _styledComponents.default.p(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: 8px 22px 0;\n padding: 10px 12px;\n border-radius: 6px;\n background-color: rgba(225, 58, 168, 0.1);\n font-size: 13px;\n line-height: 1.4;\n color: ", ";\n"])), PINK);
|
|
37
|
+
|
|
38
|
+
exports.Message = Message;
|
|
39
|
+
|
|
40
|
+
var Footer = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n padding: 16px 22px 20px;\n\n button {\n height: 38px;\n padding: 0 16px;\n border-radius: 6px;\n cursor: pointer;\n font-family: ", ";\n font-size: 13px;\n }\n\n button:disabled {\n opacity: 0.5;\n cursor: default;\n }\n\n .secondary {\n border: 1px solid ", ";\n background: none;\n color: ", ";\n }\n\n .primary {\n border: 1px solid ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), _variables.FontFamily.Raleway_600, _variables.GlobalColors.s2, _variables.GlobalColors.deep_gray, PINK, PINK, _variables.GlobalColors.white);
|
|
41
|
+
|
|
42
|
+
exports.Footer = Footer;
|