|
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2252],{91288:function(e,r,t){"use strict";var n=t(85893);t(67294);r.Z=function(e){var r=e.pageTitle;return(0,n.jsx)("div",{className:"page-title-area",children:(0,n.jsx)("div",{className:"d-table",children:(0,n.jsx)("div",{className:"d-table-cell",children:(0,n.jsx)("div",{className:"container",children:(0,n.jsx)("h2",{children:r})})})})})}},81765:function(e,r,t){"use strict";t.r(r),t.d(r,{__N_SSP:function(){return P},default:function(){return S}});var n=t(85893),o=t(38347),c=t(67294),a=t(72478),s=t(80362),i=t(91288),l=t(809),u=t.n(l),d=t(26265),p=t(92447),h=t(64121),f=t(41664),x=t(30833),j=t(39704),m=t(85611),y=t(11163),v=t(20210),b=t(61896),g=function(e){var r=e.id,t=(e.quantity,(0,j.I0)());return(0,n.jsxs)("div",{className:"input-counter",children:[(0,n.jsx)("span",{className:"minus-btn",onClick:function(e){e.preventDefault(),function(e){t({type:"SUB_QUANTITY",id:e})}(r)},children:(0,n.jsx)(v.Z,{})}),(0,n.jsx)("input",{type:"text",min:"1",value:"1",readOnly:!0,onChange:function(e){return e}}),(0,n.jsx)("span",{className:"plus-btn",onClick:function(e){e.preventDefault(),function(e){t({type:"ADD_QUANTITY",id:e})}(r)},children:(0,n.jsx)(b.Z,{})})]})},O=t(57333),w=t(46737),k=t.n(w);function N(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function _(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?N(Object(t),!0).forEach((function(r){(0,d.Z)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):N(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var T=function(e){e.backend;var r=e.cart_product,t=((0,o.Z)(e,["backend","cart_product"]),(0,y.useRouter)()),a=(0,m.e1)().addToast,s=(0,j.I0)(),i=((0,j.v9)((function(e){return e.cart})),(0,j.v9)((function(e){return e.total}))),l=c.useState({transaction_id:function(){var e=(new Date).getTime();return"Trx-Ord-yyyyyyyy".replace(/[y]/g,(function(r){var t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==r?t:3&t|8).toString(16)}))}(),product_img:"",product_name:"",product_color:"",product_quantity:1,product_price:""}),d=(0,h.Z)(l,2),v=d[0],b=d[1];return(0,n.jsxs)("form",{onSubmit:function(){var e=(0,p.Z)(u().mark((function e(n){var o,c,a;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.preventDefault(),o=_(_({},v),{},{product_name:r[0].product_name,product_color:r[0].product_color,product_price:r[0].product_price}),b(o),console.log(JSON.stringify(o)),e.next=6,fetch("/api/transaction/AddToCheckout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 6:if(!(c=e.sent).ok){e.next=15;break}return e.next=10,c.json();case 10:a=e.sent,console.log("cek response :",a),1===a.STATUS?(a.DATA.checkout,k()("Produk Berhasil Ditambah ke Keranjang","Silahkan Cek Keranjang Belanja Anda","success"),t.push("/yamaha/Shop/Checkout")):k()("Produk Gagal di Checkout","Silahkan Coba Lagi","error"),e.next=16;break;case 15:k()("Transaksi Gagal","Silahkan Coba Lagi","error");case 16:return e.abrupt("return",!1);case 17:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),children:[(0,n.jsx)("div",{className:"cart-table table-responsive",children:(0,n.jsxs)("table",{className:"table table-bordered",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{scope:"col",children:"Product"}),(0,n.jsx)("th",{scope:"col",children:"Nama Product"}),(0,n.jsx)("th",{scope:"col",children:"Warna Product"}),(0,n.jsx)("th",{scope:"col",children:"Harga Product"}),(0,n.jsx)("th",{scope:"col",children:"Jumlah"}),(0,n.jsx)("th",{scope:"col",children:"Total"})]})}),(0,n.jsx)("tbody",{children:r.length?r.map((function(e){return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"product-thumbnail",children:(0,n.jsx)(f.default,{href:"/product-details",children:(0,n.jsx)("a",{})})}),(0,n.jsx)("td",{className:"product-name",children:(0,n.jsx)(f.default,{href:"/product-details",children:(0,n.jsx)("a",{children:e.product_name})})}),(0,n.jsx)("td",{className:"product-name",children:(0,n.jsx)(f.default,{href:"/product-details",children:(0,n.jsx)("a",{children:e.product_color})})}),(0,n.jsx)("td",{className:"product-price",children:(0,n.jsx)("span",{className:"unit-amount",children:(0,n.jsx)(O.Z,{value:e.product_price,displayType:"text",thousandSeparator:!0,prefix:"Rp."})})}),(0,n.jsx)("td",{className:"product-quantity",children:(0,n.jsx)(g,_({},e))}),(0,n.jsxs)("td",{className:"product-subtotal",children:[(0,n.jsx)("span",{className:"subtotal-amount",children:(0,n.jsx)(O.Z,{value:(2*e.product_price).toFixed(2),displayType:"text",thousandSeparator:!0,prefix:"Rp."})}),(0,n.jsx)("a",{href:"#",className:"remove",onClick:function(){e.id,s({type:"REMOVE_ITEM",id:pId}),a("Cart Removed Successfully",{appearance:"error"})},children:(0,n.jsx)(x.Z,{})})]})]},e.id)})):(0,n.jsx)("tr",{children:(0,n.jsx)("td",{colSpan:"5",className:"text-center",children:"Tidak Ada Product di Keranjang"})})})]})}),(0,n.jsx)("div",{className:"cart-buttons",children:(0,n.jsx)("div",{className:"row align-items-center",children:(0,n.jsx)("div",{className:"col-lg-7 col-md-7 col-sm-7",children:(0,n.jsx)("div",{className:"continue-shopping-box",children:(0,n.jsx)("a",{href:"/yamaha/Product/Motor",className:"btn btn-light",style:{color:"white"},children:"Continue Shopping"})})})})}),(0,n.jsxs)("div",{className:"cart-totals",children:[(0,n.jsx)("h3",{children:"Cart Totals"}),(0,n.jsxs)("ul",{children:[(0,n.jsxs)("li",{children:["Subtotal ",(0,n.jsxs)("span",{children:["$",i.toFixed(2)]})]}),(0,n.jsxs)("li",{children:["Total ",(0,n.jsx)("span",{children:(0,n.jsxs)("b",{children:["$",(i+10).toFixed(2)]})})]})]}),(0,n.jsx)("button",{type:"submit",className:"btn btn-primary",children:"Proceed to Checkout"})]})]})},P=(t(88933),!0),S=function(e){var r=e.cart_product,t=e.backend;(0,o.Z)(e,["cart_product","backend"]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.Z,{}),(0,n.jsx)(i.Z,{pageTitle:"Cart"}),(0,n.jsx)("div",{className:"cart-area ptb-80",children:(0,n.jsx)("div",{className:"container",children:(0,n.jsx)("div",{className:"row",children:(0,n.jsx)("div",{className:"col-lg-12 col-md-12",children:(0,n.jsx)(T,{cart_product:r,backend:t})})})})}),(0,n.jsx)(s.Z,{})]})}},7724:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/yamaha/Shop/Cart",function(){return t(81765)}])},20210:function(e,r,t){"use strict";var n=t(67294),o=t(45697),c=t.n(o);function a(){return(a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function s(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var i=(0,n.forwardRef)((function(e,r){var t=e.color,o=void 0===t?"currentColor":t,c=e.size,i=void 0===c?24:c,l=s(e,["color","size"]);return n.createElement("svg",a({ref:r,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l),n.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}))}));i.propTypes={color:c().string,size:c().oneOfType([c().string,c().number])},i.displayName="Minus",r.Z=i},61896:function(e,r,t){"use strict";var n=t(67294),o=t(45697),c=t.n(o);function a(){return(a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function s(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var i=(0,n.forwardRef)((function(e,r){var t=e.color,o=void 0===t?"currentColor":t,c=e.size,i=void 0===c?24:c,l=s(e,["color","size"]);return n.createElement("svg",a({ref:r,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l),n.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}))}));i.propTypes={color:c().string,size:c().oneOfType([c().string,c().number])},i.displayName="Plus",r.Z=i},30833:function(e,r,t){"use strict";var n=t(67294),o=t(45697),c=t.n(o);function a(){return(a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function s(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var i=(0,n.forwardRef)((function(e,r){var t=e.color,o=void 0===t?"currentColor":t,c=e.size,i=void 0===c?24:c,l=s(e,["color","size"]);return n.createElement("svg",a({ref:r,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l),n.createElement("polyline",{points:"3 6 5 6 21 6"}),n.createElement("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),n.createElement("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),n.createElement("line",{x1:"14",y1:"11",x2:"14",y2:"17"}))}));i.propTypes={color:c().string,size:c().oneOfType([c().string,c().number])},i.displayName="Trash2",r.Z=i},46601:function(){},89214:function(){},71922:function(){},2363:function(){},52361:function(){},94616:function(){}},function(e){e.O(0,[3023,6326,7333,8933,6737,7798,9774,2888,179],(function(){return r=7724,e(e.s=r);var r}));var r=e.O();_N_E=r}]);
- //# sourceMappingURL=Cart-46cc78230a0fe97b1c70.js.map
|