diff --git a/clients/web/assets/style.css b/clients/web/assets/style.css index e81e0de..428d693 100644 --- a/clients/web/assets/style.css +++ b/clients/web/assets/style.css @@ -161,7 +161,7 @@ body { /* ── Stats grid ──────────────────────────────────────────────────── */ .stats-grid { display: grid; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; } diff --git a/clients/web/locales/fr.json b/clients/web/locales/fr.json index 569d66b..b3a05f0 100644 --- a/clients/web/locales/fr.json +++ b/clients/web/locales/fr.json @@ -99,7 +99,7 @@ "resend_verification": "Renvoyer l'email de vérification", "verification_email_resent": "Email de vérification envoyé.", "loading": "Chargement…", - "member_since": "Membre depuis le", + "member_since": "Membre depuis", "stat_games": "Parties", "stat_wins": "Victoires", "stat_losses": "Défaites", diff --git a/clients/web/src/api.rs b/clients/web/src/api.rs index d826165..9e0f57c 100644 --- a/clients/web/src/api.rs +++ b/clients/web/src/api.rs @@ -244,53 +244,10 @@ pub async fn post_reset_password(token: &str, new_password: &str) -> Result<(), // ── Utilities ───────────────────────────────────────────────────────────────── -/// Maps to the `Intl.DateTimeFormat` options object accepted by `Date.toLocaleString`. -/// `Default` passes no options (browser default: full date + time). -pub struct DateFormatOptions { - /// "full" | "long" | "medium" | "short" — omit to suppress date part - pub date_style: Option<&'static str>, - /// "full" | "long" | "medium" | "short" — omit to suppress time part - pub time_style: Option<&'static str>, -} - -impl Default for DateFormatOptions { - fn default() -> Self { - Self { date_style: None, time_style: None } - } -} - -impl DateFormatOptions { - pub fn date_only() -> Self { - Self { date_style: Some("short"), time_style: None } - } - - pub fn time_only() -> Self { - Self { date_style: None, time_style: Some("short") } - } - - pub fn date_time() -> Self { - Self { date_style: Some("short"), time_style: Some("short") } - } - - fn to_js_value(&self) -> wasm_bindgen::JsValue { - if self.date_style.is_none() && self.time_style.is_none() { - return wasm_bindgen::JsValue::UNDEFINED; - } - let obj = js_sys::Object::new(); - if let Some(v) = self.date_style { - let _ = js_sys::Reflect::set(&obj, &"dateStyle".into(), &v.into()); - } - if let Some(v) = self.time_style { - let _ = js_sys::Reflect::set(&obj, &"timeStyle".into(), &v.into()); - } - obj.into() - } -} - -pub fn format_ts(ts: i64, locale: &str, opts: &DateFormatOptions) -> String { +pub fn format_ts(ts: i64) -> String { let ms = (ts * 1000) as f64; let date = js_sys::Date::new(&wasm_bindgen::JsValue::from_f64(ms)); - date.to_locale_string(locale, &opts.to_js_value()) + date.to_locale_string("en-GB", &wasm_bindgen::JsValue::UNDEFINED) .as_string() .unwrap_or_default() } diff --git a/clients/web/src/portal/game_detail.rs b/clients/web/src/portal/game_detail.rs index d0d17d4..adc3643 100644 --- a/clients/web/src/portal/game_detail.rs +++ b/clients/web/src/portal/game_detail.rs @@ -32,12 +32,8 @@ pub fn GameDetailPage() -> impl IntoView { #[component] fn GameDetailView(game: GameDetail) -> impl IntoView { let i18n = use_i18n(); - let locale_tag = match i18n.get_locale() { - Locale::en => "en-GB", - Locale::fr => "fr-FR", - }; - let started = api::format_ts(game.started_at, locale_tag, &api::DateFormatOptions::date_only()); - let ended = game.ended_at.map(|ts| api::format_ts(ts, locale_tag, &api::DateFormatOptions::date_only())) + let started = api::format_ts(game.started_at); + let ended = game.ended_at.map(api::format_ts) .unwrap_or_else(|| t_string!(i18n, game_ongoing).to_string()); view! { diff --git a/clients/web/src/portal/profile.rs b/clients/web/src/portal/profile.rs index c727bbd..9a94b3f 100644 --- a/clients/web/src/portal/profile.rs +++ b/clients/web/src/portal/profile.rs @@ -37,16 +37,7 @@ fn ProfileContent(profile: UserProfile, username: String) -> impl IntoView { async move { api::get_user_games(&u, p).await } }); - let locale_tag = match i18n.get_locale() { - Locale::en => "en-GB", - Locale::fr => "fr-FR", - }; - let date_format = api::DateFormatOptions { - date_style: Some("long"), - time_style: None, - }; - let joined = api::format_ts(profile.created_at, locale_tag, &date_format); - // let joined = api::format_ts(profile.created_at, locale_tag, &api::DateFormatOptions::date_only()); + let joined = api::format_ts(profile.created_at); view! {