11'use client' ;
22
33import CartItem from '@/components/CartItem/CartItem' ;
4+ import CartItemSkeleton from '@/components/CartItem/components/CartItemSkeleton' ;
45import CartItemController from '@/components/CartItemController/CartItemController' ;
6+ import OutOfStock from '@/components/common/OutOfStock' ;
7+ import PriceLabel from '@/components/common/PriceLabel' ;
58import { getFragmentData } from '@/graphql/types' ;
69import {
710 CartItemContentFragmentDoc ,
@@ -27,11 +30,8 @@ import {
2730import { useAtomValue } from 'jotai' ;
2831import { useTranslations } from 'next-intl' ;
2932import Image from 'next/image' ;
30- import Header from './components/Header' ;
31- import CartItemSkeleton from '@/components/CartItem/components/CartItemSkeleton' ;
32- import OutOfStock from '@/components/common/OutOfStock' ;
3333import CheckoutBox , { CheckoutBoxProps } from './components/CheckoutBox' ;
34- import PriceLabel from '@ /components/common/PriceLabel ' ;
34+ import Header from '. /components/Header ' ;
3535
3636const Page = ( ) => {
3737 const t = useTranslations ( ) ;
@@ -67,7 +67,22 @@ const Page = () => {
6767 < Stack spacing = { 2 } >
6868 < Card variant = "outlined" >
6969 < CardContent >
70- < Skeleton variant = "rectangular" height = { 400 } />
70+ < Stack spacing = { 1 } >
71+ { new Array ( 3 ) . fill ( 1 ) . map ( ( item , index ) => {
72+ return (
73+ < Stack
74+ key = { index }
75+ direction = "row"
76+ spacing = { 1 }
77+ justifyContent = "space-between"
78+ >
79+ < Skeleton variant = "text" width = { 80 } />
80+ < Skeleton variant = "text" width = { 80 } />
81+ </ Stack >
82+ ) ;
83+ } ) }
84+ < Skeleton variant = "rectangular" height = { 45 } />
85+ </ Stack >
7186 </ CardContent >
7287 </ Card >
7388 </ Stack >
@@ -141,7 +156,7 @@ const Page = () => {
141156 {
142157 key : (
143158 < Typography variant = "body2" color = "gray" sx = { { fontWeight : 600 } } >
144- قیمت کالاها ({ cart ?. contents ?. itemCount } )
159+ { t ( 'pages.cart.box.subTotal' ) } ({ cart ?. contents ?. itemCount } )
145160 </ Typography >
146161 ) ,
147162 value : (
@@ -157,7 +172,7 @@ const Page = () => {
157172 {
158173 key : (
159174 < Typography variant = "body2" sx = { { fontWeight : 600 } } >
160- جمع سبد خرید
175+ { t ( 'pages.cart.box.total' ) }
161176 </ Typography >
162177 ) ,
163178 value : (
@@ -172,7 +187,7 @@ const Page = () => {
172187 {
173188 key : (
174189 < Typography color = "error" variant = "body2" sx = { { fontWeight : 600 } } >
175- سود شما از خرید
190+ { t ( 'pages.cart.box.yourProfit' ) }
176191 </ Typography >
177192 ) ,
178193 value : (
@@ -189,7 +204,7 @@ const Page = () => {
189204
190205 return (
191206 < >
192- < Grid container spacing = { 2 } >
207+ < Grid container spacing = { 2 } position = "relative" >
193208 < Grid item lg = { 9 } md = { 6 } xs = { 12 } >
194209 < Card variant = "outlined" >
195210 < Header />
@@ -238,15 +253,37 @@ const Page = () => {
238253 } }
239254 />
240255 ) }
256+
241257 { ! isOutOfStock && (
242- < PriceLabel
243- value = { _item . total }
244- TypographyProps = { {
245- sx : {
246- fontWeight : 600 ,
247- } ,
248- } }
249- />
258+ < Stack justifyContent = "end" >
259+ { ! ! _item . totalOnSaleDiscount && (
260+ < PriceLabel
261+ value = { _item . totalOnSaleDiscount }
262+ TypographyProps = { {
263+ fontWeight : 600 ,
264+ color : 'error' ,
265+ } }
266+ suffix = {
267+ < Typography
268+ variant = "caption"
269+ color = "error"
270+ fontWeight = { 600 }
271+ >
272+ { t ( 'discounts.off' ) }
273+ </ Typography >
274+ }
275+ />
276+ ) }
277+
278+ < PriceLabel
279+ value = { _item . total }
280+ TypographyProps = { {
281+ sx : {
282+ fontWeight : 600 ,
283+ } ,
284+ } }
285+ />
286+ </ Stack >
250287 ) }
251288 </ Stack >
252289 { ! isLast && < Divider /> }
@@ -260,7 +297,14 @@ const Page = () => {
260297 </ Grid >
261298
262299 < Grid item lg = { 3 } md = { 6 } xs = { 12 } >
263- < Stack spacing = { 2 } >
300+ < Stack
301+ spacing = { 2 }
302+ sx = { {
303+ position : 'sticky' ,
304+ top : 196 ,
305+ zIndex : 1299 ,
306+ } }
307+ >
264308 < Card variant = "outlined" >
265309 < CardContent >
266310 < CheckoutBox items = { checkoutBoxItems } />
0 commit comments