Skip to content

Commit 74cc576

Browse files
committed
chore: remove unnecessary features
1 parent 257a561 commit 74cc576

File tree

5 files changed

+24
-41
lines changed

5 files changed

+24
-41
lines changed

src/app/[locale]/(main)/(container)/products/[...params]/components/BuyBox.tsx

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { useProductContext } from '@/app/[locale]/(main)/(container)/products/[...params]/hooks/useProductContext';
44
import CartItemController from '@/components/CartItemController/CartItemController';
55
import useNewDialog from '@/components/Dialog/hooks/useNewDialog';
6+
import { DesktopView, MobileView } from '@/components/ResponsiveDesign';
67
import ButtonWithLoading from '@/components/common/ButtonWithLoading';
78
import DiscountPercentage from '@/components/common/DiscountPercentage';
89
import OldPrice from '@/components/common/OldPrice';
@@ -15,35 +16,21 @@ import {
1516
StockStatusEnum,
1617
} from '@/graphql/types/graphql';
1718
import useAddOrUpdateCartItem from '@/hooks/useAddOrUpdateCartItem';
18-
import { useAppContext } from '@/hooks/useAppContext';
1919
import useCartUtils from '@/hooks/useCartUtils';
2020
import { Link } from '@/navigation';
2121
import { getMaxOfRangePrice } from '@/utils/price';
22-
import {
23-
AccountBalanceWalletOutlined,
24-
LocalShippingOutlined,
25-
} from '@mui/icons-material';
2622
import { Box, Collapse, Divider, Stack, Typography } from '@mui/material';
2723
import List from '@mui/material/List';
2824
import ListItem from '@mui/material/ListItem';
2925
import ListItemIcon from '@mui/material/ListItemIcon';
3026
import ListItemText from '@mui/material/ListItemText';
3127
import { useTranslations } from 'next-intl';
3228
import { useParams } from 'next/navigation';
33-
import { FC } from 'react';
29+
import { FC, Fragment, ReactNode } from 'react';
3430
import AddToCartDialog from './AddToCartDialog';
3531
import MobileBuyBox from './MobileBuyBox';
3632

37-
const listItems = [
38-
{
39-
text: 'ارسال از دو روز کاری دیگر',
40-
icon: <LocalShippingOutlined />,
41-
},
42-
{
43-
text: '5% بازگشت به اعتبار',
44-
icon: <AccountBalanceWalletOutlined />,
45-
},
46-
];
33+
const features: { id: string; text: string; icon: ReactNode }[] = [];
4734

4835
export interface BuyBoxProps {
4936
product: Extract<
@@ -55,7 +42,6 @@ export interface BuyBoxProps {
5542
const BuyBox: FC<BuyBoxProps> = ({ product }) => {
5643
const { params } = useParams();
5744

58-
const { isMobile } = useAppContext();
5945
const t = useTranslations();
6046

6147
const { selectedVariantId } = useProductContext();
@@ -219,17 +205,12 @@ const BuyBox: FC<BuyBoxProps> = ({ product }) => {
219205
flexDirection: 'column',
220206
}}
221207
>
222-
{!!listItems?.length && (
208+
{!!features?.length && (
223209
<List>
224-
{listItems.map((item) => {
210+
{features.map((item, index) => {
225211
return (
226-
<>
227-
<ListItem
228-
disablePadding
229-
sx={{
230-
py: 1,
231-
}}
232-
>
212+
<Fragment key={item.id}>
213+
<ListItem>
233214
<ListItemIcon
234215
sx={{
235216
minWidth: 0,
@@ -246,22 +227,24 @@ const BuyBox: FC<BuyBoxProps> = ({ product }) => {
246227
}}
247228
/>
248229
</ListItem>
249-
<Divider />
250-
</>
230+
{index !== features.length - 1 && <Divider />}
231+
</Fragment>
251232
);
252233
})}
253234
</List>
254235
)}
255236

256-
{isMobile && (
237+
<MobileView>
257238
<MobileBuyBox>
258239
<Box width="60%">{controllerSection}</Box>
259240
{priceSection}
260241
</MobileBuyBox>
261-
)}
242+
</MobileView>
262243

263-
{!isMobile && priceSection}
264-
{!isMobile && controllerSection}
244+
<DesktopView>
245+
{priceSection}
246+
{controllerSection}
247+
</DesktopView>
265248
</Box>
266249
)}
267250
</>

src/app/[locale]/(main)/(container)/products/[...params]/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const getProduct = async ({ id }: { id: number }) => {
4141
variables: {
4242
id,
4343
},
44-
fetchPolicy: 'no-cache',
4544
});
4645
return data.product;
4746
};
@@ -103,7 +102,11 @@ const Page: FC<PageProps> = async ({ params: { params } }) => {
103102
</Grid>
104103
<Grid item md={3} xs={12}>
105104
<Card variant="outlined">
106-
<CardContent>
105+
<CardContent
106+
sx={{
107+
paddingBottom: '16px !important',
108+
}}
109+
>
107110
<BuyBox product={product} />
108111
</CardContent>
109112
</Card>

src/app/[locale]/(main)/(container)/profile/orders/[id]/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const Page: FC<PageProps> = (props) => {
3131
variables: {
3232
id: +id,
3333
},
34-
fetchPolicy: 'no-cache',
3534
});
3635

3736
const t = useTranslations();

src/components/KeyValueViewer/components/Item.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '@mui/material';
1010
import { FC } from 'react';
1111
import { IKeyValueItem } from '../types';
12+
import { useAppContext } from '@/hooks/useAppContext';
1213

1314
export type ItemProps = ListItemProps & {
1415
index: number;
@@ -34,6 +35,8 @@ const Item: FC<ItemProps> = ({ item, index, ...props }) => {
3435

3536
const isOdd = index % 2 === 1;
3637

38+
const { isMobile } = useAppContext();
39+
3740
return (
3841
<ListItem
3942
sx={{
@@ -52,7 +55,7 @@ const Item: FC<ItemProps> = ({ item, index, ...props }) => {
5255
<Box
5356
sx={{
5457
display: 'grid',
55-
gridTemplateColumns: '256px 1fr',
58+
gridTemplateColumns: `${isMobile ? 105 : 210}px 1fr`,
5659
}}
5760
>
5861
<Typography

src/graphql/clients/serverSideClient.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,5 @@ export const { getClient } = registerApolloClient(() => {
1919
cache: new InMemoryCache(),
2020
connectToDevTools: true,
2121
link: from([httpLink]),
22-
defaultOptions: {
23-
query: {
24-
fetchPolicy: 'no-cache',
25-
},
26-
},
2722
});
2823
});

0 commit comments

Comments
 (0)