11import * as Common from "@frontend/common" ;
2- import { ExpandMore } from "@mui/icons-material" ;
3- import {
4- Accordion ,
5- AccordionActions ,
6- AccordionDetails ,
7- AccordionSummary ,
8- Button ,
9- CircularProgress ,
10- Divider ,
11- List ,
12- Stack ,
13- Typography ,
14- } from "@mui/material" ;
2+ import { Button , CircularProgress , Divider , Stack , Typography } from "@mui/material" ;
153import { ErrorBoundary , Suspense } from "@suspensive/react" ;
164import * as React from "react" ;
175import * as R from "remeda" ;
@@ -92,42 +80,37 @@ const OrderProductRelationItem: React.FC<OrderProductRelationItemProps> = ({
9280 } ) ;
9381 } ;
9482
83+ const actionButtons = (
84+ < >
85+ < Button variant = "contained" fullWidth onClick = { patchOneItemOptions } disabled = { patchOptionBtnDisabled } >
86+ 옵션 수정
87+ </ Button >
88+ < Button variant = "contained" fullWidth onClick = { refundOneItem } disabled = { refundBtnDisabled } >
89+ { refundBtnText }
90+ </ Button >
91+ </ >
92+ ) ;
93+
9594 return (
96- < Accordion key = { prodRel . id } >
97- < AccordionSummary expandIcon = { < ExpandMore /> } > { prodRel . product . name } </ AccordionSummary >
98- < AccordionDetails >
99- < form
100- ref = { formRef }
101- onSubmit = { ( e ) => {
102- e . preventDefault ( ) ;
103- patchOneItemOptions ( ) ;
104- } }
105- >
106- < Stack spacing = { 2 } sx = { { width : "100%" } } >
107- { prodRel . options . map ( ( optionRel ) => (
108- < CommonComponents . OrderProductRelationOptionInput
109- key = { optionRel . product_option_group . id + ( optionRel . product_option ?. id || "" ) }
110- optionRel = { optionRel }
111- disabled = { isPending }
112- />
113- ) ) }
114- </ Stack >
115- </ form >
116- </ AccordionDetails >
117- < AccordionActions >
118- < Button
119- variant = "contained"
120- sx = { { width : "100%" } }
121- onClick = { patchOneItemOptions }
122- disabled = { patchOptionBtnDisabled }
123- >
124- 옵션 수정
125- </ Button >
126- < Button variant = "contained" sx = { { width : "100%" } } onClick = { refundOneItem } disabled = { refundBtnDisabled } >
127- { refundBtnText }
128- </ Button >
129- </ AccordionActions >
130- </ Accordion >
95+ < Common . Components . MDX . PrimaryStyledDetails key = { prodRel . id } summary = { prodRel . product . name } actions = { actionButtons } >
96+ < form
97+ ref = { formRef }
98+ onSubmit = { ( e ) => {
99+ e . preventDefault ( ) ;
100+ patchOneItemOptions ( ) ;
101+ } }
102+ >
103+ < Stack spacing = { 2 } sx = { { width : "100%" } } >
104+ { prodRel . options . map ( ( optionRel ) => (
105+ < CommonComponents . OrderProductRelationOptionInput
106+ key = { optionRel . product_option_group . id + ( optionRel . product_option ?. id || "" ) }
107+ optionRel = { optionRel }
108+ disabled = { isPending }
109+ />
110+ ) ) }
111+ </ Stack >
112+ </ form >
113+ </ Common . Components . MDX . PrimaryStyledDetails >
131114 ) ;
132115} ;
133116
@@ -154,45 +137,43 @@ const OrderItem: React.FC<{ order: ShopSchemas.Order; disabled?: boolean }> = ({
154137 ? "주문 전체 환불됨"
155138 : order . not_fully_refundable_reason ;
156139
140+ const actionButtons = (
141+ < >
142+ < Button variant = "contained" fullWidth onClick = { openReceipt } disabled = { receipyBtnDisabled } >
143+ 영수증
144+ </ Button >
145+ < Button variant = "contained" fullWidth onClick = { refundOrder } disabled = { refundBtnDisabled } >
146+ { btnText }
147+ </ Button >
148+ </ >
149+ ) ;
150+
157151 return (
158- < Accordion >
159- < AccordionSummary expandIcon = { < ExpandMore /> } >
160- < Typography variant = "h6" > { order . name } </ Typography >
161- </ AccordionSummary >
162- < AccordionDetails >
163- < Divider />
164- < br />
165- < Typography variant = "body1" >
166- 주문 결제 금액 : < CommonComponents . PriceDisplay price = { order . current_paid_price } />
167- </ Typography >
168- < Typography variant = "body1" > 상태: { PaymentHistoryStatusTranslated [ order . current_status ] } </ Typography >
169- < br />
170- < Divider />
171- < br />
172- < Typography variant = "body1" > 주문 상품 목록</ Typography >
173- < br />
174- { order . products . map ( ( prodRel ) => (
175- < OrderProductRelationItem
176- key = { prodRel . id }
177- order = { order }
178- prodRel = { prodRel }
179- isPending = { isPending }
180- oneItemRefundMutation = { oneItemRefundMutation }
181- optionsOfOneItemInOrderPatchMutation = { optionsOfOneItemInOrderPatchMutation }
182- />
183- ) ) }
184- < br />
185- < Divider />
186- </ AccordionDetails >
187- < AccordionActions >
188- < Button variant = "contained" sx = { { width : "100%" } } onClick = { openReceipt } disabled = { receipyBtnDisabled } >
189- 영수증
190- </ Button >
191- < Button variant = "contained" sx = { { width : "100%" } } onClick = { refundOrder } disabled = { refundBtnDisabled } >
192- { btnText }
193- </ Button >
194- </ AccordionActions >
195- </ Accordion >
152+ < Common . Components . MDX . PrimaryStyledDetails summary = { order . name } actions = { actionButtons } >
153+ < Divider />
154+ < br />
155+ < Typography variant = "body1" >
156+ 주문 결제 금액 : < CommonComponents . PriceDisplay price = { order . current_paid_price } />
157+ </ Typography >
158+ < Typography variant = "body1" > 상태: { PaymentHistoryStatusTranslated [ order . current_status ] } </ Typography >
159+ < br />
160+ < Divider />
161+ < br />
162+ < Typography variant = "body1" > 주문 상품 목록</ Typography >
163+ < br />
164+ { order . products . map ( ( prodRel ) => (
165+ < OrderProductRelationItem
166+ key = { prodRel . id }
167+ order = { order }
168+ prodRel = { prodRel }
169+ isPending = { isPending }
170+ oneItemRefundMutation = { oneItemRefundMutation }
171+ optionsOfOneItemInOrderPatchMutation = { optionsOfOneItemInOrderPatchMutation }
172+ />
173+ ) ) }
174+ < br />
175+ < Divider />
176+ </ Common . Components . MDX . PrimaryStyledDetails >
196177 ) ;
197178} ;
198179
@@ -201,13 +182,7 @@ export const OrderList: React.FC = () => {
201182 const shopAPIClient = ShopHooks . useShopClient ( ) ;
202183 const { data } = ShopHooks . useOrders ( shopAPIClient ) ;
203184
204- return (
205- < List >
206- { data . map ( ( item ) => (
207- < OrderItem key = { item . id } order = { item } />
208- ) ) }
209- </ List >
210- ) ;
185+ return data . map ( ( item ) => < OrderItem key = { item . id } order = { item } /> ) ;
211186 } ;
212187
213188 return (
0 commit comments