Can get possible couple states through API

This commit is contained in:
2023-08-07 17:01:56 +02:00
parent 29c503a6b0
commit ff8e3cce9d
3 changed files with 37 additions and 2 deletions

View File

@ -314,6 +314,13 @@ pub enum CoupleState {
Divorced,
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct CoupleStateDesc {
code: &'static str,
fr: &'static str,
en: &'static str,
}
impl CoupleState {
pub fn as_str(&self) -> &str {
match self {
@ -327,6 +334,31 @@ impl CoupleState {
pub fn parse_str(s: &str) -> Option<Self> {
serde_json::from_str(s).ok()
}
pub fn states_list() -> Vec<CoupleStateDesc> {
vec![
CoupleStateDesc {
code: "N",
fr: "Aucun",
en: "None",
},
CoupleStateDesc {
code: "E",
fr: "Fiancés",
en: "Engaged",
},
CoupleStateDesc {
code: "M",
fr: "Mariés",
en: "Married",
},
CoupleStateDesc {
code: "D",
fr: "Divorcés",
en: "Divorced",
},
]
}
}
#[derive(Queryable, Debug, serde::Serialize)]