From 79ce616781b63483b4cb1cdd11ca116efc9abff7 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Thu, 31 Aug 2023 19:30:16 +0200 Subject: [PATCH] Show a feedback when saving couple information --- geneit_app/src/routes/family/FamilyCoupleRoute.tsx | 10 ++++++++-- geneit_app/src/routes/family/FamilyMemberRoute.tsx | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/geneit_app/src/routes/family/FamilyCoupleRoute.tsx b/geneit_app/src/routes/family/FamilyCoupleRoute.tsx index 430d0bd..60186e5 100644 --- a/geneit_app/src/routes/family/FamilyCoupleRoute.tsx +++ b/geneit_app/src/routes/family/FamilyCoupleRoute.tsx @@ -25,6 +25,7 @@ import { MemberInput } from "../../widgets/forms/MemberInput"; import { PropSelect } from "../../widgets/forms/PropSelect"; import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton"; import { useQuery } from "../../hooks/useQuery"; +import { useLoadingMessage } from "../../hooks/context_providers/LoadingMessageProvider"; /** * Create a new couple route @@ -218,6 +219,7 @@ export function CouplePage(p: { }): React.ReactElement { const confirm = useConfirm(); const snackbar = useSnackbar(); + const loadingMessage = useLoadingMessage(); const family = useFamily(); @@ -231,8 +233,12 @@ export function CouplePage(p: { setCouple(new Couple(structuredClone(couple))); }; - const save = () => { - p.onSave!(couple); + const save = async () => { + loadingMessage.show( + "Enregistrement des informations du couple en cours..." + ); + await p.onSave!(couple); + loadingMessage.hide(); }; const cancel = async () => { diff --git a/geneit_app/src/routes/family/FamilyMemberRoute.tsx b/geneit_app/src/routes/family/FamilyMemberRoute.tsx index 1b79e35..6e01ee4 100644 --- a/geneit_app/src/routes/family/FamilyMemberRoute.tsx +++ b/geneit_app/src/routes/family/FamilyMemberRoute.tsx @@ -39,6 +39,7 @@ import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton"; import { useQuery } from "../../hooks/useQuery"; import { mdiFamilyTree } from "@mdi/js"; import Icon from "@mdi/react"; +import { useLoadingMessage } from "../../hooks/context_providers/LoadingMessageProvider"; /** * Create a new member route @@ -241,6 +242,7 @@ export function MemberPage(p: { }): React.ReactElement { const confirm = useConfirm(); const snackbar = useSnackbar(); + const loadingMessage = useLoadingMessage(); const family = useFamily(); @@ -254,8 +256,12 @@ export function MemberPage(p: { setMember(new Member(structuredClone(member))); }; - const save = () => { - p.onSave!(member); + const save = async () => { + loadingMessage.show( + "Enregistrement des informations du membre en cours..." + ); + await p.onSave!(member); + loadingMessage.hide(); }; const cancel = async () => {