Compare commits
3 Commits
0899835fab
...
79ce616781
| Author | SHA1 | Date | |
|---|---|---|---|
| 79ce616781 | |||
| e4a1817d7f | |||
| 2a69c89065 |
@@ -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
|
||||
@@ -165,7 +166,8 @@ export function FamilyEditCoupleRoute(): React.ReactElement {
|
||||
|
||||
const cancel = () => {
|
||||
setShouldQuit(true);
|
||||
n(-1);
|
||||
n(family.family.coupleURL(couple!));
|
||||
//n(-1);
|
||||
};
|
||||
|
||||
const save = async (c: Couple) => {
|
||||
@@ -217,6 +219,7 @@ export function CouplePage(p: {
|
||||
}): React.ReactElement {
|
||||
const confirm = useConfirm();
|
||||
const snackbar = useSnackbar();
|
||||
const loadingMessage = useLoadingMessage();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
@@ -230,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 () => {
|
||||
|
||||
@@ -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
|
||||
@@ -185,8 +186,8 @@ export function FamilyEditMemberRoute(): React.ReactElement {
|
||||
|
||||
const cancel = () => {
|
||||
setShouldQuit(true);
|
||||
//n(family.family.URL(`member/${member!.id}`));
|
||||
n(-1);
|
||||
n(family.family.memberURL(member!));
|
||||
//n(-1);
|
||||
};
|
||||
|
||||
const save = async (m: Member) => {
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -103,8 +103,29 @@ fn check_opt_str_val(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn trim_opt_val(val: &mut Option<String>) {
|
||||
if let Some(s) = val {
|
||||
*val = Some(s.trim().to_string());
|
||||
}
|
||||
|
||||
if val.as_deref() == Some("") {
|
||||
*val = None;
|
||||
}
|
||||
}
|
||||
|
||||
impl MemberRequest {
|
||||
pub async fn to_member(self, member: &mut Member) -> anyhow::Result<()> {
|
||||
pub async fn to_member(mut self, member: &mut Member) -> anyhow::Result<()> {
|
||||
// Trim values before processing
|
||||
trim_opt_val(&mut self.first_name);
|
||||
trim_opt_val(&mut self.last_name);
|
||||
trim_opt_val(&mut self.birth_last_name);
|
||||
trim_opt_val(&mut self.email);
|
||||
trim_opt_val(&mut self.country);
|
||||
trim_opt_val(&mut self.address);
|
||||
trim_opt_val(&mut self.city);
|
||||
trim_opt_val(&mut self.note);
|
||||
trim_opt_val(&mut self.phone);
|
||||
|
||||
let c = StaticConstraints::default();
|
||||
check_opt_str_val(
|
||||
&self.first_name,
|
||||
|
||||
@@ -6,6 +6,7 @@ diesel::table! {
|
||||
family_id -> Int4,
|
||||
wife -> Nullable<Int4>,
|
||||
husband -> Nullable<Int4>,
|
||||
#[max_length = 1]
|
||||
state -> Nullable<Varchar>,
|
||||
photo_id -> Nullable<Int4>,
|
||||
time_create -> Int8,
|
||||
@@ -23,7 +24,9 @@ diesel::table! {
|
||||
families (id) {
|
||||
id -> Int4,
|
||||
time_create -> Int8,
|
||||
#[max_length = 30]
|
||||
name -> Varchar,
|
||||
#[max_length = 7]
|
||||
invitation_code -> Varchar,
|
||||
disable_couple_photos -> Bool,
|
||||
}
|
||||
@@ -33,16 +36,26 @@ diesel::table! {
|
||||
members (id) {
|
||||
id -> Int4,
|
||||
family_id -> Int4,
|
||||
#[max_length = 30]
|
||||
first_name -> Nullable<Varchar>,
|
||||
#[max_length = 30]
|
||||
last_name -> Nullable<Varchar>,
|
||||
#[max_length = 30]
|
||||
birth_last_name -> Nullable<Varchar>,
|
||||
photo_id -> Nullable<Int4>,
|
||||
#[max_length = 255]
|
||||
email -> Nullable<Varchar>,
|
||||
#[max_length = 30]
|
||||
phone -> Nullable<Varchar>,
|
||||
#[max_length = 155]
|
||||
address -> Nullable<Varchar>,
|
||||
#[max_length = 150]
|
||||
city -> Nullable<Varchar>,
|
||||
#[max_length = 12]
|
||||
postal_code -> Nullable<Varchar>,
|
||||
#[max_length = 2]
|
||||
country -> Nullable<Varchar>,
|
||||
#[max_length = 1]
|
||||
sex -> Nullable<Varchar>,
|
||||
time_create -> Int8,
|
||||
time_update -> Int8,
|
||||
@@ -71,11 +84,15 @@ diesel::table! {
|
||||
diesel::table! {
|
||||
photos (id) {
|
||||
id -> Int4,
|
||||
#[max_length = 36]
|
||||
file_id -> Varchar,
|
||||
time_create -> Int8,
|
||||
#[max_length = 150]
|
||||
mime_type -> Varchar,
|
||||
#[max_length = 130]
|
||||
sha512 -> Varchar,
|
||||
file_size -> Int4,
|
||||
#[max_length = 130]
|
||||
thumb_sha512 -> Varchar,
|
||||
}
|
||||
}
|
||||
@@ -83,12 +100,16 @@ diesel::table! {
|
||||
diesel::table! {
|
||||
users (id) {
|
||||
id -> Int4,
|
||||
#[max_length = 30]
|
||||
name -> Varchar,
|
||||
#[max_length = 255]
|
||||
email -> Varchar,
|
||||
password -> Nullable<Varchar>,
|
||||
time_create -> Int8,
|
||||
#[max_length = 150]
|
||||
reset_password_token -> Nullable<Varchar>,
|
||||
time_gen_reset_token -> Int8,
|
||||
#[max_length = 150]
|
||||
delete_account_token -> Nullable<Varchar>,
|
||||
time_gen_delete_account_token -> Int8,
|
||||
time_activate -> Int8,
|
||||
|
||||
Reference in New Issue
Block a user