vademecum.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. 'use strict';
  2. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  12. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  13. var dom = React.createElement;
  14. var CONFIG = {
  15. "prof-a": {
  16. title: "Vademecum Profesional",
  17. contactInformation: true,
  18. productFilter: function productFilter(products) {
  19. return products;
  20. },
  21. prices: false,
  22. categories: [["Higiene", "higiene"], ["Máscaras", "mascaras"], ["Ácido Hialurónico", "acido-hialuronico"], ["Peeling", "peeling"], ["Corporales", "corporales"], ["Hombres", "hombres"], ["Protección Intensiva", "proteccion-intensiva"], ["Monodosis", "monodosis"], ["Activos Concentrados", "activos-concentrados"], ["Protección Solar", "proteccion-solar"]]
  23. },
  24. "prof-b": {
  25. title: "Vademecum Profesional",
  26. contactInformation: false,
  27. productFilter: function productFilter(products) {
  28. return products;
  29. },
  30. prices: false,
  31. categories: [["Higiene", "higiene"], ["Máscaras", "mascaras"], ["Ácido Hialurónico", "acido-hialuronico"], ["Peeling", "peeling"], ["Corporales", "corporales"], ["Hombres", "hombres"], ["Protección Intensiva", "proteccion-intensiva"], ["Monodosis", "monodosis"], ["Activos Concentrados", "activos-concentrados"], ["Protección Solar", "proteccion-solar"]]
  32. },
  33. "dom-a": {
  34. title: "Vademecum Apoyo Domiciliario",
  35. contactInformation: false,
  36. productFilter: function productFilter(products) {
  37. return Object.keys(products).reduce(function (acc, x) {
  38. var filtered = products[x].filter(function (p) {
  39. var v = p.variants.filter(function (v) {
  40. return v.code < 2000;
  41. });
  42. return v.length || p.category.includes('Protección Solar');
  43. });
  44. return _objectSpread({}, acc, _defineProperty({}, x, filtered));
  45. }, {});
  46. },
  47. prices: true,
  48. categories: [["Higiene", "higiene"], ["Ácido Hialurónico", "acido-hialuronico"], ["Corporales", "corporales"], ["Hombres", "hombres"], ["Protección Intensiva", "proteccion-intensiva"], ["Monodosis", "monodosis"], ["Protección Solar", "proteccion-solar"]]
  49. },
  50. "dom-b": {
  51. title: "Vademecum Apoyo Domiciliario",
  52. contactInformation: false,
  53. productFilter: function productFilter(products) {
  54. return products;
  55. },
  56. prices: false,
  57. categories: [["Higiene", "higiene"], ["Ácido Hialurónico", "acido-hialuronico"], ["Corporales", "corporales"], ["Hombres", "hombres"], ["Protección Intensiva", "proteccion-intensiva"], ["Monodosis", "monodosis"], ["Protección Solar", "proteccion-solar"]]
  58. }
  59. };
  60. var Tag = function Tag(label, key, className) {
  61. return dom("div", {
  62. className: "chip ".concat(className || ''),
  63. key: key
  64. }, label);
  65. };
  66. var Section = function Section(title, paragraph, prepend) {
  67. return dom("div", {
  68. className: "section-container"
  69. }, dom("h4", {
  70. className: "section-name"
  71. }, title), dom("p", {
  72. className: "section-body",
  73. lang: "es"
  74. }, prepend, paragraph));
  75. };
  76. var Product = function Product(product, key, prices) {
  77. return dom("div", {
  78. className: "product-container"
  79. }, dom("div", {
  80. className: "row valign-wrapper"
  81. }, dom("div", {
  82. class: "col s2"
  83. }, prices ? dom("img", {
  84. src: "images/_img/".concat(product.variants[0].img || product.img, ".png"),
  85. className: "responsive-img"
  86. }) : dom("img", {
  87. src: "images/_img/".concat(product.img || product.variants[0].img, ".png"),
  88. className: "responsive-img"
  89. })), dom("div", {
  90. class: "col s10"
  91. }, dom("h4", {
  92. className: "primary-title"
  93. }, product.name), dom("div", {
  94. className: "product-body"
  95. }, dom("p", {
  96. className: "product-short-desc",
  97. lang: "es"
  98. }, product.shortDesc), prices && dom("div", {
  99. className: "product-price"
  100. }, dom("div", {
  101. className: "price-tag"
  102. }, dom("h5", null, dom("span", {
  103. className: "price-symbol"
  104. }, "$"), dom("span", {
  105. className: "price-total"
  106. }, product.variants[0].sellPrice), dom("sup", {
  107. className: "price-decimal"
  108. }, "00"))), dom("div", {
  109. className: "product-size"
  110. }, "Cont. ", product.variants[0].content))))), dom("div", null, product.fullDesc && Section('Descripción', product.fullDesc), product.application && Section('Aplicación', product.application), product.actives && Section('', product.actives.map(function (p) {
  111. return Tag(p);
  112. }), product.ph && Tag("PH ".concat(product.ph), null, 'is-ph'))));
  113. };
  114. var Category = function Category(category, products, prices) {
  115. return dom("section", {
  116. id: category[TAG],
  117. className: "container ".concat(prices ? 'dom' : 'prof')
  118. }, dom("h2", {
  119. className: "category-name"
  120. }, category[LABEL]), dom("div", {
  121. className: "collection"
  122. }, products.map(function (p, i) {
  123. return dom("div", {
  124. className: "collection-item"
  125. }, Product(p, i, prices));
  126. })));
  127. };
  128. var ToC = function ToC(categories, products) {
  129. return dom("section", {
  130. id: "eba-toc",
  131. className: "container"
  132. }, dom("h2", {
  133. className: "pagebreak"
  134. }, "Indice"), dom("div", {
  135. className: ""
  136. }, categories.map(function (category, i) {
  137. return dom("div", null, dom("div", null, dom("a", {
  138. href: "#".concat(category[TAG])
  139. }, dom("h5", null, category[LABEL], " ", dom("i", {
  140. className: "material-icons"
  141. }, "chevron_right")))), dom("div", null, products[category[LABEL]].map(function (product) {
  142. return Tag(product.name, null, 'toc-tag');
  143. })));
  144. })));
  145. };
  146. var Vademecum = function Vademecum(categories, products, prices) {
  147. console.log("prices?", prices);
  148. return categories.map(function (categoryName, i) {
  149. return dom("div", {
  150. key: i
  151. }, Category(categoryName, products[categoryName[LABEL]], prices));
  152. });
  153. };
  154. var ContactInformation = function ContactInformation() {
  155. return dom("section", {
  156. id: "contact-information"
  157. }, dom("div", {
  158. className: "container"
  159. }, dom("h2", {
  160. class: "pagebreak"
  161. }, "Contacto"), dom("div", {
  162. class: "collection"
  163. }, dom("div", {
  164. class: "collection-item"
  165. }, dom("h4", {
  166. className: "primary-title"
  167. }, "Argentina"), dom("div", {
  168. class: "section-container"
  169. }, dom("h4", {
  170. class: "section-name"
  171. }, "Direcci\xF3n"), dom("p", {
  172. class: "section-body"
  173. }, "Leopoldo Marechal 914, Ciudad Aut\xF3noma de Buenos Aires")), dom("div", {
  174. class: "section-container"
  175. }, dom("h4", {
  176. class: "section-name"
  177. }, "Telefono"), dom("p", {
  178. class: "section-body"
  179. }, "(+5411) 4139-6860/1")), dom("div", {
  180. class: "section-container"
  181. }, dom("h4", {
  182. class: "section-name"
  183. }, "Email"), dom("p", {
  184. class: "section-body"
  185. }, "consultas@especificosba.com.ar"))), dom("div", {
  186. className: "collection-item"
  187. }, dom("h4", {
  188. className: "primary-title"
  189. }, "M\xE9xico"), dom("div", {
  190. class: "section-container"
  191. }, dom("h4", {
  192. class: "section-name"
  193. }, "Tel\xE9fono"), dom("p", {
  194. class: "section-body"
  195. }, "(+5255)4170-8856")), dom("div", {
  196. class: "section-container"
  197. }, dom("h4", {
  198. class: "section-name"
  199. }, "Email"), dom("p", {
  200. class: "section-body"
  201. }, "contactos@skin-connect.com.mx"))), dom("div", {
  202. className: "collection-item"
  203. }, dom("h4", {
  204. className: "primary-title"
  205. }, "Ecuador"), dom("div", {
  206. class: "section-container"
  207. }, dom("h4", {
  208. class: "section-name"
  209. }, "Direcci\xF3n"), dom("p", {
  210. class: "section-body"
  211. }, "Av. Felipe II s/n, Via Mall del R\xEDo")), dom("div", {
  212. class: "section-container"
  213. }, dom("h4", {
  214. class: "section-name"
  215. }, "Tel\xE9fono"), dom("p", {
  216. class: "section-body"
  217. }, "(+593)07245-5143 (+593)07288-6258")), dom("div", {
  218. class: "section-container"
  219. }, dom("h4", {
  220. class: "section-name"
  221. }, "Email"), dom("p", {
  222. class: "section-body"
  223. }, "kasanacorp@hotmail.com"))))));
  224. };
  225. var domContainer = document.querySelector('#vademecum');
  226. var LABEL = 0,
  227. TAG = 1;
  228. var VademecumData =
  229. /*#__PURE__*/
  230. function (_React$Component) {
  231. _inherits(VademecumData, _React$Component);
  232. function VademecumData(props) {
  233. var _this;
  234. _classCallCheck(this, VademecumData);
  235. _this = _possibleConstructorReturn(this, _getPrototypeOf(VademecumData).call(this, props));
  236. var config = CONFIG["dom-a"];
  237. _this.state = {
  238. config: config,
  239. categories: config.categories,
  240. products: null
  241. };
  242. console.log(config);
  243. return _this;
  244. }
  245. _createClass(VademecumData, [{
  246. key: "componentDidMount",
  247. value: function componentDidMount() {
  248. var _this2 = this;
  249. fetch('data/products-by-category.json').then(function (response) {
  250. return response.json();
  251. }).then(this.state.config.productFilter).then(function (data) {
  252. console.log("data", data);
  253. _this2.setState({
  254. products: data
  255. });
  256. });
  257. }
  258. }, {
  259. key: "render",
  260. value: function render() {
  261. var _this$state = this.state,
  262. categories = _this$state.categories,
  263. products = _this$state.products,
  264. config = _this$state.config;
  265. if (products) {
  266. return dom("div", null, ToC(categories, products), Vademecum(categories, products, config.prices), config.contactInformation && ContactInformation());
  267. } else {
  268. return dom("div", null);
  269. }
  270. }
  271. }]);
  272. return VademecumData;
  273. }(React.Component);
  274. ReactDOM.render(dom(VademecumData), domContainer);