Can delete member for members route
This commit is contained in:
parent
b39122cc43
commit
ac623fde9b
@ -4,17 +4,41 @@ import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
|
|||||||
import { Button, Tooltip } from "@mui/material";
|
import { Button, Tooltip } from "@mui/material";
|
||||||
import AddIcon from "@mui/icons-material/Add";
|
import AddIcon from "@mui/icons-material/Add";
|
||||||
import { RouterLink } from "../../widgets/RouterLink";
|
import { RouterLink } from "../../widgets/RouterLink";
|
||||||
import { Member, dateTimestamp, fmtDate } from "../../api/MemberApi";
|
import { Member, MemberApi, dateTimestamp, fmtDate } from "../../api/MemberApi";
|
||||||
import { DataGrid, GridActionsCellItem, GridColDef } from "@mui/x-data-grid";
|
import { DataGrid, GridActionsCellItem, GridColDef } from "@mui/x-data-grid";
|
||||||
import { MemberPhoto } from "../../widgets/MemberPhoto";
|
import { MemberPhoto } from "../../widgets/MemberPhoto";
|
||||||
import DeleteIcon from "@mui/icons-material/DeleteOutlined";
|
import DeleteIcon from "@mui/icons-material/DeleteOutlined";
|
||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import VisibilityIcon from "@mui/icons-material/Visibility";
|
import VisibilityIcon from "@mui/icons-material/Visibility";
|
||||||
|
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||||
|
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
|
||||||
|
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
|
||||||
|
|
||||||
export function FamilyMembersListRoute(): React.ReactElement {
|
export function FamilyMembersListRoute(): React.ReactElement {
|
||||||
|
const alert = useAlert();
|
||||||
|
const confirm = useConfirm();
|
||||||
|
const snackbar = useSnackbar();
|
||||||
|
|
||||||
const family = useFamily();
|
const family = useFamily();
|
||||||
|
|
||||||
const processDeletion = async (m: Member) => {};
|
const processDeletion = async (m: Member) => {
|
||||||
|
try {
|
||||||
|
if (
|
||||||
|
!(await confirm(
|
||||||
|
`Voulez-vous vraiment supprimer la fiche de ${m.fullName} ?`
|
||||||
|
))
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await MemberApi.Delete(m);
|
||||||
|
await family.reloadMembersList();
|
||||||
|
|
||||||
|
snackbar("La fiche du membre a été supprimée avec succès !");
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert("Echec de la suppression de la fiche ! ");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user