diff --git a/front/src/components/home.rs b/front/src/components/home.rs index 8c9295a..68f165c 100644 --- a/front/src/components/home.rs +++ b/front/src/components/home.rs @@ -34,9 +34,7 @@ impl Component for Home { type Properties = (); fn create(_ctx: &Context) -> Self { - Self { - user: None, - } + Self { user: None } } fn view(&self, ctx: &Context) -> Html { diff --git a/front/src/components/list_groups.rs b/front/src/components/list_groups.rs index 8bfc3c0..e8e061b 100644 --- a/front/src/components/list_groups.rs +++ b/front/src/components/list_groups.rs @@ -1,6 +1,10 @@ use gloo_net::http::Request; use gloo_net::Error; -use patternfly_yew::{Button, Card, Flex, FlexModifier, Gallery, Icon, Modal, ModalVariant, Title, ToastViewer, ToFlexItems, Variant, WithBreakpointExt}; use yew::prelude::*; +use patternfly_yew::{ + Button, Card, Flex, FlexModifier, Gallery, Icon, Modal, ModalVariant, Title, ToFlexItems, + ToastViewer, Variant, WithBreakpointExt, +}; +use yew::prelude::*; use crate::components::{Group, Home, TestMessage, ToastFields, ToastType}; @@ -139,7 +143,7 @@ impl Component for ListGroups { let mut groups_final: Vec = Vec::new(); for g in groups.chunks(3) { - groups_final.push(html!{ { g.to_vec().into_flex_items() } }); + groups_final.push(html! { { g.to_vec().into_flex_items() } }); } html! { @@ -218,11 +222,7 @@ impl Component for ListGroups { MsgListGroups::Done(groups) => { let len = groups.len(); self.groups = groups; - self.nb_show = if len < 3 { - len - } else { - 3 - }; + self.nb_show = if len < 3 { len } else { 3 }; true } @@ -244,41 +244,43 @@ impl Component for ListGroups { if let Some(group) = self.free_groups.get(self.selected_group) { let id = group.id.clone(); ctx.link().send_future(async move { - match Request::put(&format!("/api/groups/{}/join", id)).send().await { + match Request::put(&format!("/api/groups/{}/join", id)) + .send() + .await + { Ok(resp) => { if resp.ok() { MsgListGroups::FinishJoin } else { MsgListGroups::Error( String::from("Erreur"), - String::from("Pas de réponse 200") + String::from("Pas de réponse 200"), ) } } Err(_) => { - MsgListGroups::Error( - String::from("Erreur"), - String::from("Bruh") - ) + MsgListGroups::Error(String::from("Erreur"), String::from("Bruh")) } } }); } else { ctx.link().send_message(MsgListGroups::Error( String::from("Erreur"), - String::from("Contactez nous si vous êtes tombés sur cette erreur.") + String::from("Contactez nous si vous êtes tombés sur cette erreur."), )); } false } MsgListGroups::FinishJoin => { - self.groups.push(self.free_groups.remove(self.selected_group)); + self.groups + .push(self.free_groups.remove(self.selected_group)); if self.nb_show < 3 { self.nb_show += 1; } true - }MsgListGroups::FinishLeave(id) => { + } + MsgListGroups::FinishLeave(id) => { self.free_groups.push(self.groups.remove(id)); if self.nb_show > 0 && id <= self.nb_show { self.nb_show -= 1; @@ -293,29 +295,29 @@ impl Component for ListGroups { if let Some(group) = self.groups.get(id_group) { let id = group.id.clone(); ctx.link().send_future(async move { - match Request::put(&format!("/api/groups/{}/leave", id)).send().await { + match Request::put(&format!("/api/groups/{}/leave", id)) + .send() + .await + { Ok(resp) => { if resp.ok() { MsgListGroups::FinishLeave(id_group) } else { MsgListGroups::Error( String::from("Erreur"), - String::from("Pas de réponse 200") + String::from("Pas de réponse 200"), ) } } Err(_) => { - MsgListGroups::Error( - String::from("Erreur"), - String::from("Bruh") - ) + MsgListGroups::Error(String::from("Erreur"), String::from("Bruh")) } } }); } else { ctx.link().send_message(MsgListGroups::Error( String::from("Erreur"), - String::from("Contactez nous si vous êtes tombés sur cette erreur.") + String::from("Contactez nous si vous êtes tombés sur cette erreur."), )); } false diff --git a/front/src/components/mod.rs b/front/src/components/mod.rs index 281afc4..7b319d3 100644 --- a/front/src/components/mod.rs +++ b/front/src/components/mod.rs @@ -4,8 +4,8 @@ mod list_groups; pub use home::*; use list_groups::ListGroups; -use gloo_net::Error; use gloo_net::http::Request; +use gloo_net::Error; use serde::{Deserialize, Serialize}; #[derive(Clone, Deserialize, PartialEq, Serialize)]