vademecum.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 _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; }
  12. var dom = React.createElement;
  13. var CONFIG = _defineProperty({
  14. "prof-a": {
  15. contactInformation: true,
  16. productFilter: function productFilter(products) {
  17. return products;
  18. },
  19. prices: false,
  20. 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"]]
  21. },
  22. "prof-b": {
  23. contactInformation: false,
  24. productFilter: function productFilter(products) {
  25. return products;
  26. },
  27. prices: false,
  28. 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"]]
  29. },
  30. "dom-a": {
  31. contactInformation: false,
  32. productFilter: function productFilter(products) {
  33. return products;
  34. },
  35. prices: true
  36. }
  37. }, "dom-a", {
  38. contactInformation: false,
  39. productFilter: function productFilter(products) {
  40. return products;
  41. },
  42. prices: false
  43. });
  44. var Tag = function Tag(label, key, className) {
  45. return dom("div", {
  46. className: "chip ".concat(className || ''),
  47. key: key
  48. }, label);
  49. };
  50. var Section = function Section(title, paragraph, prepend) {
  51. return dom("div", {
  52. className: "section-container"
  53. }, dom("h4", {
  54. className: "section-name"
  55. }, title), dom("p", {
  56. className: "section-body",
  57. lang: "es"
  58. }, prepend, paragraph));
  59. };
  60. var Product = function Product(product, key) {
  61. return dom("div", {
  62. className: "product-container"
  63. }, dom("div", {
  64. className: "row valign-wrapper"
  65. }, dom("div", {
  66. class: "col s2"
  67. }, dom("img", {
  68. src: "images/_img/".concat(product.img || product.variants[0].img, ".png"),
  69. className: "responsive-img"
  70. })), dom("div", {
  71. class: "col s10"
  72. }, dom("h4", {
  73. className: "primary-title"
  74. }, product.name), dom("div", {
  75. className: "product-body"
  76. }, dom("p", {
  77. className: "product-short-desc",
  78. lang: "es"
  79. }, product.shortDesc)))), dom("div", null, Section('Descripción', product.fullDesc), product.application && Section('Aplicación', product.application), product.actives && Section('', product.actives.map(function (p) {
  80. return Tag(p);
  81. }), product.ph && Tag("PH ".concat(product.ph), null, 'is-ph'))));
  82. };
  83. var Category = function Category(category, products, prices) {
  84. return dom("section", {
  85. id: category[TAG],
  86. className: "container"
  87. }, dom("h2", {
  88. className: "category-name"
  89. }, category[LABEL]), dom("div", {
  90. className: "collection"
  91. }, products.map(function (p, i) {
  92. return dom("div", {
  93. className: "collection-item"
  94. }, Product(p, i));
  95. })));
  96. };
  97. var ToC = function ToC(categories, products) {
  98. return dom("section", {
  99. id: "eba-toc",
  100. className: "container"
  101. }, dom("h2", {
  102. className: "pagebreak"
  103. }, "Indice"), dom("div", {
  104. className: ""
  105. }, categories.map(function (category, i) {
  106. return dom("div", null, dom("div", null, dom("a", {
  107. href: "#".concat(category[TAG])
  108. }, dom("h5", null, category[LABEL], " ", dom("i", {
  109. className: "material-icons"
  110. }, "chevron_right")))), dom("div", null, products[category[LABEL]].map(function (product) {
  111. return Tag(product.name, null, 'toc-tag');
  112. })));
  113. })));
  114. };
  115. var Vademecum = function Vademecum(categories, products, prices) {
  116. return categories.map(function (categoryName, i) {
  117. return dom("div", {
  118. key: i
  119. }, Category(categoryName, products[categoryName[LABEL]], prices));
  120. });
  121. };
  122. var ContactInformation = function ContactInformation() {
  123. return dom("section", {
  124. id: "contact-information"
  125. }, dom("div", {
  126. className: "container"
  127. }, dom("h2", {
  128. class: "pagebreak"
  129. }, "Contacto"), dom("div", {
  130. class: "collection"
  131. }, dom("div", {
  132. class: "collection-item"
  133. }, dom("h4", {
  134. className: "primary-title"
  135. }, "Argentina"), dom("div", {
  136. class: "section-container"
  137. }, dom("h4", {
  138. class: "section-name"
  139. }, "Direcci\xF3n"), dom("p", {
  140. class: "section-body"
  141. }, "Leopoldo Marechal 914, Ciudad Aut\xF3noma de Buenos Aires")), dom("div", {
  142. class: "section-container"
  143. }, dom("h4", {
  144. class: "section-name"
  145. }, "Telefono"), dom("p", {
  146. class: "section-body"
  147. }, "(+5411) 4139-6860/1")), dom("div", {
  148. class: "section-container"
  149. }, dom("h4", {
  150. class: "section-name"
  151. }, "Email"), dom("p", {
  152. class: "section-body"
  153. }, "consultas@especificosba.com.ar"))), dom("div", {
  154. className: "collection-item"
  155. }, dom("h4", {
  156. className: "primary-title"
  157. }, "M\xE9xico"), dom("div", {
  158. class: "section-container"
  159. }, dom("h4", {
  160. class: "section-name"
  161. }, "Tel\xE9fono"), dom("p", {
  162. class: "section-body"
  163. }, "(+5255)4170-8856")), dom("div", {
  164. class: "section-container"
  165. }, dom("h4", {
  166. class: "section-name"
  167. }, "Email"), dom("p", {
  168. class: "section-body"
  169. }, "contactos@skin-connect.com.mx"))), dom("div", {
  170. className: "collection-item"
  171. }, dom("h4", {
  172. className: "primary-title"
  173. }, "Ecuador"), dom("div", {
  174. class: "section-container"
  175. }, dom("h4", {
  176. class: "section-name"
  177. }, "Direcci\xF3n"), dom("p", {
  178. class: "section-body"
  179. }, "Luis Cordero 1254, Cuenca, Azuay")), dom("div", {
  180. class: "section-container"
  181. }, dom("h4", {
  182. class: "section-name"
  183. }, "Tel\xE9fono"), dom("p", {
  184. class: "section-body"
  185. }, "(+593)07283-5550 (+593)07284-1207")), dom("div", {
  186. class: "section-container"
  187. }, dom("h4", {
  188. class: "section-name"
  189. }, "Email"), dom("p", {
  190. class: "section-body"
  191. }, "casamonickaventas@yahoo.com"))))));
  192. };
  193. var domContainer = document.querySelector('#vademecum');
  194. var LABEL = 0,
  195. TAG = 1;
  196. var VademecumData =
  197. /*#__PURE__*/
  198. function (_React$Component) {
  199. _inherits(VademecumData, _React$Component);
  200. function VademecumData(props) {
  201. var _this;
  202. _classCallCheck(this, VademecumData);
  203. _this = _possibleConstructorReturn(this, _getPrototypeOf(VademecumData).call(this, props));
  204. var config = CONFIG["prof-a"];
  205. _this.state = {
  206. config: config,
  207. categories: config.categories,
  208. products: null
  209. };
  210. console.log(config);
  211. return _this;
  212. }
  213. _createClass(VademecumData, [{
  214. key: "componentDidMount",
  215. value: function componentDidMount() {
  216. var _this2 = this;
  217. fetch('data/products-by-category.json').then(function (response) {
  218. return response.json();
  219. }).then(this.state.config.productFilter).then(function (data) {
  220. _this2.setState({
  221. products: data
  222. });
  223. });
  224. }
  225. }, {
  226. key: "render",
  227. value: function render() {
  228. var _this$state = this.state,
  229. categories = _this$state.categories,
  230. products = _this$state.products,
  231. config = _this$state.config;
  232. console.log(config.contactInformation);
  233. if (products) {
  234. return dom("div", null, ToC(categories, products), Vademecum(categories, products, config.prices), config.contactInformation && ContactInformation());
  235. } else {
  236. return dom("div", null);
  237. }
  238. }
  239. }]);
  240. return VademecumData;
  241. }(React.Component);
  242. ReactDOM.render(dom(VademecumData), domContainer);