@@ -35,6 +35,7 @@ import DiscountPercentage from '../../../../../../../components/common/DiscountP
3535import OldPrice from '../../../../../../../components/common/OldPrice' ;
3636import PriceLabel from '../../../../../../../components/common/PriceLabel' ;
3737import AddToCartDialog from './AddToCartDialog' ;
38+ import MobileBuyBox from './MobileBuyBox' ;
3839
3940const listItems = [
4041 {
@@ -117,6 +118,89 @@ const BuyBox: FC<BuyBoxProps> = ({ product }) => {
117118 ( variant === null && product ?. discountPercentage ) ||
118119 ( variant !== null && variant ?. discountPercentage ) ;
119120
121+ const priceSection = (
122+ < Box
123+ sx = { {
124+ display : 'flex' ,
125+ flexDirection : 'column' ,
126+ alignItems : 'end' ,
127+ gap : 1 ,
128+ } }
129+ >
130+ < Box
131+ sx = { {
132+ display : 'flex' ,
133+ gap : 0.5 ,
134+ } }
135+ >
136+ { ! ! discountPercentage && (
137+ < >
138+ < OldPrice
139+ value = { variant ? variant ?. regularPrice : product . regularPrice }
140+ TypographyProps = { {
141+ variant : 'body1' ,
142+ } }
143+ />
144+
145+ < DiscountPercentage
146+ value = {
147+ variant
148+ ? variant . discountPercentage
149+ : product . discountPercentage
150+ }
151+ />
152+ </ >
153+ ) }
154+ </ Box >
155+ < PriceLabel
156+ TypographyProps = { {
157+ variant : 'h6' ,
158+ fontWeight : 600 ,
159+ } }
160+ value = { variant ? variant . price : product . price }
161+ />
162+ </ Box >
163+ ) ;
164+
165+ const controllerSection = (
166+ < Box >
167+ { /* TODO: Handle out of stock state */ }
168+ { ! itemInCart && (
169+ < ButtonWithLoading
170+ isLoading = { addOrUpdateCartItemLoading }
171+ fullWidth
172+ variant = "contained"
173+ color = "primary"
174+ size = "large"
175+ onClick = { handleClickOnAdd }
176+ sx = { { minHeight : height } }
177+ >
178+ { t ( 'buttons.addToCart' ) }
179+ </ ButtonWithLoading >
180+ ) }
181+
182+ { itemInCart && (
183+ < >
184+ < Box height = { height } >
185+ < CartItemController item = { itemInCart } />
186+ </ Box >
187+ < Collapse appear in = { true } >
188+ < Stack direction = "row" justifyContent = "center" spacing = { 1 } >
189+ < Typography variant = "body2" >
190+ { t ( 'pages.product.buyBox.inYourCart' ) }
191+ </ Typography >
192+ < Link href = "/cart" >
193+ < Typography color = "primary" variant = "body2" >
194+ { t ( 'pages.product.buyBox.viewCart' ) }
195+ </ Typography >
196+ </ Link >
197+ </ Stack >
198+ </ Collapse >
199+ </ >
200+ ) }
201+ </ Box >
202+ ) ;
203+
120204 return (
121205 < >
122206 < AddToCartDialog
@@ -174,86 +258,15 @@ const BuyBox: FC<BuyBoxProps> = ({ product }) => {
174258 } ) }
175259 </ List >
176260
177- < Box
178- sx = { {
179- display : 'flex' ,
180- flexDirection : 'column' ,
181- alignItems : 'end' ,
182- gap : 1 ,
183- } }
184- >
185- < Box
186- sx = { {
187- display : 'flex' ,
188- gap : 0.5 ,
189- } }
190- >
191- { ! ! discountPercentage && (
192- < >
193- < OldPrice
194- value = {
195- variant ? variant ?. regularPrice : product . regularPrice
196- }
197- TypographyProps = { {
198- variant : 'body1' ,
199- } }
200- />
261+ { isMobile && (
262+ < MobileBuyBox >
263+ < Box width = "55%" > { controllerSection } </ Box >
264+ { priceSection }
265+ </ MobileBuyBox >
266+ ) }
201267
202- < DiscountPercentage
203- value = {
204- variant
205- ? variant . discountPercentage
206- : product . discountPercentage
207- }
208- />
209- </ >
210- ) }
211- </ Box >
212- < PriceLabel
213- TypographyProps = { {
214- variant : 'h6' ,
215- fontWeight : 600 ,
216- } }
217- value = { variant ? variant . price : product . price }
218- />
219- </ Box >
220-
221- < Box >
222- { /* TODO: Handle out of stock state */ }
223- { ! itemInCart && (
224- < ButtonWithLoading
225- isLoading = { addOrUpdateCartItemLoading }
226- fullWidth
227- variant = "contained"
228- color = "primary"
229- size = "large"
230- onClick = { handleClickOnAdd }
231- sx = { { minHeight : height } }
232- >
233- { t ( 'buttons.addToCart' ) }
234- </ ButtonWithLoading >
235- ) }
236-
237- { itemInCart && (
238- < >
239- < Box height = { height } >
240- < CartItemController item = { itemInCart } />
241- </ Box >
242- < Collapse appear in = { true } >
243- < Stack direction = "row" justifyContent = "center" spacing = { 1 } >
244- < Typography variant = "body2" >
245- { t ( 'pages.product.buyBox.inYourCart' ) }
246- </ Typography >
247- < Link href = "/cart" >
248- < Typography color = "primary" variant = "body2" >
249- { t ( 'pages.product.buyBox.viewCart' ) }
250- </ Typography >
251- </ Link >
252- </ Stack >
253- </ Collapse >
254- </ >
255- ) }
256- </ Box >
268+ { ! isMobile && priceSection }
269+ { ! isMobile && controllerSection }
257270 </ Box >
258271 ) }
259272 </ >
0 commit comments