umwd-components 0.1.698 → 0.1.699

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,256 +0,0 @@
1
- "use client";
2
-
3
- import React from "react";
4
-
5
- import Paper from "@mui/material/Paper";
6
- import Stack from "@mui/material/Stack";
7
- import Box from "@mui/material/Box";
8
- import Typography from "@mui/material/Typography";
9
- import Button from "@mui/material/Button";
10
- import Grid from "@mui/material/Grid";
11
- import Table from "@mui/material/Table";
12
- import TableBody from "@mui/material/TableBody";
13
- import TableCell from "@mui/material/TableCell";
14
- import TableHead from "@mui/material/TableHead";
15
- import TableRow from "@mui/material/TableRow";
16
-
17
- import { SxProps, Theme } from "@mui/material/styles";
18
- import PersonIcon from "@mui/icons-material/Person";
19
- import EmailIcon from "@mui/icons-material/Email";
20
- import PhoneIcon from "@mui/icons-material/Phone";
21
- import Address from "../../common/Address";
22
- import BusinessCredentials from "./BusinessCredentials";
23
- import { StyledLink } from "../../../components/StyledLink";
24
- import { CustomerProfileProps } from "../../../types/e-commerce/customer/types";
25
-
26
- import { Alert } from "@mui/material";
27
-
28
- import { usePathname } from "next/navigation";
29
-
30
- interface CustomerProfileDisplayProps extends CustomerProfileProps {
31
- maxWidth: "xs" | "sm" | "md" | "lg" | "xl" | false | undefined;
32
- sx?: SxProps<Theme>;
33
- editProfileUrl?: string;
34
- completeEnough?: boolean;
35
- }
36
-
37
- export default function CustomerProfileDisplay({
38
- data,
39
- }: {
40
- readonly data: CustomerProfileDisplayProps;
41
- }) {
42
- const {
43
- first_name,
44
- last_name,
45
- email,
46
- phone,
47
- company_address,
48
- billing_address,
49
- delivery_address,
50
- business_credentials,
51
- editProfileUrl = "/user/profile/edit",
52
- completeEnough = false,
53
- orders,
54
- returns,
55
- } = data;
56
-
57
- if (!data) {
58
- return (
59
- <Stack spacing={2}>
60
- <Typography>Customer profile not available</Typography>
61
- </Stack>
62
- );
63
- }
64
-
65
- console.log("CustomerProfileDisplay", data);
66
-
67
- const pathname = usePathname();
68
- const isCustomer = pathname.includes("/user/");
69
-
70
- return (
71
- <Grid container sx={{ width: "100%" }} spacing={2}>
72
- {isCustomer && (
73
- <Grid item xs={12}>
74
- {!Boolean(completeEnough) ? (
75
- <Alert
76
- severity="warning"
77
- action={
78
- <StyledLink href={editProfileUrl} target="_self">
79
- <Button variant="contained">complete profile</Button>
80
- </StyledLink>
81
- }
82
- >
83
- After completion of your profile you can enjoy all the benefits of
84
- your services.
85
- </Alert>
86
- ) : (
87
- <Stack direction={"row"} justifyContent={"flex-end"}>
88
- <StyledLink href={editProfileUrl} target="_self">
89
- <Button variant="contained">edit profile</Button>
90
- </StyledLink>
91
- </Stack>
92
- )}
93
- </Grid>
94
- )}
95
-
96
- <Grid item xs={12}>
97
- {business_credentials ? (
98
- <BusinessCredentials data={business_credentials} />
99
- ) : (
100
- <Typography>Business credentials not available</Typography>
101
- )}
102
- </Grid>
103
-
104
- <Grid item xs={12}>
105
- <Stack spacing={2} direction="row">
106
- <PersonIcon />
107
- <Box>
108
- <Typography variant="body1" component="p">
109
- {first_name} {last_name} {!first_name && !last_name && "N/A"}
110
- </Typography>
111
- </Box>
112
- </Stack>
113
- <Stack spacing={2} direction="row">
114
- <EmailIcon />
115
- <Box>
116
- <Typography variant="body1" component="p">
117
- {email} {!email && "N/A"}
118
- </Typography>
119
- </Box>
120
- </Stack>
121
- <Stack spacing={2} direction="row">
122
- <PhoneIcon />
123
- <Box>
124
- <Typography variant="body1" component="p">
125
- {phone} {!phone && "N/A"}
126
- </Typography>
127
- </Box>
128
- </Stack>
129
- </Grid>
130
-
131
- {company_address ? (
132
- <Grid item xs={12} md={4}>
133
- <Typography variant="h6">Company Address</Typography>
134
- <Address data={{ ...company_address }} />
135
- </Grid>
136
- ) : (
137
- <Grid item xs={12} md={4}>
138
- <Typography>Company address not available</Typography>
139
- </Grid>
140
- )}
141
- {delivery_address ? (
142
- <Grid item xs={12} md={4}>
143
- <Typography variant="h6">Delivery Address</Typography>
144
- <Address data={{ ...delivery_address }} />
145
- </Grid>
146
- ) : (
147
- <Grid item xs={12} md={4}>
148
- <Typography>Delivery address not available</Typography>
149
- </Grid>
150
- )}
151
- {billing_address ? (
152
- <Grid item xs={12} md={4}>
153
- <Typography variant="h6">Billing Address</Typography>
154
- <Address data={{ ...billing_address }} />
155
- </Grid>
156
- ) : (
157
- <Grid item xs={12} md={4}>
158
- <Typography>Billing address not available</Typography>
159
- </Grid>
160
- )}
161
-
162
- <Grid item xs={12}>
163
- <Typography variant="h6" gutterBottom>
164
- Orders
165
- </Typography>
166
- <Paper>
167
- {orders && orders.data && orders.data.length > 0 ? (
168
- <Table>
169
- <TableHead>
170
- <TableRow>
171
- <TableCell>Order Number</TableCell>
172
- <TableCell>Date</TableCell>
173
- <TableCell>Status</TableCell>
174
- <TableCell align="right">Total</TableCell>
175
- <TableCell align="right">Actions</TableCell>
176
- </TableRow>
177
- </TableHead>
178
- <TableBody>
179
- {orders.data.map((order, index) => (
180
- <TableRow key={index}>
181
- <TableCell>{order.opo_number}</TableCell>
182
- <TableCell>
183
- {new Date(order.order_date).toLocaleDateString()}
184
- </TableCell>
185
- <TableCell>{order.status}</TableCell>
186
- <TableCell align="right">
187
- {order.total_incl_vat} {order.order_currency}
188
- </TableCell>
189
- <TableCell align="right">
190
- <StyledLink href={`/orders/${order.uuid}`} target="_self">
191
- <Button variant="contained" size="small">
192
- View
193
- </Button>
194
- </StyledLink>
195
- </TableCell>
196
- </TableRow>
197
- ))}
198
- </TableBody>
199
- </Table>
200
- ) : (
201
- <Box p={2}>
202
- <Typography>You have no orders.</Typography>
203
- </Box>
204
- )}
205
- </Paper>
206
- </Grid>
207
-
208
- <Grid item xs={12}>
209
- <Typography variant="h6" gutterBottom>
210
- Returns
211
- </Typography>
212
- <Paper>
213
- {returns && returns.data && returns.data.length > 0 ? (
214
- <Table>
215
- <TableHead>
216
- <TableRow>
217
- <TableCell>Return Number</TableCell>
218
- <TableCell>RMA Number</TableCell>
219
- <TableCell>Date</TableCell>
220
- <TableCell>Status</TableCell>
221
- <TableCell align="right">Actions</TableCell>
222
- </TableRow>
223
- </TableHead>
224
- <TableBody>
225
- {returns.data.map((returnItem, index) => (
226
- <TableRow key={index}>
227
- <TableCell>{returnItem.return_number}</TableCell>
228
- <TableCell>{returnItem.rma_number}</TableCell>
229
- <TableCell>
230
- {new Date(returnItem.return_date).toLocaleDateString()}
231
- </TableCell>
232
- <TableCell>{returnItem.status}</TableCell>
233
- <TableCell align="right">
234
- <StyledLink
235
- href={`/returns/${returnItem.uuid}`}
236
- target="_self"
237
- >
238
- <Button variant="contained" size="small">
239
- View
240
- </Button>
241
- </StyledLink>
242
- </TableCell>
243
- </TableRow>
244
- ))}
245
- </TableBody>
246
- </Table>
247
- ) : (
248
- <Box p={2}>
249
- <Typography>You have no returns.</Typography>
250
- </Box>
251
- )}
252
- </Paper>
253
- </Grid>
254
- </Grid>
255
- );
256
- }