PageSourceSearch

https://samugiken.com/_next/static/chunks/pages/my-order/[refId]-f2eeedaec3a94b19.js

js samugiken.com collected 2026-10-07 01:51:19 UTC 11,374 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[178],{87165:function(e,s,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/my-order/[refId]",function(){return r(25608)}])},25608:function(e,s,r){"use strict";r.r(s),r.d(s,{__N_SSP:function(){return C}});var t=r(52676),a=r(46980),n=r(33561),i=r(69834),l=r(71030),d=r(56115),c=r(6443),o=r(83214),m=r(22903),x=r(76517),u=r(32623),h=r.n(u),p=r(79406),f=r(78051),g=r(18816),b=r(25918),N=r(57044),j=r(85842),y=r(54144),v=r(58612),w=r(7144),E=r(40974),D=r(72818),P=r(27026),S=r.n(P),A=r(4814);let L=e=>(e||"").toLowerCase().replace(/[_-]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),I=e=>{let s="DELIVERED"===e?"COMPLETED":e;if(["CANCELLED","PAYMENT_FAILED","REFUNDED","EXPIRED"].includes(e))return{current:-1,status:"error"};let r=["PENDING","PROCESSING","SHIPPED","COMPLETED"].indexOf(s);return{current:r>-1?r:0,status:"process"}};var C=!0;s.default=e=>{var s,r,u,P,C,F,Z;let{user:_}=e,{refId:O}=(0,n.useRouter)().query,{data:M,isLoading:k,error:R,refetch:T}=(0,i.a)({queryKey:["order",O],enabled:!!O,queryFn:async()=>(await (0,d.co)(O)).data}),Y=(0,l.D)({mutationFn:e=>(0,d.sl)(e),onSuccess:()=>{x.Am.success("Order cancelled"),T()},onError:e=>{x.Am.error((0,o._g)(e))}}),U=e=>{p.Z.confirm({title:"Cancel this order?",content:"This will cancel your pending order and release the reserved items. This cannot be undone.",okText:"Yes, cancel order",okButtonProps:{danger:!0},cancelText:"Keep order",onOk:()=>Y.mutateAsync(e)})},K=(0,l.D)({mutationFn:async e=>(await (0,c.y)(e)).data,onSuccess:e=>{let s=document.createElement("form");s.method="POST",s.action=e.actionUrl,Object.entries(e.formData).forEach(e=>{let[r,t]=e,a=document.createElement("input");a.type="hidden",a.name=r,a.value=String(t),s.appendChild(a)}),document.body.appendChild(s),s.submit()},onError:e=>{x.Am.error((0,o._g)(e))}});if(k)return(0,t.jsx)(a.Z,{user:_,children:(0,t.jsx)("div",{className:"flex justify-center items-center min-h-[60vh]",children:(0,t.jsx)("div",{className:"w-10 h-10 border-b-2 rounded-full animate-spin border-primary"})})});if(R||!M)return(0,t.jsx)(a.Z,{user:_,children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[60vh] gap-4",children:[(0,t.jsx)(b.Z,{className:"w-16 h-16 text-gray-300"}),(0,t.jsx)("p",{className:"text-lg text-gray-500",children:"Order not found"}),(0,t.jsx)(S(),{href:"/my-profile?tab=orders",children:(0,t.jsx)(f.ZP,{type:"primary",children:"Back to Orders"})})]})});let{current:V,status:q}=I(M.status),B=["PENDING","PAYMENT_FAILED"].includes(M.status),G=Number(M.shippingDiscount||0),H=Number(M.shippingFee)+G,X=M.shippingAddressSnapshot||M.pickupLocationSnapshot,z="PICKUP"===M.deliveryMethod;return(0,t.jsx)(a.Z,{user:_,children:(0,t.jsx)("div",{className:"min-h-screen pb-20 bg-gray-50/50",children:(0,t.jsxs)("div",{className:"max-w-6xl px-4 pt-8 mx-auto sm:px-6 lg:px-8",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,t.jsxs)(S(),{href:"/my-profile?tab=orders",className:"flex items-center text-sm font-medium text-gray-500 transition-colors group hover:text-gray-900",children:[(0,t.jsx)("div",{className:"flex items-center justify-center w-8 h-8 mr-3 transition-colors bg-white border border-gray-200 rounded-full shadow-sm group-hover:border-gray-300",children:(0,t.jsx)(v.Z,{className:"w-4 h-4"})}),"Back to Orders"]}),(0,t.jsxs)("div",{className:"text-sm text-gray-400",children:["ID: ",(0,t.jsxs)("span",{className:"font-mono text-gray-600",children:["#",M.orderCode]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-8 lg:grid-cols-12",children:[(0,t.jsxs)("div",{className:"space-y-6 lg:col-span-8",children:[(0,t.jsxs)("div",{className:"p-6 bg-white border border-gray-100 shadow-sm rounded-2xl sm:p-8",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold text-gray-900",children:["Order ",L(M.status)]}),(0,t.jsx)("p",{className:"mt-1 text-gray-500",children:(0,o.i$)(M.createdAt,"MMMM DD, YYYY [at] h:mm A")})]}),(0,t.jsxs)("div",{className:(0,A.Z)("flex items-center gap-2 px-4 py-2 rounded-full border text-sm font-semibold",["CANCELLED","PAYMENT_FAILED","REFUNDED"].includes(F=M.status)?"text-red-600 bg-red-50 border-red-100":"COMPLETED"===F||"DELIVERED"===F?"text-green-600 bg-green-50 border-green-100":"SHIPPED"===F?"text-purple-600 bg-purple-50 border-purple-100":"text-blue-600 bg-blue-50 border-blue-100"),children:[["CANCELLED","PAYMENT_FAILED","REFUNDED"].includes(Z=M.status)?(0,t.jsx)(N.Z,{className:"w-5 h-5"}):"COMPLETED"===Z||"DELIVERED"===Z?(0,t.jsx)(j.Z,{className:"w-5 h-5"}):(0,t.jsx)(y.Z,{className:"w-5 h-5"}),L(M.status)]})]}),"error"!==q&&(0,t.jsx)("div",{className:"px-2",children:(0,t.jsx)(g.Z,{current:V,status:q,items:[{title:"Order Placed"},{title:"Processing"},{title:"Shipped"},{title:"Delivered"}]})})]}),(0,t.jsxs)("div",{className:"overflow-hidden bg-white border border-gray-100 shadow-sm rounded-2xl",children:[(0,t.jsx)("div",{className:"flex items-center justify-between p-6 border-b border-gray-100",children:(0,t.jsxs)("h2",{className:"text-lg font-bold text-gray-900",children:["Items (",M.items.length,")"]})}),(0,t.jsx)("div",{className:"divide-y divide-gray-50",children:M.items.map(e=>(0,t.jsx)("div",{className:"p-6 transition-colors hover:bg-gray-50/50",children:(0,t.jsxs)("div",{className:"flex gap-6",children:[(0,t.jsx)("div",{className:"relative flex-shrink-0 w-24 h-24 overflow-hidden bg-gray-100 border border-gray-200 rounded-xl",children:e.imageKey?(0,t.jsx)(h(),{src:(0,m.I)(e.imageKey),alt:e.productName||"Product",fill:!0,className:"object-cover"}):(0,t.jsx)("div",{className:"flex items-center justify-center w-full h-full",children:(0,t.jsx)(w.Z,{className:"w-8 h-8 text-gray-400"})})}),(0,t.jsx)("div",{className:"flex flex-col justify-center flex-1 min-w-0",children:(0,t.jsxs)("div",{className:"flex items-start justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"mb-1 text-base font-semibold text-gray-900 line-clamp-2",children:e.productName}),e.variationAttributes&&e.variationAttributes.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-2 mt-1",children:e.variationAttributes.map((e,s)=>(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-600",children:e.value},s))})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsxs)("div",{className:"text-lg font-bold text-gray-900",children:["RM"," ",Number(e.unitPrice).toFixed(2)]}),(0,t.jsxs)("div",{className:"mt-1 text-sm text-gray-500",children:["x",e.quantity]})]})]})})]})},e.refId))})]})]}),(0,t.jsxs)("div",{className:"space-y-6 lg:col-span-4",children:[(0,t.jsxs)("div",{className:"sticky p-6 bg-white border border-gray-100 shadow-sm rounded-2xl top-6",children:[(0,t.jsx)("h3",{className:"mb-6 font-bold text-gray-900",children:"Order Summary"}),(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between text-gray-600",children:[(0,t.jsx)("span",{children:"Subtotal"}),(0,t.jsxs)("span",{className:"font-medium text-gray-900",children:["RM ",Number(M.subtotal).toFixed(2)]})]}),Number(M.discount)>0&&(0,t.jsxs)("div",{className:"flex justify-between text-green-600",children:[(0,t.jsx)("span",{children:"Discount"}),(0,t.jsxs)("span",{className:"font-medium",children:["-RM ",Number(M.discount).toFixed(2)]})]}),(0,t.jsxs)("div",{className:"flex justify-between text-gray-600",children:[(0,t.jsx)("span",{children:"Shipping Fee"}),(0,t.jsx)("span",{className:"font-medium text-gray-900",children:H>0?"RM ".concat(H.toFixed(2)):"Free"})]}),G>0&&(0,t.jsxs)("div",{className:"flex justify-between text-green-600",children:[(0,t.jsx)("span",{children:"Free Shipping Voucher"}),(0,t.jsxs)("span",{className:"font-medium",children:["-RM ",G.toFixed(2)]})]}),M.couponSnapshots&&M.couponSnapshots.length>0&&(0,t.jsxs)("div",{className:"pt-4 border-t border-gray-100",children:[(0,t.jsx)("div",{className:"mb-2 text-xs font-medium text-gray-500",children:"Vouchers Applied"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:M.couponSnapshots.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2.5 py-1 text-xs font-semibold text-primary",children:[e.code,"FREE_SHIPPING"===e.discountType?" \xb7 Free Shipping":""]},e.code))})]}),(0,t.jsx)("div",{className:"pt-4 border-t border-gray-100",children:(0,t.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,t.jsx)("span",{className:"text-base font-bold text-gray-900",children:"Total"}),(0,t.jsxs)("span",{className:"text-2xl font-bold text-primary",children:["RM ",Number(M.total).toFixed(2)]})]})})]}),B&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.ZP,{type:"primary",size:"large",loading:K.isPending,onClick:()=>K.mutate(M.refId),className:"w-full h-12 mt-6 text-base font-semibold shadow-lg shadow-primary/25 rounded-xl",children:"Pay Now"}),(0,t.jsx)(f.ZP,{danger:!0,size:"large",loading:Y.isPending,onClick:()=>U(M.refId),className:"w-full h-12 mt-3 text-base font-semibold rounded-xl",children:"Cancel Order"})]})]}),(0,t.jsxs)("div",{className:"p-6 bg-white border border-gray-100 shadow-sm rounded-2xl",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 text-blue-600 rounded-lg bg-blue-50",children:z?(0,t.jsx)(E.Z,{className:"w-5 h-5"}):(0,t.jsx)(D.Z,{className:"w-5 h-5"})}),(0,t.jsx)("h3",{className:"font-bold text-gray-900",children:z?"Pickup Location":"Delivery Address"})]}),X?(0,t.jsxs)("div",{className:"text-sm text-gray-600 pl-[3.25rem]",children:[(0,t.jsx)("p",{className:"mb-1 text-base font-semibold text-gray-900",children:z?null===(s=M.pickupLocationSnapshot)||void 0===s?void 0:s.name:(null===(r=M.shippingAddressSnapshot)||void 0===r?void 0:r.firstName)+" "+(null===(u=M.shippingAddressSnapshot)||void 0===u?void 0:u.lastName)}),(0,t.jsx)("p",{className:"mb-2",children:z?null===(P=M.pickupLocationSnapshot)||void 0===P?void 0:P.phone:null===(C=M.shippingAddressSnapshot)||void 0===C?void 0:C.phone}),(0,t.jsx)("p",{className:"leading-relaxed",children:[X.addressLine1,X.addressLine2,X.city,X.state,X.postcode,X.country].filter(
1Boolean).join(", ")})]}):(0,t.jsx)("div",{className:"text-sm text-gray-400 italic pl-[3.25rem]",children:"Address information unavailable"})]})]})]})]})})})}},56115:function(e,s,r){"use strict";r.d(s,{OU:function(){return i},co:function(){return a},m9:function(){return l},sl:function(){return n}});var t=r(5409);async function a(e){return await t.Z.get("/orders/".concat(e))}async function n(e){return await t.Z.post("/orders/".concat(e,"/cancel"))}async function i(e){return await t.Z.post("/orders/init-with-delivery",e)}async function l(e,s){return await t.Z.post("/orders/init-from-session?sessionId=".concat(e),s)}},6443:function(e,s,r){"use strict";r.d(s,{j:function(){return n},y:function(){return a}});var t=r(5409);async function a(e){return await t.Z.post("/payment/init/".concat(e))}async function n(e){let s=new URLSearchParams;return e.orderid&&s.set("orderid",e.orderid),await t.Z.get("/payment/return?".concat(s.toString()))}}},function(e){e.O(0,[5989,4237,7610,8174,9834,8051,4298,9406,9830,1618,6980,2888,9774,179],function(){return e(e.s=87165)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.