diff --git a/backend/test.db b/backend/test.db
index c44651d..c14eef2 100644
Binary files a/backend/test.db and b/backend/test.db differ
diff --git a/frontend/src/pages/AddressManagerView.tsx b/frontend/src/pages/AddressManagerView.tsx
index 2bb5f1d..da472e1 100644
--- a/frontend/src/pages/AddressManagerView.tsx
+++ b/frontend/src/pages/AddressManagerView.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import axios from 'axios';
import {
- Container, Typography, List, ListItem, IconButton, TextField, Box, ListItemText, ListItemSecondaryAction
+ Container, Typography, List, ListItem, IconButton, TextField, Box, ListItemText, ListItemSecondaryAction, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Button
} from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import EditIcon from '@mui/icons-material/Edit';
@@ -19,7 +19,6 @@ interface Address {
const AddressManager: React.FC = () => {
const [addresses, setAddresses] = React.useState
([]);
const [newAddress, setNewAddress] = React.useState>({
- id: 0,
street: '',
city: '',
zipcode: '',
@@ -27,6 +26,8 @@ const AddressManager: React.FC = () => {
});
const [editAddressId, setEditAddressId] = React.useState(null);
const [errorMessage, setErrorMessage] = React.useState(null);
+ const [dialogOpen, setDialogOpen] = React.useState(false);
+ const [selectedAddress, setSelectedAddress] = React.useState(null);
React.useEffect(() => {
const fetchAddresses = async () => {
@@ -94,6 +95,23 @@ const AddressManager: React.FC = () => {
setNewAddress(address);
};
+ const openDialog = (address: Address) => {
+ setSelectedAddress(address);
+ setDialogOpen(true);
+ };
+
+ const closeDialog = () => {
+ setDialogOpen(false);
+ setSelectedAddress(null);
+ };
+
+ const confirmDelete = async () => {
+ if (selectedAddress) {
+ await handleDeleteAddress(selectedAddress.id);
+ closeDialog();
+ }
+ };
+
return (
@@ -121,7 +139,7 @@ const AddressManager: React.FC = () => {
handleEditAddress(address)}>
- handleDeleteAddress(address.id)}>
+ openDialog(address)}>
@@ -131,6 +149,27 @@ const AddressManager: React.FC = () => {
No addresses found
)}
+
);
};
diff --git a/frontend/src/pages/ContactsManagerView.tsx b/frontend/src/pages/ContactsManagerView.tsx
index 00f621d..d8143b7 100644
--- a/frontend/src/pages/ContactsManagerView.tsx
+++ b/frontend/src/pages/ContactsManagerView.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import axios from 'axios';
import {
- Container, Typography, List, ListItem, IconButton, TextField, Box, ListItemText, ListItemSecondaryAction
+ Container, Typography, List, ListItem, IconButton, TextField, Box, ListItemText, ListItemSecondaryAction, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Button
} from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import EditIcon from '@mui/icons-material/Edit';
@@ -19,7 +19,6 @@ interface Contact {
const ContactsManager: React.FC = () => {
const [contacts, setContacts] = React.useState([]);
const [newContact, setNewContact] = React.useState>({
- id: 0,
firstname: '',
lastname: '',
phone_number: '',
@@ -27,6 +26,8 @@ const ContactsManager: React.FC = () => {
});
const [editContactId, setEditContactId] = React.useState(null);
const [errorMessage, setErrorMessage] = React.useState(null);
+ const [dialogOpen, setDialogOpen] = React.useState(false);
+ const [selectedContact, setSelectedContact] = React.useState(null);
React.useEffect(() => {
const fetchContacts = async () => {
@@ -94,6 +95,23 @@ const ContactsManager: React.FC = () => {
setNewContact(contact);
};
+ const openDialog = (contact: Contact) => {
+ setSelectedContact(contact);
+ setDialogOpen(true);
+ };
+
+ const closeDialog = () => {
+ setDialogOpen(false);
+ setSelectedContact(null);
+ };
+
+ const confirmDelete = async () => {
+ if (selectedContact) {
+ await handleDeleteContact(selectedContact.id);
+ closeDialog();
+ }
+ };
+
return (
@@ -121,7 +139,7 @@ const ContactsManager: React.FC = () => {
handleEditContact(contact)}>
- handleDeleteContact(contact.id)}>
+ openDialog(contact)}>
@@ -131,6 +149,27 @@ const ContactsManager: React.FC = () => {
No contacts found
)}
+
);
};