vademecum.js 12 KB

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