forked from steve8708/mui-vite
-
Notifications
You must be signed in to change notification settings - Fork 13
Add complete customer management system to CRM #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
steve8708
wants to merge
2
commits into
main
Choose a base branch
from
ai_main_406cf6a90ed3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| import * as React from "react"; | ||
| import Dialog from "@mui/material/Dialog"; | ||
| import DialogTitle from "@mui/material/DialogTitle"; | ||
| import DialogContent from "@mui/material/DialogContent"; | ||
| import DialogActions from "@mui/material/DialogActions"; | ||
| import Button from "@mui/material/Button"; | ||
| import Avatar from "@mui/material/Avatar"; | ||
| import Box from "@mui/material/Box"; | ||
| import Typography from "@mui/material/Typography"; | ||
| import Grid from "@mui/material/Grid"; | ||
| import Chip from "@mui/material/Chip"; | ||
| import Divider from "@mui/material/Divider"; | ||
| import IconButton from "@mui/material/IconButton"; | ||
| import EditIcon from "@mui/icons-material/Edit"; | ||
| import EmailIcon from "@mui/icons-material/Email"; | ||
| import PhoneIcon from "@mui/icons-material/Phone"; | ||
| import LocationOnIcon from "@mui/icons-material/LocationOn"; | ||
| import PersonIcon from "@mui/icons-material/Person"; | ||
| import CakeIcon from "@mui/icons-material/Cake"; | ||
| import AccessTimeIcon from "@mui/icons-material/AccessTime"; | ||
| import type { Customer } from "../types/customer"; | ||
|
|
||
| interface CustomerDetailsCardProps { | ||
| open: boolean; | ||
| customer: Customer | null; | ||
| onClose: () => void; | ||
| onEdit: (customer: Customer) => void; | ||
| } | ||
|
|
||
| interface DetailItemProps { | ||
| icon: React.ReactNode; | ||
| label: string; | ||
| value: string | React.ReactNode; | ||
| } | ||
|
|
||
| function DetailItem({ icon, label, value }: DetailItemProps) { | ||
| return ( | ||
| <Box sx={{ display: "flex", alignItems: "flex-start", gap: 1, mb: 2 }}> | ||
| <Box sx={{ color: "text.secondary", mt: 0.5 }}>{icon}</Box> | ||
| <Box sx={{ flex: 1 }}> | ||
| <Typography variant="body2" color="text.secondary" sx={{ mb: 0.5 }}> | ||
| {label} | ||
| </Typography> | ||
| <Typography variant="body1">{value}</Typography> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| export default function CustomerDetailsCard({ | ||
| open, | ||
| customer, | ||
| onClose, | ||
| onEdit, | ||
| }: CustomerDetailsCardProps) { | ||
| if (!customer) { | ||
| return null; | ||
| } | ||
|
|
||
| const fullName = `${customer.name.title} ${customer.name.first} ${customer.name.last}`; | ||
| const address = `${customer.location.street.number} ${customer.location.street.name}, ${customer.location.city}, ${customer.location.state} ${customer.location.postcode}, ${customer.location.country}`; | ||
| const registeredDate = new Date( | ||
| customer.registered.date, | ||
| ).toLocaleDateString(); | ||
| const birthDate = new Date(customer.dob.date).toLocaleDateString(); | ||
|
|
||
| const handleEdit = () => { | ||
| onEdit(customer); | ||
| }; | ||
|
|
||
| return ( | ||
| <Dialog | ||
| open={open} | ||
| onClose={onClose} | ||
| maxWidth="md" | ||
| fullWidth | ||
| PaperProps={{ | ||
| sx: { minHeight: "500px" }, | ||
| }} | ||
| > | ||
| <DialogTitle sx={{ pb: 1 }}> | ||
| <Box | ||
| sx={{ | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "space-between", | ||
| }} | ||
| > | ||
| <Typography variant="h6">Customer Details</Typography> | ||
| <IconButton onClick={handleEdit} color="primary"> | ||
| <EditIcon /> | ||
| </IconButton> | ||
| </Box> | ||
| </DialogTitle> | ||
|
|
||
| <DialogContent> | ||
| <Box sx={{ pt: 1 }}> | ||
| {/* Header with Avatar and Basic Info */} | ||
| <Box sx={{ display: "flex", alignItems: "center", mb: 3 }}> | ||
| <Avatar | ||
| src={customer.picture?.large} | ||
| alt={fullName} | ||
| sx={{ width: 80, height: 80, mr: 2 }} | ||
| > | ||
| {fullName.charAt(0).toUpperCase()} | ||
| </Avatar> | ||
| <Box sx={{ flex: 1 }}> | ||
| <Typography variant="h5" gutterBottom> | ||
| {fullName} | ||
| </Typography> | ||
| <Box sx={{ display: "flex", gap: 1, mb: 1 }}> | ||
| <Chip | ||
| label={ | ||
| customer.gender.charAt(0).toUpperCase() + | ||
| customer.gender.slice(1) | ||
| } | ||
| color={customer.gender === "male" ? "primary" : "secondary"} | ||
| size="small" | ||
| /> | ||
| <Chip | ||
| label={`${customer.dob.age} years old`} | ||
| variant="outlined" | ||
| size="small" | ||
| /> | ||
| <Chip label={customer.nat} variant="outlined" size="small" /> | ||
| </Box> | ||
| <Typography variant="body2" color="text.secondary"> | ||
| Customer since {registeredDate} ({customer.registered.age}{" "} | ||
| years) | ||
| </Typography> | ||
| </Box> | ||
| </Box> | ||
|
|
||
| <Divider sx={{ mb: 3 }} /> | ||
|
|
||
| <Grid container spacing={3}> | ||
| {/* Contact Information */} | ||
| <Grid item xs={12} md={6}> | ||
| <Typography | ||
| variant="h6" | ||
| gutterBottom | ||
| sx={{ color: "primary.main" }} | ||
| > | ||
| Contact Information | ||
| </Typography> | ||
|
|
||
| <DetailItem | ||
| icon={<EmailIcon fontSize="small" />} | ||
| label="Email Address" | ||
| value={customer.email} | ||
| /> | ||
|
|
||
| {customer.phone && ( | ||
| <DetailItem | ||
| icon={<PhoneIcon fontSize="small" />} | ||
| label="Phone Number" | ||
| value={customer.phone} | ||
| /> | ||
| )} | ||
|
|
||
| {customer.cell && ( | ||
| <DetailItem | ||
| icon={<PhoneIcon fontSize="small" />} | ||
| label="Cell Phone" | ||
| value={customer.cell} | ||
| /> | ||
| )} | ||
|
|
||
| <DetailItem | ||
| icon={<PersonIcon fontSize="small" />} | ||
| label="Username" | ||
| value={customer.login.username} | ||
| /> | ||
| </Grid> | ||
|
|
||
| {/* Personal Information */} | ||
| <Grid item xs={12} md={6}> | ||
| <Typography | ||
| variant="h6" | ||
| gutterBottom | ||
| sx={{ color: "primary.main" }} | ||
| > | ||
| Personal Information | ||
| </Typography> | ||
|
|
||
| <DetailItem | ||
| icon={<CakeIcon fontSize="small" />} | ||
| label="Date of Birth" | ||
| value={`${birthDate} (${customer.dob.age} years old)`} | ||
| /> | ||
|
|
||
| <DetailItem | ||
| icon={<AccessTimeIcon fontSize="small" />} | ||
| label="Customer Since" | ||
| value={`${registeredDate} (${customer.registered.age} years)`} | ||
| /> | ||
|
|
||
| {customer.location.timezone && ( | ||
| <DetailItem | ||
| icon={<AccessTimeIcon fontSize="small" />} | ||
| label="Timezone" | ||
| value={`${customer.location.timezone.offset} - ${customer.location.timezone.description}`} | ||
| /> | ||
| )} | ||
| </Grid> | ||
|
|
||
| {/* Address Information */} | ||
| <Grid item xs={12}> | ||
| <Typography | ||
| variant="h6" | ||
| gutterBottom | ||
| sx={{ color: "primary.main" }} | ||
| > | ||
| Address Information | ||
| </Typography> | ||
|
|
||
| <DetailItem | ||
| icon={<LocationOnIcon fontSize="small" />} | ||
| label="Full Address" | ||
| value={address} | ||
| /> | ||
|
|
||
| {customer.location.coordinates && ( | ||
| <DetailItem | ||
| icon={<LocationOnIcon fontSize="small" />} | ||
| label="Coordinates" | ||
| value={`${customer.location.coordinates.latitude}, ${customer.location.coordinates.longitude}`} | ||
| /> | ||
| )} | ||
| </Grid> | ||
| </Grid> | ||
| </Box> | ||
| </DialogContent> | ||
|
|
||
| <DialogActions sx={{ p: 2 }}> | ||
| <Button onClick={onClose}>Close</Button> | ||
| <Button variant="contained" onClick={handleEdit}> | ||
| Edit Customer | ||
| </Button> | ||
| </DialogActions> | ||
| </Dialog> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@builderio-bot move this to be its own component in a new file and use it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will get right to work!