import{u as Y,Q as k,a as y,j as e,ai as A,aC as p,aD as l,T as r,aL as E,L as W,U as F,c as d,R as M,az as _,n as B,aB as G,aE as q,b as m,d as f,aM as C,a8 as z,W as H,a6 as O,aq as v,a0 as w,Z as Q,G as u,aG as T,aH as N}from"../index.Crez7j-Y.bundle.js";import{P as V}from"./PreviousOrderAPIs.DG34jGDX.bundle.js";import{P as D}from"./PeriodSearchFilter.B8yOjOwD.bundle.js";import{E as L}from"./EmptyContent.BRQ9JwMr.bundle.js";import{u as $}from"./useClaimHooks.DyLDR42V.bundle.js";import"./DialogContent.CusHOJib.bundle.js";const K=(s,a)=>{const{getPreviousOrderListAPI:t}=V();return Y({queryKey:k.getPreviousOrderList(s),queryFn:()=>t(s),refetchOnWindowFocus:!1,...a})};function I(s){const{isDesktop:a,isMobile:t}=y();return e.jsxs(e.Fragment,{children:[a&&e.jsx(Z,{...s}),t&&e.jsx(J,{...s})]})}function Z(s){const{previousOrderOption:a,mainPayAmt:t,payTypeLabel:i,isFirstRow:n,orderNo:o,rowSpan:c}=s,{formatPriceWithCommas:h}=A(),{getClaimStatusTypeLabel:g}=$();return e.jsxs(p,{children:[n&&e.jsxs(l,{align:"center",rowSpan:c,children:[e.jsx(r,{variant:"body",component:"p",fontWeight:500,children:E(a.orderYmdt).format("YYYY-MM-DD")}),e.jsx(W,{variant:"small",href:"".concat(F.MYPAGE_PREVIOUS_ORDER_DETAIL,"?orderNo=").concat(o),children:o})]}),e.jsx(l,{children:e.jsx(d,{display:"flex",gap:1,children:e.jsxs(d,{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,children:[e.jsx(r,{variant:"body",fontWeight:500,children:a.productName}),e.jsx(r,{variant:"small",children:"".concat(a.optionName," : ").concat(a.optionValue)})]})})}),e.jsx(l,{align:"center",children:e.jsx(r,{variant:"body",children:a.orderCnt})}),e.jsx(l,{align:"center",children:e.jsx(r,{variant:"body",component:"span",children:h(t,"WON")})}),e.jsx(l,{align:"center",children:e.jsx(r,{variant:"body",component:"span",children:g(a.orderStatusType)})}),e.jsx(l,{align:"center",children:e.jsx(r,{variant:"body",component:"span",children:i})})]})}function J(s){const{previousOrderOption:a,mainPayAmt:t,payTypeLabel:i,orderNo:n}=s,{formatPriceWithCommas:o}=A(),{getClaimStatusTypeLabel:c}=$();return e.jsxs(W,{href:"".concat(F.MYPAGE_PREVIOUS_ORDER_DETAIL,"?orderNo=").concat(n),underline:"none",display:"flex",flexDirection:"column",gap:1,children:[e.jsxs(d,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(r,{variant:"subtitle2",children:["상품명 : ",a.productName]}),e.jsx(r,{variant:"body",color:M,fontWeight:500,children:"".concat(c(a.orderStatusType))})]}),e.jsx(r,{variant:"body",fontWeight:400,children:"주문일시 : ".concat(E(a.orderYmdt).format("YYYY-MM-DD"))}),e.jsx(r,{variant:"body",children:"주문옵션 : ".concat(a.optionValue)}),e.jsxs(d,{display:"flex",justifyContent:"space-between",children:[e.jsx(r,{variant:"body",children:"주문수량 : ".concat(a.orderCnt)}),e.jsx(r,{variant:"body",component:"span",children:"실결제금액 : ".concat(o(t,"WON"))}),e.jsx(r,{variant:"body",component:"span",children:"결제수단 : ".concat(i,"}")})]})]})}function R(s){const{isDesktop:a,isMobile:t}=y();return e.jsxs(e.Fragment,{children:[a&&e.jsx(X,{...s}),t&&e.jsx(ee,{...s})]})}function X(s){var i;const{isPending:a,previousOrderList:t}=s;return e.jsxs(d,{mt:3,children:[e.jsx(r,{variant:"subtitle1",pb:1,children:"총 ".concat((i=t==null?void 0:t.totalCount)!=null?i:0,"건")}),e.jsxs(_,{size:"small",sx:{"& th":{py:1,px:0,bgcolor:B},"& td":{py:2,px:0}},children:[e.jsx(G,{children:e.jsxs(p,{children:[e.jsx(l,{width:130,align:"center",children:e.jsx(r,{variant:"body",fontWeight:500,children:"주문일자(주문번호)"})}),e.jsx(l,{width:300,align:"center",children:e.jsx(r,{variant:"body",fontWeight:500,children:"상품정보"})}),e.jsx(l,{width:70,align:"center",children:e.jsx(r,{variant:"body",fontWeight:500,children:"주문수량"})}),e.jsx(l,{width:100,align:"center",children:e.jsx(r,{variant:"body",fontWeight:500,children:"실결제금액"})}),e.jsx(l,{width:100,align:"center",children:e.jsx(r,{variant:"body",fontWeight:500,children:"진행상태"})}),e.jsx(l,{width:150,align:"center",children:e.jsx(r,{variant:"body",fontWeight:500,children:"결제수단"})})]})}),e.jsxs(q,{children:[t&&t.totalCount===0&&e.jsx(p,{children:e.jsx(l,{colSpan:6,children:e.jsx(L,{text:"주문 내역이 없습니다.",height:"40dvh"})})}),a&&Array.from({length:5}).map((n,o)=>e.jsx(p,{children:Array.from({length:6}).map((c,h)=>e.jsx(l,{children:e.jsx(m,{sx:{height:100,width:"70%",margin:"auto"}})},h*10))},o)),t==null?void 0:t.contents.map(n=>e.jsx(f.Fragment,{children:n.orderOptions.map((o,c,h)=>e.jsx(I,{previousOrderOption:o,payTypeLabel:n.payTypeLabel,mainPayAmt:n.mainPayAmt,isFirstRow:c===0,rowSpan:h.length,orderNo:n.orderNo},o.orderYmdt+c))},n.orderNo))]})]})]})}function ee(s){const{isPending:a,previousOrderList:t}=s;return a?e.jsx(e.Fragment,{children:Array.from({length:3}).map((i,n)=>e.jsxs(d,{display:"flex",gap:2,mb:2,children:[e.jsx(m,{variant:"rectangular",sx:{height:100,flex:1}}),e.jsxs(d,{flex:2,children:[e.jsx(m,{variant:"text"}),e.jsx(m,{variant:"text"}),e.jsx(m,{variant:"text"}),e.jsx(m,{variant:"text"})]})]},n))}):(t==null?void 0:t.totalCount)===0?e.jsx(L,{text:"주문 내역이 없습니다.",height:"40vh"}):e.jsx(e.Fragment,{children:t==null?void 0:t.contents.map(i=>e.jsx(d,{children:e.jsxs(d,{display:"flex",flexDirection:"column",py:2,gap:1,children:[e.jsx(d,{display:"flex",alignItems:"center",gap:1,justifyContent:"space-between",children:e.jsx(r,{variant:"subtitle2",fontWeight:400,children:"주문번호 : "+i.orderNo})}),e.jsx(C,{sx:{borderColor:"".concat(z)}}),i.orderOptions.map((n,o,c)=>e.jsxs(f.Fragment,{children:[e.jsx(I,{previousOrderOption:n,mainPayAmt:i.mainPayAmt,payTypeLabel:i.payTypeLabel,isFirstRow:o===0,rowSpan:c.length,orderNo:i.orderNo}),o!==c.length&&e.jsx(C,{})]},n.optionNo+n.orderYmdt+o))]},i.orderNo)},i.orderNo))})}function oe(){var b,P;const[s,a]=H(),[t,i]=f.useState(s),{data:n,isPending:o}=K(t),c=()=>{a(x=>{const j=new URLSearchParams(x);return j.set("pageNumber",String(T)),j.set("pageSize",String(N)),j}),i(()=>{const x=new URLSearchParams(s);return x.set("pageNumber",String(T)),x.set("pageSize",String(N)),x})},h=x=>{i(j=>{const S=new URLSearchParams(j);return S.set("pageNumber",String(x)),S})},{isMobile:g,isDesktop:U}=y();return e.jsxs(e.Fragment,{children:[U&&e.jsxs(d,{bgcolor:O,borderRadius:2,p:4,gap:2,component:"section",display:"flex",flexDirection:"column",children:[e.jsx(v,{title:"이전 주문목록"}),e.jsx(D,{onClickSearchButton:c,isPreviousOrderFilter:!0}),e.jsx(R,{previousOrderList:n,isPending:o}),e.jsx(w,{itemTotalCount:(b=n==null?void 0:n.totalCount)!=null?b:0,onPageChange:h})]}),g&&e.jsxs(Q,{children:[e.jsx(u,{item:!0,mobile:12,children:e.jsx(v,{title:"이전 주문목록"})}),e.jsx(u,{item:!0,mobile:11,mx:"auto",my:3,children:e.jsx(D,{onClickSearchButton:c,isPreviousOrderFilter:!0})}),e.jsx(u,{item:!0,mobile:11,mx:"auto",component:"section",children:e.jsx(R,{previousOrderList:n,isPending:o})}),e.jsx(w,{itemTotalCount:(P=n==null?void 0:n.totalCount)!=null?P:0,onPageChange:h})]})]})}export{oe as default};