1
1
import { Box , Button , Container , Grid , Typography , useTheme } from '@mui/material' ;
2
- import { DataGrid , GridColDef , GridValueGetterParams } from '@mui/x-data-grid' ;
2
+ import { DataGrid , GridColDef , GridColTypeDef , GridValueGetterParams } from '@mui/x-data-grid' ;
3
3
import Header from '../../components/Header' ;
4
4
import FlexBetween from '../../components/FlexBetween' ;
5
+ import { useMemo } from 'react' ;
6
+
7
+ const classes = {
8
+ cartContainer : {
9
+ background : '#F9F1E7' ,
10
+ width : '393px' ,
11
+ height : '390px' ,
12
+ display : 'flex' ,
13
+ flexDirection : 'column' ,
14
+ justifyContent : 'space-around' ,
15
+ p : '1.5rem 2.5rem' ,
16
+ } ,
17
+ title : {
18
+ color : '#000' ,
19
+ fontSize : '32px' ,
20
+ fontStyle : 'normal' ,
21
+ fontWeight : '600' ,
22
+ lineHeight : 'normal' ,
23
+ } ,
24
+ subtitle : {
25
+ color : '#9F9F9F' ,
26
+ fontSize : '16px' ,
27
+ fontStyle : 'normal' ,
28
+ fontWeight : '400' ,
29
+ lineHeight : 'normal' ,
30
+ } ,
31
+ highlight : {
32
+ color : 'var(--primary, #B88E2F)' ,
33
+ fontSize : '20px' ,
34
+ fontStyle : 'normal' ,
35
+ fontWeight : '500' ,
36
+ lineHeight : 'normal' ,
37
+ } ,
38
+ orderBtn : {
39
+ border : '1px solid #000' ,
40
+ padding : '0.5rem 1.5rem' ,
41
+ color : '#000' ,
42
+ letterSpacing : '1.25px' ,
43
+ } ,
44
+ root : {
45
+ display : 'flex' ,
46
+ height : '100%' ,
47
+ } ,
48
+ dataGrid : {
49
+ flexGrow : 1 ,
50
+ } ,
51
+ } ;
5
52
6
53
const Cart = ( ) => {
7
- const classes = {
8
- cartContainer : {
9
- background : '#F9F1E7' ,
10
- width : '393px' ,
11
- height : '390px' ,
12
- display : 'flex' ,
13
- flexDirection : 'column' ,
14
- justifyContent : 'space-around' ,
15
- p : '1.5rem 2.5rem' ,
16
- } ,
17
- title : {
18
- color : '#000' ,
19
- fontSize : '32px' ,
20
- fontStyle : 'normal' ,
21
- fontWeight : '600' ,
22
- lineHeight : 'normal' ,
23
- } ,
24
- subtitle : {
25
- color : '#9F9F9F' ,
26
- fontSize : '16px' ,
27
- fontStyle : 'normal' ,
28
- fontWeight : '400' ,
29
- lineHeight : 'normal' ,
30
- } ,
31
- highlight : {
32
- color : 'var(--primary, #B88E2F)' ,
33
- fontSize : '20px' ,
34
- fontStyle : 'normal' ,
35
- fontWeight : '500' ,
36
- lineHeight : 'normal' ,
37
- } ,
38
- orderBtn : {
39
- border : '1px solid #000' ,
40
- padding : '0.5rem 1.5rem' ,
41
- color : '#000' ,
42
- letterSpacing : '1.25px' ,
43
- } ,
44
- } ;
54
+ const columns : GridColDef [ ] = useMemo (
55
+ ( ) => [
56
+ { field : 'product' , headerName : 'Product' , editable : false , sortable : false , width : 170 } ,
57
+ { field : 'price' , headerName : 'Price' , width : 120 } ,
58
+ { field : 'quantity' , headerName : 'Quantity' , width : 120 } ,
59
+ { field : 'subtotal' , headerName : 'Subtotal' , width : 140 } ,
60
+ ] ,
61
+ [ ]
62
+ ) ;
63
+
64
+ const rows = [
65
+ { id : 1 , product : 'super test' , price : 32 , quantity : 1 , subtotal : 32 } ,
66
+ { id : 1 , product : 'super test' , price : 32 , quantity : 1 , subtotal : 32 } ,
67
+ { id : 1 , product : 'super test' , price : 32 , quantity : 1 , subtotal : 32 } ,
68
+ { id : 1 , product : 'super test' , price : 32 , quantity : 1 , subtotal : 32 } ,
69
+ ] ;
70
+
45
71
return (
46
72
< >
47
73
< Header title = 'Cart' location = 'Home' location1 = 'Cart' />
@@ -51,7 +77,9 @@ const Cart = () => {
51
77
>
52
78
< Grid container >
53
79
{ /* LEFT */ }
54
- < Grid item xs = { 12 } md = { 6 } lg = { 8 } > </ Grid >
80
+ < Grid item xs = { 12 } md = { 6 } lg = { 8 } >
81
+ < DataGrid rows = { rows } columns = { columns } className = { classes . dataGrid } />
82
+ </ Grid >
55
83
< Grid item xs = { 12 } md = { 6 } lg = { 4 } >
56
84
{ /* RIGHT */ }
57
85
< Box sx = { classes . cartContainer } >
0 commit comments