|
- (function() {
- var exports = {};
- exports.id = 2252;
- exports.ids = [2252];
- exports.modules = {
-
- /***/ 4777:
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
- "use strict";
-
-
- var _apollo = _interopRequireDefault(__webpack_require__(6371));
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- async function GetCartProduct(token = "") {
- var res = await _apollo.default.query(`
- query
- {
- carts
- {
- id
- product_otr
- product_name
- product_price
- product_color
- product_img{
- url
- }
- }
- }
- `, token);
- return res;
- }
-
- module.exports = {
- GetCartProduct: GetCartProduct
- };
-
- /***/ }),
-
- /***/ 1288:
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5282);
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9297);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
-
-
-
- const PageBanner = ({
- pageTitle
- }) => {
- return /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
- className: "page-title-area",
- children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
- className: "d-table",
- children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
- className: "d-table-cell",
- children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
- className: "container",
- children: /*#__PURE__*/react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
- children: pageTitle
- })
- })
- })
- })
- });
- };
-
- /* harmony default export */ __webpack_exports__["Z"] = (PageBanner);
-
- /***/ }),
-
- /***/ 1765:
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- // ESM COMPAT FLAG
- __webpack_require__.r(__webpack_exports__);
-
- // EXPORTS
- __webpack_require__.d(__webpack_exports__, {
- "default": function() { return /* binding */ Shop_Cart; },
- "getServerSideProps": function() { return /* binding */ getServerSideProps; }
- });
-
- // EXTERNAL MODULE: external "react/jsx-runtime"
- var jsx_runtime_ = __webpack_require__(5282);
- // EXTERNAL MODULE: external "react"
- var external_react_ = __webpack_require__(9297);
- var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
- // EXTERNAL MODULE: ./components/_App/NavbarYamaha.js
- var NavbarYamaha = __webpack_require__(2478);
- // EXTERNAL MODULE: ./components/_App/FooterYamaha.js
- var FooterYamaha = __webpack_require__(362);
- // EXTERNAL MODULE: ./components/Common/PageBanner.js
- var PageBanner = __webpack_require__(1288);
- // EXTERNAL MODULE: ./node_modules/next/link.js
- var next_link = __webpack_require__(1664);
- // EXTERNAL MODULE: external "react-feather"
- var external_react_feather_ = __webpack_require__(9337);
- // EXTERNAL MODULE: external "react-redux"
- var external_react_redux_ = __webpack_require__(79);
- // EXTERNAL MODULE: external "react-toast-notifications"
- var external_react_toast_notifications_ = __webpack_require__(9614);
- // EXTERNAL MODULE: external "next/router"
- var router_ = __webpack_require__(6731);
- ;// CONCATENATED MODULE: ./components/Yamaha/Shop/QtyForm.js
-
-
-
-
-
-
- const QtyForm = ({
- id,
- quantity
- }) => {
- const dispatch = (0,external_react_redux_.useDispatch)();
-
- const addQuantity = pId => {
- dispatch({
- type: 'ADD_QUANTITY',
- id: pId
- });
- };
-
- const subQuantity = pId => {
- dispatch({
- type: 'SUB_QUANTITY',
- id: pId
- });
- };
-
- return /*#__PURE__*/(0,jsx_runtime_.jsxs)("div", {
- className: "input-counter",
- children: [/*#__PURE__*/jsx_runtime_.jsx("span", {
- className: "minus-btn",
- onClick: e => {
- e.preventDefault();
- subQuantity(id);
- },
- children: /*#__PURE__*/jsx_runtime_.jsx(external_react_feather_.Minus, {})
- }), /*#__PURE__*/jsx_runtime_.jsx("input", {
- type: "text",
- min: "1" // value={quantity}
- ,
- value: "1",
- readOnly: true,
- onChange: e => e
- }), /*#__PURE__*/jsx_runtime_.jsx("span", {
- className: "plus-btn",
- onClick: e => {
- e.preventDefault();
- addQuantity(id);
- },
- children: /*#__PURE__*/jsx_runtime_.jsx(external_react_feather_.Plus, {})
- })]
- });
- };
-
- /* harmony default export */ var Shop_QtyForm = (QtyForm);
- // EXTERNAL MODULE: external "react-number-format"
- var external_react_number_format_ = __webpack_require__(3230);
- var external_react_number_format_default = /*#__PURE__*/__webpack_require__.n(external_react_number_format_);
- // EXTERNAL MODULE: external "sweetalert"
- var external_sweetalert_ = __webpack_require__(8080);
- var external_sweetalert_default = /*#__PURE__*/__webpack_require__.n(external_sweetalert_);
- ;// CONCATENATED MODULE: ./components/Yamaha/Shop/Cart.js
-
-
-
- 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; }
-
- 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; }
-
- 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; }
-
- 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; }
-
- 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; }
-
-
-
-
-
-
-
- //library yarn
-
- //sweet alert
-
-
-
- const CartContent = function (_ref) {
- let {
- backend,
- cart_product
- } = _ref,
- props = _objectWithoutProperties(_ref, ["backend", "cart_product"]);
-
- const router = (0,router_.useRouter)();
- const {
- addToast
- } = (0,external_react_toast_notifications_.useToasts)();
- const dispatch = (0,external_react_redux_.useDispatch)();
- const cart = (0,external_react_redux_.useSelector)(state => state.cart);
- const total = (0,external_react_redux_.useSelector)(state => state.total); // console.log(cart)
-
- const removeItem = () => {
- dispatch({
- type: 'REMOVE_ITEM',
- id: pId
- });
- addToast('Cart Removed Successfully', {
- appearance: 'error'
- });
- };
-
- const reset = () => {
- dispatch({
- type: 'RESET'
- });
- addToast('Thanks for your order.', {
- appearance: 'success'
- });
- router.push('/');
- };
-
- const [formValue, setFormValue] = external_react_default().useState({
- transaction_id: GenerateID(),
- product_img: "",
- product_name: "",
- product_color: "",
- product_quantity: 1,
- product_price: ""
- });
-
- function GenerateID() {
- var dt = new Date().getTime();
- var uuid = 'Trx-Ord-yyyyyyyy'.replace(/[y]/g, function (c) {
- var r = (dt + Math.random() * 16) % 16 | 0;
- dt = Math.floor(dt / 16);
- return (c == 'x' ? r : r & 0x3 | 0x8).toString(16);
- });
- return uuid;
- }
-
- return /*#__PURE__*/(0,jsx_runtime_.jsxs)("form", {
- onSubmit: async e => {
- e.preventDefault();
-
- var newformValue = _objectSpread(_objectSpread({}, formValue), {}, {
- product_name: cart_product[0].product_name,
- product_color: cart_product[0].product_color,
- product_price: cart_product[0].product_price
- });
-
- setFormValue(newformValue);
- console.log(JSON.stringify(newformValue));
- const response = await fetch("/api/transaction/AddToCheckout", {
- method: "POST",
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(newformValue)
- });
-
- if (response.ok) {
- var res = await response.json();
- console.log("cek response :", res);
-
- if (res["STATUS"] === 1) {
- res["DATA"]["checkout"];
- external_sweetalert_default()("Produk Berhasil Ditambah ke Keranjang", "Silahkan Cek Keranjang Belanja Anda", "success");
- router.push("/yamaha/Shop/Checkout");
- } else {
- external_sweetalert_default()("Produk Gagal di Checkout", "Silahkan Coba Lagi", "error");
- }
- } else {
- external_sweetalert_default()("Transaksi Gagal", "Silahkan Coba Lagi", "error");
- }
-
- return false;
- },
- children: [/*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "cart-table table-responsive",
- children: /*#__PURE__*/(0,jsx_runtime_.jsxs)("table", {
- className: "table table-bordered",
- children: [/*#__PURE__*/jsx_runtime_.jsx("thead", {
- children: /*#__PURE__*/(0,jsx_runtime_.jsxs)("tr", {
- children: [/*#__PURE__*/jsx_runtime_.jsx("th", {
- scope: "col",
- children: "Product"
- }), /*#__PURE__*/jsx_runtime_.jsx("th", {
- scope: "col",
- children: "Nama Product"
- }), /*#__PURE__*/jsx_runtime_.jsx("th", {
- scope: "col",
- children: "Warna Product"
- }), /*#__PURE__*/jsx_runtime_.jsx("th", {
- scope: "col",
- children: "Harga Product"
- }), /*#__PURE__*/jsx_runtime_.jsx("th", {
- scope: "col",
- children: "Jumlah"
- }), /*#__PURE__*/jsx_runtime_.jsx("th", {
- scope: "col",
- children: "Total"
- })]
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("tbody", {
- children: cart_product.length ? cart_product.map(data => /*#__PURE__*/(0,jsx_runtime_.jsxs)("tr", {
- children: [/*#__PURE__*/jsx_runtime_.jsx("td", {
- className: "product-thumbnail",
- children: /*#__PURE__*/jsx_runtime_.jsx(next_link.default, {
- href: "/product-details",
- children: /*#__PURE__*/jsx_runtime_.jsx("a", {})
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("td", {
- className: "product-name",
- children: /*#__PURE__*/jsx_runtime_.jsx(next_link.default, {
- href: "/product-details",
- children: /*#__PURE__*/jsx_runtime_.jsx("a", {
- children: data.product_name
- })
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("td", {
- className: "product-name",
- children: /*#__PURE__*/jsx_runtime_.jsx(next_link.default, {
- href: "/product-details",
- children: /*#__PURE__*/jsx_runtime_.jsx("a", {
- children: data.product_color
- })
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("td", {
- className: "product-price",
- children: /*#__PURE__*/jsx_runtime_.jsx("span", {
- className: "unit-amount",
- children: /*#__PURE__*/jsx_runtime_.jsx((external_react_number_format_default()), {
- value: data.product_price,
- displayType: 'text',
- thousandSeparator: true,
- prefix: 'Rp.'
- })
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("td", {
- className: "product-quantity",
- children: /*#__PURE__*/jsx_runtime_.jsx(Shop_QtyForm, _objectSpread({}, data))
- }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("td", {
- className: "product-subtotal",
- children: [/*#__PURE__*/jsx_runtime_.jsx("span", {
- className: "subtotal-amount",
- children: /*#__PURE__*/jsx_runtime_.jsx((external_react_number_format_default()), {
- value: (2 * data.product_price).toFixed(2),
- displayType: 'text',
- thousandSeparator: true,
- prefix: 'Rp.' // name="product_price"
- // onInput={(e) => {
- // setFormValue({
- // ...formValue,
- // product_price: e.target.value(),
- // })
- // }}
-
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("a", {
- href: "#",
- className: "remove",
- onClick: () => {
- removeItem(data.id);
- },
- children: /*#__PURE__*/jsx_runtime_.jsx(external_react_feather_.Trash2, {})
- })]
- })]
- }, data.id)) : /*#__PURE__*/jsx_runtime_.jsx("tr", {
- children: /*#__PURE__*/jsx_runtime_.jsx("td", {
- colSpan: "5",
- className: "text-center",
- children: "Tidak Ada Product di Keranjang"
- })
- })
- })]
- })
- }), /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "cart-buttons",
- children: /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "row align-items-center",
- children: /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "col-lg-7 col-md-7 col-sm-7",
- children: /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "continue-shopping-box",
- children: /*#__PURE__*/jsx_runtime_.jsx("a", {
- href: "/yamaha/Product/Motor",
- className: "btn btn-light",
- style: {
- color: 'white'
- },
- children: "Continue Shopping"
- })
- })
- })
- })
- }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("div", {
- className: "cart-totals",
- children: [/*#__PURE__*/jsx_runtime_.jsx("h3", {
- children: "Cart Totals"
- }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("ul", {
- children: [/*#__PURE__*/(0,jsx_runtime_.jsxs)("li", {
- children: ["Subtotal ", /*#__PURE__*/(0,jsx_runtime_.jsxs)("span", {
- children: ["$", total.toFixed(2)]
- })]
- }), /*#__PURE__*/(0,jsx_runtime_.jsxs)("li", {
- children: ["Total ", /*#__PURE__*/jsx_runtime_.jsx("span", {
- children: /*#__PURE__*/(0,jsx_runtime_.jsxs)("b", {
- children: ["$", (total + 10).toFixed(2)]
- })
- })]
- })]
- }), /*#__PURE__*/jsx_runtime_.jsx("button", {
- type: "submit",
- className: "btn btn-primary",
- children: "Proceed to Checkout"
- })]
- })]
- });
- };
-
- /* harmony default export */ var Cart = (CartContent);
- // EXTERNAL MODULE: ./api/shop/cart.js
- var cart = __webpack_require__(4777);
- var cart_default = /*#__PURE__*/__webpack_require__.n(cart);
- // EXTERNAL MODULE: external "cookies"
- var external_cookies_ = __webpack_require__(9038);
- ;// CONCATENATED MODULE: ./pages/yamaha/Shop/Cart.js
-
-
-
-
- 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; }
-
- 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; }
-
-
-
-
-
-
-
-
-
- const Cart_Cart = function (_ref) {
- let {
- cart_product,
- backend
- } = _ref,
- props = Cart_objectWithoutProperties(_ref, ["cart_product", "backend"]);
-
- return /*#__PURE__*/(0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
- children: [/*#__PURE__*/jsx_runtime_.jsx(NavbarYamaha/* default */.Z, {}), /*#__PURE__*/jsx_runtime_.jsx(PageBanner/* default */.Z, {
- pageTitle: "Cart"
- }), /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "cart-area ptb-80",
- children: /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "container",
- children: /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "row",
- children: /*#__PURE__*/jsx_runtime_.jsx("div", {
- className: "col-lg-12 col-md-12",
- children: /*#__PURE__*/jsx_runtime_.jsx(Cart, {
- cart_product: cart_product,
- backend: backend
- })
- })
- })
- })
- }), /*#__PURE__*/jsx_runtime_.jsx(FooterYamaha/* default */.Z, {})]
- });
- };
-
- /* harmony default export */ var Shop_Cart = (Cart_Cart);
- async function getServerSideProps() {
- var cart_product = [];
- const backend = process.env.BACKEND_SERVER_URI;
- var res = await cart_default().GetCartProduct();
-
- if (res["STATUS"] === 1) {
- cart_product = res["DATA"]["carts"];
- }
-
- console.log(cart_product);
- return {
- props: {
- cart_product,
- backend
- } // will be passed to the page component as props
-
- };
- }
-
- /***/ }),
-
- /***/ 8074:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("@apollo/client");;
-
- /***/ }),
-
- /***/ 9038:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("cookies");;
-
- /***/ }),
-
- /***/ 1683:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("cross-fetch");;
-
- /***/ }),
-
- /***/ 8417:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("next/dist/next-server/lib/router-context.js");;
-
- /***/ }),
-
- /***/ 2238:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("next/dist/next-server/lib/router/utils/get-asset-path-from-route.js");;
-
- /***/ }),
-
- /***/ 6731:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("next/router");;
-
- /***/ }),
-
- /***/ 9297:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("react");;
-
- /***/ }),
-
- /***/ 9337:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("react-feather");;
-
- /***/ }),
-
- /***/ 3230:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("react-number-format");;
-
- /***/ }),
-
- /***/ 79:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("react-redux");;
-
- /***/ }),
-
- /***/ 9614:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("react-toast-notifications");;
-
- /***/ }),
-
- /***/ 5282:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("react/jsx-runtime");;
-
- /***/ }),
-
- /***/ 8080:
- /***/ (function(module) {
-
- "use strict";
- module.exports = require("sweetalert");;
-
- /***/ })
-
- };
- ;
-
- // load runtime
- var __webpack_require__ = require("../../../webpack-runtime.js");
- __webpack_require__.C(exports);
- var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
- var __webpack_exports__ = __webpack_require__.X(0, [1664,4755,6371,7798], function() { return __webpack_exec__(1765); });
- module.exports = __webpack_exports__;
-
- })();
|