Add feedback for member creation

This commit is contained in:
Pierre HUBERT 2023-08-08 14:34:33 +02:00
parent c6d0ff187c
commit b828fce039
2 changed files with 11 additions and 0 deletions

View File

@ -98,6 +98,14 @@ export class Member implements MemberApi {
family_id: family_id,
});
}
get fullName(): string {
const firstName = this.first_name ?? "";
return firstName.length === 0
? this.last_name ?? ""
: `${firstName} ${this.last_name ?? ""}`;
}
}
export class MemberApi {

View File

@ -12,12 +12,14 @@ import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
import { PropEdit } from "../../widgets/PropEdit";
import { PropertiesBox } from "../../widgets/PropertiesBox";
import { SexSelection } from "../../widgets/SexSelection";
import { useSnackbar } from "../../context_providers/SnackbarProvider";
/**
* Create a new member route
*/
export function FamilyCreateMemberRoute(): React.ReactElement {
const alert = useAlert();
const snackbar = useSnackbar();
const n = useNavigate();
const family = useFamily();
@ -29,6 +31,7 @@ export function FamilyCreateMemberRoute(): React.ReactElement {
// TODO : trigger update
n(family.family.URL(`member/${r.id}`));
snackbar(`La fiche pour ${r.fullName} a été créée avec succès !`);
} catch (e) {
console.error(e);
alert("Echec de la création de la personne !");