diff --git a/public/c1.jpg b/public/c1.jpg new file mode 100644 index 0000000..fc37c20 Binary files /dev/null and b/public/c1.jpg differ diff --git a/public/c2.jpg b/public/c2.jpg new file mode 100644 index 0000000..529abae Binary files /dev/null and b/public/c2.jpg differ diff --git a/public/c3.jpg b/public/c3.jpg new file mode 100644 index 0000000..459bc73 Binary files /dev/null and b/public/c3.jpg differ diff --git a/public/c4.jpg b/public/c4.jpg new file mode 100644 index 0000000..54973d0 Binary files /dev/null and b/public/c4.jpg differ diff --git a/public/c5.jpg b/public/c5.jpg new file mode 100644 index 0000000..bfbc585 Binary files /dev/null and b/public/c5.jpg differ diff --git a/src/components/MenuDrawer.jsx b/src/components/MenuDrawer.jsx index d48ac6c..b370d1f 100644 --- a/src/components/MenuDrawer.jsx +++ b/src/components/MenuDrawer.jsx @@ -21,10 +21,10 @@ export default function MenuDrawer({ zone = 'public', open, onClose, onSelect }) }}> {items.map((text, index) => ( - { - onClose(); // Close drawer - onSelect?.(text); // Notify parent of selected item - }}> + { + onClose(); // Close drawer + onSelect?.(text); // Notify parent of selected item + }}> { + if (initialData) { + setClient(initialData); + } else { + setClient({ + fullName: '', + email: '', + phone: '', + address: '', + company: '', + avatar: '' + }); + } + }, [initialData]); + + const handleChange = (e) => { + const { name, value } = e.target; + setClient((prev) => ({ ...prev, [name]: value })); + }; + + const handleImageChange = (e) => { + const file = e.target.files[0]; + if (!file) return; + + const reader = new FileReader(); + reader.onloadend = () => { + setClient((prev) => ({ ...prev, avatar: reader.result })); + }; + reader.readAsDataURL(file); + }; + + const handleSubmit = () => { + if (onAdd) { + onAdd(client); + } + }; + + return ( + + + {/* Left visual panel */} + + + {client.fullName || 'N/A'} + + + {client.email || 'N/A'} + + + {client.phone || 'N/A'} + + {client.avatar ? ( + + ) : ( + + Image Preview + + )} + + + + + + {/* Right input panel */} + + + + + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/private/clients/Clients.jsx b/src/private/clients/Clients.jsx index f330407..a4678a9 100644 --- a/src/private/clients/Clients.jsx +++ b/src/private/clients/Clients.jsx @@ -2,71 +2,17 @@ import SectionContainer from '../../components/SectionContainer.jsx'; import { useState } from 'react'; import { DataGrid } from '@mui/x-data-grid'; import { Typography, Button, Dialog, DialogTitle, DialogContent, IconButton, Box, Avatar } from '@mui/material'; +import AddOrEditClientsForm from './AddOrEditClientsForm.jsx'; + import EditRoundedIcon from '@mui/icons-material/EditRounded'; import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded'; import '../../App.css'; -const columns = [ - { - field: 'avatar', - headerName: '', - width: 100, - renderCell: (params) => ( - - ) - }, - { field: 'fullName', headerName: 'Full Name', flex: 1 }, - { field: 'email', headerName: 'Email', flex: 1.5 }, - { field: 'phone', headerName: 'Phone', flex: 1 }, - { field: 'address', headerName: 'Address', flex: 1.5 }, - { field: 'company', headerName: 'Company', flex: 1 }, - { - field: 'actions', - headerName: '', - width: 130, - renderCell: (params) => ( - - - - - - - - - ) - } -]; - export default function Clients() { const [rows, setRows] = useState([ { id: 1, - avatar: '/client1.jpg', + avatar: '/c2.jpg', fullName: 'Anna Wintour', email: 'anna@fendi.com', phone: '+1 555-1234', @@ -75,7 +21,7 @@ export default function Clients() { }, { id: 2, - avatar: '/client2.jpg', + avatar: '/c3.jpg', fullName: 'Karl Lagerfeld', email: 'karl@fendi.com', phone: '+1 555-5678', @@ -84,20 +30,143 @@ export default function Clients() { }, { id: 3, - avatar: '', + avatar: '/c4.jpg', fullName: 'Donatella Versace', email: 'donatella@fendi.com', phone: '+1 555-9999', address: '789 Couture St, Milan', company: 'Fendi Casa' + }, + { + id: 4, + avatar: '/c5.jpg', + fullName: 'Giorgio Armani', + email: 'giorgio@fendi.com', + phone: '+1 555-8888', + address: '101 Luxury Rd, Milan', + company: 'Fendi Casa' } ]); + const [open, setOpen] = useState(false); + const [editingClient, setEditingClient] = useState(null); + const [confirmOpen, setConfirmOpen] = useState(false); + const [rowToDelete, setRowToDelete] = useState(null); + + const handleAddOrEditClient = (client) => { + if (editingClient) { + // Update existing + setRows(rows.map((row) => (row.id === editingClient.id ? { ...editingClient, ...client } : row))); + } else { + // Add new + const id = rows.length + 1; + setRows([...rows, { id, company: 'Fendi casa', ...client }]); + } + setOpen(false); + setEditingClient(null); + }; + + const handleEditClick = (params) => { + setEditingClient(params.row); + setOpen(true); + }; + + const handleDeleteClick = (row) => { + setRowToDelete(row); + setConfirmOpen(true); + }; + + const confirmDelete = () => { + setRows(rows.filter((row) => row.id !== rowToDelete.id)); + setRowToDelete(null); + setConfirmOpen(false); + }; + + const columns = [ + { + field: 'avatar', + headerName: '', + width: 100, + renderCell: (params) => ( + + ) + }, + { field: 'fullName', headerName: 'Full Name', flex: 1 }, + { field: 'email', headerName: 'Email', flex: 1.5 }, + { field: 'phone', headerName: 'Phone', flex: 1 }, + { field: 'address', headerName: 'Address', flex: 1.5 }, + { field: 'company', headerName: 'Company', flex: 1 }, + { + field: 'actions', + headerName: '', + width: 130, + renderCell: (params) => ( + + handleEditClick(params)} + > + + + handleDeleteClick(params.row)} + > + + + + ) + } + ]; + return ( Clients + + { setOpen(false); setEditingClient(null); }} maxWidth="md" fullWidth> + {editingClient ? 'Edit Client' : 'Add Client'} + + { setOpen(false); setEditingClient(null); }} /> + + + + setConfirmOpen(false)}> + Confirm Delete + + + Are you sure you want to delete{' '} + {rowToDelete?.fullName}? + + + + + + + + 60} @@ -108,7 +177,7 @@ export default function Clients() { getRowSpacing={() => ({ top: 4, bottom: 4 })} /> - diff --git a/src/private/products/Products.jsx b/src/private/products/Products.jsx index 7512c28..7d6b278 100644 --- a/src/private/products/Products.jsx +++ b/src/private/products/Products.jsx @@ -131,7 +131,7 @@ export default function Products({ children, maxWidth = 'lg', sx = {} }) { return ( - Product Catalog + Products { setOpen(false); setEditingProduct(null); }} maxWidth="md" fullWidth>