瀏覽代碼

Shipping Done

cart-api-guide
azri 1 周之前
父節點
當前提交
7ea9df2982
共有 3 個檔案被更改,包括 188 行新增8 行删除
  1. 168
    0
      src/components/ShippingForm/ShippingForm.jsx
  2. 1
    0
      src/components/ShippingForm/index.js
  3. 19
    8
      src/pages/Checkout.jsx

+ 168
- 0
src/components/ShippingForm/ShippingForm.jsx 查看文件

@@ -0,0 +1,168 @@
1
+import React, { useState } from 'react';
2
+import {
3
+  Box,
4
+  TextField,
5
+  Button,
6
+  Typography,
7
+  MenuItem,
8
+  RadioGroup,
9
+  FormControlLabel,
10
+  Radio,
11
+} from '@mui/material';
12
+import Grid from '@mui/material/Grid2';
13
+
14
+const ShippingForm = () => {
15
+  const [shippingMethod, setShippingMethod] = useState('COD');
16
+
17
+  const handleSubmit = (e) => {
18
+    e.preventDefault();
19
+    // Handle form submission logic
20
+    console.log('Form submitted');
21
+  };
22
+
23
+  const FieldContainer = ({ label, children }) => (
24
+    <Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
25
+      <Typography variant="body1" sx={{ fontWeight: 500, minWidth: 120 }}>
26
+        {label}
27
+      </Typography>
28
+      {children}
29
+    </Box>
30
+  );
31
+
32
+  return (
33
+    <Box
34
+      component="form"
35
+      onSubmit={handleSubmit}
36
+      sx={{
37
+        width: '100%',
38
+        mx: 'auto',
39
+        mt: 4,
40
+        display: 'flex',
41
+        flexDirection: 'column',
42
+        gap: 3,
43
+      }}
44
+    >
45
+      <Grid container>
46
+
47
+        <Grid item size={6} sx={{ gap: 3, display: 'flex', flexDirection: 'column' }}>
48
+          <FieldContainer label="Title">
49
+            <TextField variant="outlined" fullWidth required />
50
+          </FieldContainer>
51
+
52
+          <FieldContainer label="First Name">
53
+            <TextField variant="outlined" fullWidth required />
54
+          </FieldContainer>
55
+
56
+          <FieldContainer label="Last Name">
57
+            <TextField variant="outlined" fullWidth required />
58
+          </FieldContainer>
59
+
60
+          <FieldContainer label="Country">
61
+            <TextField select variant="outlined" fullWidth required>
62
+              <MenuItem value="USA">USA</MenuItem>
63
+              <MenuItem value="Canada">Canada</MenuItem>
64
+              <MenuItem value="UK">UK</MenuItem>
65
+              {/* Add more countries as needed */}
66
+            </TextField>
67
+          </FieldContainer>
68
+        </Grid>
69
+
70
+        <Grid item size={6} sx={{ gap: 3, display: 'flex', flexDirection: 'column', px: 4, height: "100%" }}>
71
+
72
+          <Grid
73
+            container
74
+            spacing={2}
75
+            sx={{ position: 'relative', width: '100%', backgroundColor: '#F7FBFF', textAlign: 'center' }}
76
+          >
77
+            {/* First Section */}
78
+            <Grid
79
+              item
80
+              size={12}
81
+              sx={{ px: 5, py: 3, borderBottom: '1px solid #ddd', mx: "auto" }}
82
+            >
83
+              <Typography variant="h6" sx={{ fontWeight: 500 }}>
84
+                SHIPPING RESTRICTIONS AND DUTIES MAY APPLY
85
+              </Typography>
86
+            </Grid>
87
+
88
+            {/* Second Section */}
89
+            <Grid item size={12} sx={{ px: 5, py: 3, mx: "auto" }}>
90
+              <Typography variant="h6" sx={{ fontWeight: 500 }}>
91
+                NEED HELP?
92
+              </Typography>
93
+              <Typography variant="body2" sx={{ mb: 1 }}>CALL US: +44 (0)10 2345 6789</Typography>
94
+              <Typography variant="body2" sx={{ mb: 1 }}>EMAIL CUSTOMER CARE | SHIPPING INFORMATION</Typography>
95
+              <Typography variant="body2" sx={{ mb: 1 }}>RETURNS & EXCHANGES</Typography>
96
+            </Grid>
97
+          </Grid>
98
+
99
+        </Grid>
100
+
101
+      </Grid>
102
+
103
+      <FieldContainer label="Address Line 1">
104
+        <TextField variant="outlined" fullWidth required multiline rows={3} />
105
+      </FieldContainer>
106
+
107
+      <FieldContainer label="Address Line 2">
108
+        <TextField variant="outlined" fullWidth multiline rows={3} />
109
+      </FieldContainer>
110
+
111
+      <FieldContainer label="City">
112
+        <TextField variant="outlined" fullWidth required />
113
+      </FieldContainer>
114
+
115
+      <FieldContainer label="Country/Province">
116
+        <TextField variant="outlined" fullWidth required />
117
+      </FieldContainer>
118
+
119
+      <FieldContainer label="Postcode/Zip">
120
+        <TextField variant="outlined" fullWidth required />
121
+      </FieldContainer>
122
+
123
+      <FieldContainer label="Telephone">
124
+        <TextField variant="outlined" fullWidth required />
125
+      </FieldContainer>
126
+
127
+      <FieldContainer label="Mobile">
128
+        <TextField variant="outlined" fullWidth />
129
+      </FieldContainer>
130
+
131
+      <FieldContainer label="Shipping Method">
132
+        <RadioGroup
133
+          value={shippingMethod}
134
+          onChange={(e) => setShippingMethod(e.target.value)}
135
+        >
136
+          <FormControlLabel
137
+            value="COD"
138
+            control={<Radio />}
139
+            label="Cash on Delivery (COD)"
140
+          />
141
+          <FormControlLabel
142
+            value="Postage"
143
+            control={<Radio />}
144
+            label="Postage"
145
+          />
146
+        </RadioGroup>
147
+      </FieldContainer>
148
+
149
+      <Button
150
+        variant="contained"
151
+        color="common.black"
152
+        onClick={() => { window.location.href = "/checkout" }}
153
+        sx={{
154
+          backgroundColor: (theme) => theme.palette.common.black,
155
+          color: "white",
156
+          textTransform: "none",
157
+          px: 8,
158
+          py: 2,
159
+          width: "fit-content",
160
+          "&:hover": {
161
+            backgroundColor: (theme) => theme.palette.grey[900],
162
+          },
163
+        }}>SIGN IN</Button>
164
+    </Box>
165
+  );
166
+};
167
+
168
+export default ShippingForm;

