cargo fmt
This commit is contained in:
parent
3be7ac3336
commit
e1d720f5d6
3 changed files with 27 additions and 27 deletions
|
@ -34,9 +34,7 @@ impl Component for Home {
|
|||
type Properties = ();
|
||||
|
||||
fn create(_ctx: &Context<Self>) -> Self {
|
||||
Self {
|
||||
user: None,
|
||||
}
|
||||
Self { user: None }
|
||||
}
|
||||
|
||||
fn view(&self, ctx: &Context<Self>) -> Html {
|
||||
|
|
|
@ -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<Html> = Vec::new();
|
||||
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! {
|
||||
|
@ -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
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue