cargo fmt

This commit is contained in:
rick 2022-10-30 16:32:27 +01:00
parent 3be7ac3336
commit e1d720f5d6
Signed by: Rick
GPG key ID: 4A6223D66294EB20
3 changed files with 27 additions and 27 deletions

View file

@ -34,9 +34,7 @@ impl Component for Home {
type Properties = (); type Properties = ();
fn create(_ctx: &Context<Self>) -> Self { fn create(_ctx: &Context<Self>) -> Self {
Self { Self { user: None }
user: None,
}
} }
fn view(&self, ctx: &Context<Self>) -> Html { fn view(&self, ctx: &Context<Self>) -> Html {

View file

@ -1,6 +1,10 @@
use gloo_net::http::Request; use gloo_net::http::Request;
use gloo_net::Error; 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}; use crate::components::{Group, Home, TestMessage, ToastFields, ToastType};
@ -139,7 +143,7 @@ impl Component for ListGroups {
let mut groups_final: Vec<Html> = Vec::new(); let mut groups_final: Vec<Html> = Vec::new();
for g in groups.chunks(3) { for g in groups.chunks(3) {
groups_final.push(html!{ <Flex> { g.to_vec().into_flex_items() } </Flex> }); groups_final.push(html! { <Flex> { g.to_vec().into_flex_items() } </Flex> });
} }
html! { html! {
@ -218,11 +222,7 @@ impl Component for ListGroups {
MsgListGroups::Done(groups) => { MsgListGroups::Done(groups) => {
let len = groups.len(); let len = groups.len();
self.groups = groups; self.groups = groups;
self.nb_show = if len < 3 { self.nb_show = if len < 3 { len } else { 3 };
len
} else {
3
};
true true
} }
@ -244,41 +244,43 @@ impl Component for ListGroups {
if let Some(group) = self.free_groups.get(self.selected_group) { if let Some(group) = self.free_groups.get(self.selected_group) {
let id = group.id.clone(); let id = group.id.clone();
ctx.link().send_future(async move { 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) => { Ok(resp) => {
if resp.ok() { if resp.ok() {
MsgListGroups::FinishJoin MsgListGroups::FinishJoin
} else { } else {
MsgListGroups::Error( MsgListGroups::Error(
String::from("Erreur"), String::from("Erreur"),
String::from("Pas de réponse 200") String::from("Pas de réponse 200"),
) )
} }
} }
Err(_) => { Err(_) => {
MsgListGroups::Error( MsgListGroups::Error(String::from("Erreur"), String::from("Bruh"))
String::from("Erreur"),
String::from("Bruh")
)
} }
} }
}); });
} else { } else {
ctx.link().send_message(MsgListGroups::Error( ctx.link().send_message(MsgListGroups::Error(
String::from("Erreur"), 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 false
} }
MsgListGroups::FinishJoin => { 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 { if self.nb_show < 3 {
self.nb_show += 1; self.nb_show += 1;
} }
true true
}MsgListGroups::FinishLeave(id) => { }
MsgListGroups::FinishLeave(id) => {
self.free_groups.push(self.groups.remove(id)); self.free_groups.push(self.groups.remove(id));
if self.nb_show > 0 && id <= self.nb_show { if self.nb_show > 0 && id <= self.nb_show {
self.nb_show -= 1; self.nb_show -= 1;
@ -293,29 +295,29 @@ impl Component for ListGroups {
if let Some(group) = self.groups.get(id_group) { if let Some(group) = self.groups.get(id_group) {
let id = group.id.clone(); let id = group.id.clone();
ctx.link().send_future(async move { 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) => { Ok(resp) => {
if resp.ok() { if resp.ok() {
MsgListGroups::FinishLeave(id_group) MsgListGroups::FinishLeave(id_group)
} else { } else {
MsgListGroups::Error( MsgListGroups::Error(
String::from("Erreur"), String::from("Erreur"),
String::from("Pas de réponse 200") String::from("Pas de réponse 200"),
) )
} }
} }
Err(_) => { Err(_) => {
MsgListGroups::Error( MsgListGroups::Error(String::from("Erreur"), String::from("Bruh"))
String::from("Erreur"),
String::from("Bruh")
)
} }
} }
}); });
} else { } else {
ctx.link().send_message(MsgListGroups::Error( ctx.link().send_message(MsgListGroups::Error(
String::from("Erreur"), 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 false

View file

@ -4,8 +4,8 @@ mod list_groups;
pub use home::*; pub use home::*;
use list_groups::ListGroups; use list_groups::ListGroups;
use gloo_net::Error;
use gloo_net::http::Request; use gloo_net::http::Request;
use gloo_net::Error;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Deserialize, PartialEq, Serialize)] #[derive(Clone, Deserialize, PartialEq, Serialize)]