+ 1
- 0
src/components/ShippingForm/index.js 查看文件

@@ -0,0 +1 @@
1
+export { default } from './ShippingForm'

+ 19
- 8
src/pages/Checkout.jsx 查看文件

@@ -1,10 +1,10 @@
1
-import React, {useState} from 'react'
1
+import React, { useState } from 'react'
2 2
 import { Box, Button, IconButton, TextField, Typography } from '@mui/material'
3 3
 import SocialMedia from '../components/SocialMedia'
4 4
 import Feature from '../components/Feature'
5 5
 import LoginForm from '../components/LoginForm'
6 6
 import SignUpForm from '../components/SignUpForm'
7
-
7
+import ShippingForm from '../components/ShippingForm'
8 8
 
9 9
 import Grid from '@mui/material/Grid2';
10 10
 
@@ -36,10 +36,10 @@ const Checkout = () => {
36 36
 
37 37
         <Grid item size={12} sx={{ borderTop: "1px solid rgba(0,0,0,0.2)", borderBottom: "1px solid rgba(0,0,0,0.2)", display: "flex", justifyContent: "space-evenly", py: 1 }}>
38 38
 
39
-          <Typography variant="body1" onClick={()=>{setContent(0)}} sx={{cursor:"pointer", color:(content == 0) ? "#93ABC7" : "black" }}>Login</Typography> 
40
-          <Typography variant="body1" onClick={()=>{setContent(1)}} sx={{cursor:"pointer", color:(content == 1) ? "#93ABC7" : "black" }}>Shipping</Typography> 
41
-          <Typography variant="body1" onClick={()=>{setContent(2)}} sx={{cursor:"pointer", color:(content == 2) ? "#93ABC7" : "black" }}>Billing</Typography> 
42
-          <Typography variant="body1" onClick={()=>{setContent(3)}} sx={{cursor:"pointer", color:(content == 3) ? "#93ABC7" : "black" }}>Confirmation</Typography>
39
+          <Typography variant="body1" onClick={() => { setContent(0) }} sx={{ cursor: "pointer", color: (content == 0) ? "#93ABC7" : "black" }}>Login</Typography>
40
+          <Typography variant="body1" onClick={() => { setContent(1) }} sx={{ cursor: "pointer", color: (content == 1) ? "#93ABC7" : "black" }}>Shipping</Typography>
41
+          <Typography variant="body1" onClick={() => { setContent(2) }} sx={{ cursor: "pointer", color: (content == 2) ? "#93ABC7" : "black" }}>Billing</Typography>
42
+          <Typography variant="body1" onClick={() => { setContent(3) }} sx={{ cursor: "pointer", color: (content == 3) ? "#93ABC7" : "black" }}>Confirmation</Typography>
43 43
 
44 44
         </Grid>
45 45
 
@@ -64,7 +64,7 @@ const Checkout = () => {
64 64
 
65 65
           <Typography variant="body2">Make purchases faster using previously saved details. Track previous orders and easily request returns from the website.</Typography>
66 66
 
67
-          <LoginForm/>
67
+          <LoginForm />
68 68
 
69 69
         </Grid>
70 70
 
@@ -72,7 +72,18 @@ const Checkout = () => {
72 72
 
73 73
           <Typography variant="body2">You’ll need an account to purchase watches, track and review orders, and manage your personal details.</Typography>
74 74
 
75
-          <SignUpForm/>
75
+          <SignUpForm />
76
+
77
+        </Grid>
78
+
79
+
80
+      </Grid>}
81
+
82
+      {(content == 1) && <Grid container sx={{ mb: 5 }}>
83
+
84
+        <Grid item size={12}>
85
+
86
+          <ShippingForm/>
76 87
 
77 88
         </Grid>
78 89
 

Loading…
取消
儲存