@@ -15,10 +15,13 @@ import {
1515import { ErrorBoundary , Suspense } from "@suspensive/react" ;
1616import { useQueryClient } from "@tanstack/react-query" ;
1717
18- import * as Shop from "@frontend/shop" ;
18+ import ShopHooks from "../../hooks" ;
19+ import ShopSchemas from "../../schemas" ;
20+ import ShopUtils from "../../utils" ;
21+ import CommonComponents from "../common" ;
1922
20- const ShopCartItem : React . FC < {
21- cartProdRel : Shop . Schemas . OrderProductItem ;
23+ const CartItem : React . FC < {
24+ cartProdRel : ShopSchemas . OrderProductItem ;
2225 removeItemFromCartFunc : ( cartProductId : string ) => void ;
2326 disabled ?: boolean ;
2427} > = ( { cartProdRel, disabled, removeItemFromCartFunc } ) => (
@@ -31,7 +34,7 @@ const ShopCartItem: React.FC<{
3134 < AccordionDetails >
3235 < Stack spacing = { 2 } sx = { { width : "100%" } } >
3336 { cartProdRel . options . map ( ( optionRel ) => (
34- < Shop . Components . OrderProductRelationOptionInput
37+ < CommonComponents . OrderProductRelationOptionInput
3538 key = {
3639 optionRel . product_option_group . id +
3740 ( optionRel . product_option ?. id || "" )
@@ -46,7 +49,7 @@ const ShopCartItem: React.FC<{
4649 < Divider />
4750 < br />
4851 < Typography variant = "h6" sx = { { textAlign : "end" } } >
49- 상품 가격: < Shop . Components . PriceDisplay price = { cartProdRel . price } />
52+ 상품 가격: < CommonComponents . PriceDisplay price = { cartProdRel . price } />
5053 </ Typography >
5154 </ AccordionDetails >
5255 < AccordionActions >
@@ -62,33 +65,33 @@ const ShopCartItem: React.FC<{
6265 </ Accordion >
6366) ;
6467
65- export const ShopCartList : React . FC < { onPaymentCompleted ?: ( ) => void } > = ( {
68+ export const CartStatus : React . FC < { onPaymentCompleted ?: ( ) => void } > = ( {
6669 onPaymentCompleted,
6770} ) => {
6871 const queryClient = useQueryClient ( ) ;
69- const cartOrderStartMutation = Shop . Hooks . usePrepareCartOrderMutation ( ) ;
70- const removeItemFromCartMutation = Shop . Hooks . useRemoveItemFromCartMutation ( ) ;
72+ const cartOrderStartMutation = ShopHooks . usePrepareCartOrderMutation ( ) ;
73+ const removeItemFromCartMutation = ShopHooks . useRemoveItemFromCartMutation ( ) ;
7174
7275 const removeItemFromCart = ( cartProductId : string ) =>
7376 removeItemFromCartMutation . mutate ( { cartProductId } ) ;
7477 const startCartOrder = ( ) =>
7578 cartOrderStartMutation . mutate ( undefined , {
76- onSuccess : ( order : Shop . Schemas . Order ) => {
77- Shop . Utils . startPortOnePurchase (
79+ onSuccess : ( order : ShopSchemas . Order ) => {
80+ ShopUtils . startPortOnePurchase (
7881 order ,
7982 ( ) => {
8083 queryClient . invalidateQueries ( ) ;
8184 queryClient . resetQueries ( ) ;
8285 onPaymentCompleted ?.( ) ;
8386 } ,
8487 ( response ) => alert ( "결제를 실패했습니다!\n" + response . error_msg ) ,
85- ( ) => { }
88+ ( ) => { }
8689 ) ;
8790 } ,
8891 onError : ( error ) =>
8992 alert (
9093 error . message ||
91- "결제 준비 중 문제가 발생했습니다,\n잠시 후 다시 시도해주세요."
94+ "결제 준비 중 문제가 발생했습니다,\n잠시 후 다시 시도해주세요."
9295 ) ,
9396 } ) ;
9497
@@ -97,7 +100,7 @@ export const ShopCartList: React.FC<{ onPaymentCompleted?: () => void }> = ({
97100
98101 const WrappedShopCartList : React . FC = ( ) => {
99102 // eslint-disable-next-line react-hooks/rules-of-hooks
100- const { data } = Shop . Hooks . useCart ( ) ;
103+ const { data } = ShopHooks . useCart ( ) ;
101104
102105 return ! data . hasOwnProperty ( "products" ) || data . products . length === 0 ? (
103106 < Typography variant = "body1" color = "error" >
@@ -106,7 +109,7 @@ export const ShopCartList: React.FC<{ onPaymentCompleted?: () => void }> = ({
106109 ) : (
107110 < >
108111 { data . products . map ( ( prodRel ) => (
109- < ShopCartItem
112+ < CartItem
110113 key = { prodRel . id }
111114 cartProdRel = { prodRel }
112115 disabled = { disabled }
@@ -117,7 +120,7 @@ export const ShopCartList: React.FC<{ onPaymentCompleted?: () => void }> = ({
117120 < Divider />
118121 < Typography variant = "h6" sx = { { textAlign : "end" } } >
119122 결제 금액:{ " " }
120- < Shop . Components . PriceDisplay price = { data . first_paid_price } />
123+ < CommonComponents . PriceDisplay price = { data . first_paid_price } />
121124 </ Typography >
122125 < Button
123126 variant = "contained"
@@ -131,20 +134,11 @@ export const ShopCartList: React.FC<{ onPaymentCompleted?: () => void }> = ({
131134 ) ;
132135 } ;
133136
134- return (
135- < >
136- < Typography variant = "h5" gutterBottom >
137- Cart List
138- </ Typography >
139- < Shop . Components . ShopSignInGuard >
140- < ErrorBoundary
141- fallback = { < div > 장바구니 정보를 불러오는 중 문제가 발생했습니다.</ div > }
142- >
143- < Suspense fallback = { < CircularProgress /> } >
144- < WrappedShopCartList />
145- </ Suspense >
146- </ ErrorBoundary >
147- </ Shop . Components . ShopSignInGuard >
148- </ >
149- ) ;
137+ return < CommonComponents . SignInGuard >
138+ < ErrorBoundary fallback = { < div > 장바구니 정보를 불러오는 중 문제가 발생했습니다.</ div > } >
139+ < Suspense fallback = { < CircularProgress /> } >
140+ < WrappedShopCartList />
141+ </ Suspense >
142+ </ ErrorBoundary >
143+ </ CommonComponents . SignInGuard > ;
150144} ;
0 commit comments