1- import { FormControl , InputLabel , MenuItem , Select , TextField , Tooltip } from "@mui/material" ;
1+ import { CircularProgress , FormControl , InputLabel , MenuItem , Select , TextField , Tooltip } from "@mui/material" ;
2+ import { Suspense } from "@suspensive/react" ;
23import * as React from "react" ;
34import * as R from "remeda" ;
45
56import { PriceDisplay } from "./price_display" ;
7+ import ShopHooks from "../../hooks" ;
68import ShopSchemas from "../../schemas" ;
79import ShopAPIUtil from "../../utils" ;
810
@@ -25,12 +27,13 @@ type SimplifiedOption = Pick<ShopSchemas.Option, "id" | "name" | "additional_pri
2527const isFilledString = ( str : unknown ) : str is string => R . isString ( str ) && ! R . isEmpty ( str ) ;
2628
2729const SelectableOptionGroupInput : React . FC < {
30+ language : "ko" | "en" ;
2831 optionGroup : SelectableOptionGroupType ;
2932 options : SimplifiedOption [ ] ;
3033 defaultValue ?: string ;
3134 disabled ?: boolean ;
3235 disabledReason ?: string ;
33- } > = ( { optionGroup, options, defaultValue, disabled, disabledReason } ) => {
36+ } > = ( { language , optionGroup, options, defaultValue, disabled, disabledReason } ) => {
3437 const optionElements = options . map ( ( option ) => {
3538 const isOptionOutOfStock = R . isNumber ( option . leftover_stock ) && option . leftover_stock <= 0 ;
3639
@@ -43,7 +46,7 @@ const SelectableOptionGroupInput: React.FC<{
4346 [ +< PriceDisplay price = { option . additional_price } /> ]
4447 </ >
4548 ) }
46- { isOptionOutOfStock && < > (품절 )</ > }
49+ { isOptionOutOfStock && < > ({ language === "ko" ? "품절" : "Out of stock" } )</ > }
4750 </ MenuItem >
4851 ) ;
4952 } ) ;
@@ -93,13 +96,14 @@ const CustomResponseOptionGroupInput: React.FC<{
9396} ;
9497
9598export const OptionGroupInput : React . FC < {
99+ language ?: "ko" | "en" ;
96100 optionGroup : OptionGroupType ;
97101 options : SimplifiedOption [ ] ;
98102
99103 defaultValue ?: string ;
100104 disabled ?: boolean ;
101105 disabledReason ?: string ;
102- } > = ( { optionGroup, options, defaultValue, disabled, disabledReason } ) =>
106+ } > = ( { language , optionGroup, options, defaultValue, disabled, disabledReason } ) =>
103107 optionGroup . is_custom_response ? (
104108 < CustomResponseOptionGroupInput
105109 optionGroup = { optionGroup }
@@ -109,6 +113,7 @@ export const OptionGroupInput: React.FC<{
109113 />
110114 ) : (
111115 < SelectableOptionGroupInput
116+ language = { language || "ko" }
112117 optionGroup = { optionGroup }
113118 options = { options }
114119 defaultValue = { defaultValue }
@@ -121,7 +126,8 @@ export const OrderProductRelationOptionInput: React.FC<{
121126 optionRel : ShopSchemas . OrderProductItem [ "options" ] [ number ] ;
122127 disabled ?: boolean ;
123128 disabledReason ?: string ;
124- } > = ( { optionRel, disabled, disabledReason } ) => {
129+ } > = Suspense . with ( { fallback : < CircularProgress /> } , ( { optionRel, disabled, disabledReason } ) => {
130+ const { language } = ShopHooks . useShopContext ( ) ;
125131 let defaultValue : string | null = null ;
126132 let guessedDisabledReason : string | undefined = undefined ;
127133 let dummyOptions : {
@@ -134,7 +140,10 @@ export const OrderProductRelationOptionInput: React.FC<{
134140 // type hinting을 위해 if문을 사용함
135141 if ( optionRel . product_option_group . is_custom_response === false && R . isNonNull ( optionRel . product_option ) ) {
136142 defaultValue = optionRel . product_option . id ;
137- guessedDisabledReason = "추가 비용이 발생하는 옵션은 수정할 수 없어요." ;
143+ guessedDisabledReason =
144+ language === "ko"
145+ ? "추가 비용이 발생하는 옵션은 수정할 수 없어요."
146+ : "You cannot modify options that incur additional costs." ;
138147 dummyOptions = [
139148 {
140149 id : optionRel . product_option . id ,
@@ -157,4 +166,4 @@ export const OrderProductRelationOptionInput: React.FC<{
157166 disabledReason = { disabledReason || guessedDisabledReason }
158167 />
159168 ) ;
160- } ;
169+ } ) ;
0 commit comments