您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

621 行
20 KiB

  1. (function() {
  2. var exports = {};
  3. exports.id = 2252;
  4. exports.ids = [2252];
  5. exports.modules = {
  6. /***/ 4777:
  7. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  8. "use strict";
  9. var _apollo = _interopRequireDefault(__webpack_require__(6371));
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. async function GetCartProduct(token = "") {
  12. var res = await _apollo.default.query(`
  13. query
  14. {
  15. carts
  16. {
  17. id
  18. product_otr
  19. product_name
  20. product_price
  21. product_color
  22. product_img{
  23. url
  24. }
  25. }
  26. }
  27. `, token);
  28. return res;
  29. }
  30. module.exports = {
  31. GetCartProduct: GetCartProduct
  32. };
  33. /***/ }),
  34. /***/ 1288:
  35. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  36. "use strict";
  37. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5282);
  38. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  39. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9297);
  40. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  41. const PageBanner = ({
  42. pageTitle
  43. }) => {
  44. return /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  45. className: "page-title-area",
  46. children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  47. className: "d-table",
  48. children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  49. className: "d-table-cell",
  50. children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  51. className: "container",
  52. children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
  53. children: pageTitle
  54. })
  55. })
  56. })
  57. })
  58. });
  59. };
  60. /* harmony default export */ __webpack_exports__["Z"] = (PageBanner);
  61. /***/ }),
  62. /***/ 1765:
  63. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  64. "use strict";
  65. // ESM COMPAT FLAG
  66. __webpack_require__.r(__webpack_exports__);
  67. // EXPORTS
  68. __webpack_require__.d(__webpack_exports__, {
  69. "default": function() { return /* binding */ Shop_Cart; },
  70. "getServerSideProps": function() { return /* binding */ getServerSideProps; }
  71. });
  72. // EXTERNAL MODULE: external "react/jsx-runtime"
  73. var jsx_runtime_ = __webpack_require__(5282);
  74. // EXTERNAL MODULE: external "react"
  75. var external_react_ = __webpack_require__(9297);
  76. var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
  77. // EXTERNAL MODULE: ./components/_App/NavbarYamaha.js
  78. var NavbarYamaha = __webpack_require__(2478);
  79. // EXTERNAL MODULE: ./components/_App/FooterYamaha.js
  80. var FooterYamaha = __webpack_require__(362);
  81. // EXTERNAL MODULE: ./components/Common/PageBanner.js
  82. var PageBanner = __webpack_require__(1288);
  83. // EXTERNAL MODULE: ./node_modules/next/link.js
  84. var next_link = __webpack_require__(1664);
  85. // EXTERNAL MODULE: external "react-feather"
  86. var external_react_feather_ = __webpack_require__(9337);
  87. // EXTERNAL MODULE: external "react-redux"
  88. var external_react_redux_ = __webpack_require__(79);
  89. // EXTERNAL MODULE: external "react-toast-notifications"
  90. var external_react_toast_notifications_ = __webpack_require__(9614);
  91. // EXTERNAL MODULE: external "next/router"
  92. var router_ = __webpack_require__(6731);
  93. ;// CONCATENATED MODULE: ./components/Yamaha/Shop/QtyForm.js
  94. const QtyForm = ({
  95. id,
  96. quantity
  97. }) => {
  98. const dispatch = (0,external_react_redux_.useDispatch)();
  99. const addQuantity = pId => {
  100. dispatch({
  101. type: 'ADD_QUANTITY',
  102. id: pId
  103. });
  104. };
  105. const subQuantity = pId => {
  106. dispatch({
  107. type: 'SUB_QUANTITY',
  108. id: pId
  109. });
  110. };
  111. return /*#__PURE__*/(0,jsx_runtime_.jsxs)("div", {
  112. className: "input-counter",
  113. children: [/*#__PURE__*/jsx_runtime_.jsx("span", {
  114. className: "minus-btn",
  115. onClick: e => {
  116. e.preventDefault();
  117. subQuantity(id);
  118. },
  119. children: /*#__PURE__*/jsx_runtime_.jsx(external_react_feather_.Minus, {})
  120. }), /*#__PURE__*/jsx_runtime_.jsx("input", {
  121. type: "text",
  122. min: "1" // value={quantity}
  123. ,
  124. value: "1",
  125. readOnly: true,
  126. onChange: e => e
  127. }), /*#__PURE__*/jsx_runtime_.jsx("span", {
  128. className: "plus-btn",
  129. onClick: e => {
  130. e.preventDefault();
  131. addQuantity(id);
  132. },
  133. children: /*#__PURE__*/jsx_runtime_.jsx(external_react_feather_.Plus, {})
  134. })]
  135. });
  136. };
  137. /* harmony default export */ var Shop_QtyForm = (QtyForm);
  138. // EXTERNAL MODULE: external "react-number-format"
  139. var external_react_number_format_ = __webpack_require__(3230);
  140. var external_react_number_format_default = /*#__PURE__*/__webpack_require__.n(external_react_number_format_);
  141. // EXTERNAL MODULE: external "sweetalert"
  142. var external_sweetalert_ = __webpack_require__(8080);
  143. var external_sweetalert_default = /*#__PURE__*/__webpack_require__.n(external_sweetalert_);
  144. ;// CONCATENATED MODULE: ./components/Yamaha/Shop/Cart.js
  145. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  146. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  147. 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; }
  148. function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  149. function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  150. //library yarn
  151. //sweet alert
  152. const CartContent = function (_ref) {
  153. let {
  154. backend,
  155. cart_product
  156. } = _ref,
  157. props = _objectWithoutProperties(_ref, ["backend", "cart_product"]);
  158. const router = (0,router_.useRouter)();
  159. const {
  160. addToast
  161. } = (0,external_react_toast_notifications_.useToasts)();
  162. const dispatch = (0,external_react_redux_.useDispatch)();
  163. const cart = (0,external_react_redux_.useSelector)(state => state.cart);
  164. const total = (0,external_react_redux_.useSelector)(state => state.total); // console.log(cart)
  165. const removeItem = () => {
  166. dispatch({
  167. type: 'REMOVE_ITEM',
  168. id: pId
  169. });
  170. addToast('Cart Removed Successfully', {
  171. appearance: 'error'
  172. });
  173. };
  174. const reset = () => {
  175. dispatch({
  176. type: 'RESET'
  177. });
  178. addToast('Thanks for your order.', {
  179. appearance: 'success'
  180. });
  181. router.push('/');
  182. };
  183. const [formValue, setFormValue] = external_react_default().useState({
  184. transaction_id: GenerateID(),
  185. product_img: "",
  186. product_name: "",
  187. product_color: "",
  188. product_quantity: 1,
  189. product_price: ""
  190. });
  191. function GenerateID() {
  192. var dt = new Date().getTime();
  193. var uuid = 'Trx-Ord-yyyyyyyy'.replace(/[y]/g, function (c) {
  194. var r = (dt + Math.random() * 16) % 16 | 0;
  195. dt = Math.floor(dt / 16);
  196. return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);
  197. });
  198. return uuid;
  199. }
  200. return /*#__PURE__*/(0,jsx_runtime_.jsxs)("form", {
  201. onSubmit: async e => {
  202. e.preventDefault();
  203. var newformValue = _objectSpread(_objectSpread({}, formValue), {}, {
  204. product_name: cart_product[0].product_name,
  205. product_color: cart_product[0].product_color,
  206. product_price: cart_product[0].product_price
  207. });
  208. setFormValue(newformValue);
  209. console.log(JSON.stringify(newformValue));
  210. const response = await fetch("/api/transaction/AddToCheckout", {
  211. method: "POST",
  212. headers: {
  213. 'Content-Type': 'application/json'
  214. },
  215. body: JSON.stringify(newformValue)
  216. });
  217. if (response.ok) {
  218. var res = await response.json();
  219. console.log("cek response :", res);
  220. if (res["STATUS"] === 1) {
  221. res["DATA"]["checkout"];
  222. external_sweetalert_default()("Produk Berhasil Ditambah ke Keranjang", "Silahkan Cek Keranjang Belanja Anda", "success");
  223. router.push("/yamaha/Shop/Checkout");
  224. } else {
  225. external_sweetalert_default()("Produk Gagal di Checkout", "Silahkan Coba Lagi", "error");
  226. }
  227. } else {
  228. external_sweetalert_default()("Transaksi Gagal", "Silahkan Coba Lagi", "error");
  229. }
  230. return false;
  231. },
  232. children: [/*#__PURE__*/jsx_runtime_.jsx("div", {
  233. className: "cart-table table-responsive",
  234. children: /*#__PURE__*/(0,jsx_runtime_.jsxs)("table", {
  235. className: "table table-bordered",
  236. children: [/*#__PURE__*/jsx_runtime_.jsx("thead", {
  237. children: /*#__PURE__*/(0,jsx_runtime_.jsxs)("tr", {
  238. children: [/*#__PURE__*/jsx_runtime_.jsx("th", {
  239. scope: "col",
  240. children: "Product"
  241. }), /*#__PURE__*/jsx_runtime_.jsx("th", {
  242. scope: "col",
  243. children: "Nama Product"
  244. }), /*#__PURE__*/jsx_runtime_.jsx("th", {
  245. scope: "col",
  246. children: "Warna Product"
  247. }), /*#__PURE__*/jsx_runtime_.jsx("th", {
  248. scope: "col",
  249. children: "Harga Product"
  250. }), /*#__PURE__*/jsx_runtime_.jsx("th", {
  251. scope: "col",
  252. children: "Jumlah"
  253. }), /*#__PURE__*/jsx_runtime_.jsx("th", {
  254. scope: "col",
  255. children: "Total"
  256. })]
  257. })
  258. }), /*#__PURE__*/jsx_runtime_.jsx("tbody", {
  259. children: cart_product.length ? cart_product.map(data => /*#__PURE__*/(0,jsx_runtime_.jsxs)("tr", {
  260. children: [/*#__PURE__*/jsx_runtime_.jsx("td", {
  261. className: "product-thumbnail",
  262. children: /*#__PURE__*/jsx_runtime_.jsx(next_link.default, {
  263. href: "/product-details",
  264. children: /*#__PURE__*/jsx_runtime_.jsx("a", {})
  265. })
  266. }), /*#__PURE__*/jsx_runtime_.jsx("td", {
  267. className: "product-name",
  268. children: /*#__PURE__*/jsx_runtime_.jsx(next_link.default, {
  269. href: "/product-details",
  270. children: /*#__PURE__*/jsx_runtime_.jsx("a", {
  271. children: data.product_name
  272. })
  273. })
  274. }), /*#__PURE__*/jsx_runtime_.jsx("td", {
  275. className: "product-name",
  276. children: /*#__PURE__*/jsx_runtime_.jsx(next_link.default, {
  277. href: "/product-details",
  278. children: /*#__PURE__*/jsx_runtime_.jsx("a", {
  279. children: data.product_color
  280. })
  281. })
  282. }), /*#__PURE__*/jsx_runtime_.jsx("td", {
  283. className: "product-price",
  284. children: /*#__PURE__*/jsx_runtime_.jsx("span", {
  285. className: "unit-amount",
  286. children: /*#__PURE__*/jsx_runtime_.jsx((external_react_number_format_default()), {
  287. value: data.product_price,
  288. displayType: 'text',
  289. thousandSeparator: true,
  290. prefix: 'Rp.'
  291. })
  292. })
  293. }), /*#__PURE__*/jsx_runtime_.jsx("td", {
  294. className: "product-quantity",
  295. children: /*#__PURE__*/jsx_runtime_.jsx(Shop_QtyForm, _objectSpread({}, data))
  296. }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("td", {
  297. className: "product-subtotal",
  298. children: [/*#__PURE__*/jsx_runtime_.jsx("span", {
  299. className: "subtotal-amount",
  300. children: /*#__PURE__*/jsx_runtime_.jsx((external_react_number_format_default()), {
  301. value: (2 * data.product_price).toFixed(2),
  302. displayType: 'text',
  303. thousandSeparator: true,
  304. prefix: 'Rp.' // name="product_price"
  305. // onInput={(e) => {
  306. // setFormValue({
  307. // ...formValue,
  308. // product_price: e.target.value(),
  309. // })
  310. // }}
  311. })
  312. }), /*#__PURE__*/jsx_runtime_.jsx("a", {
  313. href: "#",
  314. className: "remove",
  315. onClick: () => {
  316. removeItem(data.id);
  317. },
  318. children: /*#__PURE__*/jsx_runtime_.jsx(external_react_feather_.Trash2, {})
  319. })]
  320. })]
  321. }, data.id)) : /*#__PURE__*/jsx_runtime_.jsx("tr", {
  322. children: /*#__PURE__*/jsx_runtime_.jsx("td", {
  323. colSpan: "5",
  324. className: "text-center",
  325. children: "Tidak Ada Product di Keranjang"
  326. })
  327. })
  328. })]
  329. })
  330. }), /*#__PURE__*/jsx_runtime_.jsx("div", {
  331. className: "cart-buttons",
  332. children: /*#__PURE__*/jsx_runtime_.jsx("div", {
  333. className: "row align-items-center",
  334. children: /*#__PURE__*/jsx_runtime_.jsx("div", {
  335. className: "col-lg-7 col-md-7 col-sm-7",
  336. children: /*#__PURE__*/jsx_runtime_.jsx("div", {
  337. className: "continue-shopping-box",
  338. children: /*#__PURE__*/jsx_runtime_.jsx("a", {
  339. href: "/yamaha/Product/Motor",
  340. className: "btn btn-light",
  341. style: {
  342. color: 'white'
  343. },
  344. children: "Continue Shopping"
  345. })
  346. })
  347. })
  348. })
  349. }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("div", {
  350. className: "cart-totals",
  351. children: [/*#__PURE__*/jsx_runtime_.jsx("h3", {
  352. children: "Cart Totals"
  353. }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("ul", {
  354. children: [/*#__PURE__*/(0,jsx_runtime_.jsxs)("li", {
  355. children: ["Subtotal ", /*#__PURE__*/(0,jsx_runtime_.jsxs)("span", {
  356. children: ["$", total.toFixed(2)]
  357. })]
  358. }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("li", {
  359. children: ["Total ", /*#__PURE__*/jsx_runtime_.jsx("span", {
  360. children: /*#__PURE__*/(0,jsx_runtime_.jsxs)("b", {
  361. children: ["$", (total + 10).toFixed(2)]
  362. })
  363. })]
  364. })]
  365. }), /*#__PURE__*/jsx_runtime_.jsx("button", {
  366. type: "submit",
  367. className: "btn btn-primary",
  368. children: "Proceed to Checkout"
  369. })]
  370. })]
  371. });
  372. };
  373. /* harmony default export */ var Cart = (CartContent);
  374. // EXTERNAL MODULE: ./api/shop/cart.js
  375. var cart = __webpack_require__(4777);
  376. var cart_default = /*#__PURE__*/__webpack_require__.n(cart);
  377. // EXTERNAL MODULE: external "cookies"
  378. var external_cookies_ = __webpack_require__(9038);
  379. ;// CONCATENATED MODULE: ./pages/yamaha/Shop/Cart.js
  380. function Cart_objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = Cart_objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  381. function Cart_objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  382. const Cart_Cart = function (_ref) {
  383. let {
  384. cart_product,
  385. backend
  386. } = _ref,
  387. props = Cart_objectWithoutProperties(_ref, ["cart_product", "backend"]);
  388. return /*#__PURE__*/(0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
  389. children: [/*#__PURE__*/jsx_runtime_.jsx(NavbarYamaha/* default */.Z, {}), /*#__PURE__*/jsx_runtime_.jsx(PageBanner/* default */.Z, {
  390. pageTitle: "Cart"
  391. }), /*#__PURE__*/jsx_runtime_.jsx("div", {
  392. className: "cart-area ptb-80",
  393. children: /*#__PURE__*/jsx_runtime_.jsx("div", {
  394. className: "container",
  395. children: /*#__PURE__*/jsx_runtime_.jsx("div", {
  396. className: "row",
  397. children: /*#__PURE__*/jsx_runtime_.jsx("div", {
  398. className: "col-lg-12 col-md-12",
  399. children: /*#__PURE__*/jsx_runtime_.jsx(Cart, {
  400. cart_product: cart_product,
  401. backend: backend
  402. })
  403. })
  404. })
  405. })
  406. }), /*#__PURE__*/jsx_runtime_.jsx(FooterYamaha/* default */.Z, {})]
  407. });
  408. };
  409. /* harmony default export */ var Shop_Cart = (Cart_Cart);
  410. async function getServerSideProps() {
  411. var cart_product = [];
  412. const backend = process.env.BACKEND_SERVER_URI;
  413. var res = await cart_default().GetCartProduct();
  414. if (res["STATUS"] === 1) {
  415. cart_product = res["DATA"]["carts"];
  416. }
  417. console.log(cart_product);
  418. return {
  419. props: {
  420. cart_product,
  421. backend
  422. } // will be passed to the page component as props
  423. };
  424. }
  425. /***/ }),
  426. /***/ 8074:
  427. /***/ (function(module) {
  428. "use strict";
  429. module.exports = require("@apollo/client");;
  430. /***/ }),
  431. /***/ 9038:
  432. /***/ (function(module) {
  433. "use strict";
  434. module.exports = require("cookies");;
  435. /***/ }),
  436. /***/ 1683:
  437. /***/ (function(module) {
  438. "use strict";
  439. module.exports = require("cross-fetch");;
  440. /***/ }),
  441. /***/ 8417:
  442. /***/ (function(module) {
  443. "use strict";
  444. module.exports = require("next/dist/next-server/lib/router-context.js");;
  445. /***/ }),
  446. /***/ 2238:
  447. /***/ (function(module) {
  448. "use strict";
  449. module.exports = require("next/dist/next-server/lib/router/utils/get-asset-path-from-route.js");;
  450. /***/ }),
  451. /***/ 6731:
  452. /***/ (function(module) {
  453. "use strict";
  454. module.exports = require("next/router");;
  455. /***/ }),
  456. /***/ 9297:
  457. /***/ (function(module) {
  458. "use strict";
  459. module.exports = require("react");;
  460. /***/ }),
  461. /***/ 9337:
  462. /***/ (function(module) {
  463. "use strict";
  464. module.exports = require("react-feather");;
  465. /***/ }),
  466. /***/ 3230:
  467. /***/ (function(module) {
  468. "use strict";
  469. module.exports = require("react-number-format");;
  470. /***/ }),
  471. /***/ 79:
  472. /***/ (function(module) {
  473. "use strict";
  474. module.exports = require("react-redux");;
  475. /***/ }),
  476. /***/ 9614:
  477. /***/ (function(module) {
  478. "use strict";
  479. module.exports = require("react-toast-notifications");;
  480. /***/ }),
  481. /***/ 5282:
  482. /***/ (function(module) {
  483. "use strict";
  484. module.exports = require("react/jsx-runtime");;
  485. /***/ }),
  486. /***/ 8080:
  487. /***/ (function(module) {
  488. "use strict";
  489. module.exports = require("sweetalert");;
  490. /***/ })
  491. };
  492. ;
  493. // load runtime
  494. var __webpack_require__ = require("../../../webpack-runtime.js");
  495. __webpack_require__.C(exports);
  496. var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  497. var __webpack_exports__ = __webpack_require__.X(0, [1664,4755,6371,7798], function() { return __webpack_exec__(1765); });
  498. module.exports = __webpack_exports__;
  499. })();