diff --git a/src/components/result_board.rs b/src/components/result_board.rs index d5de789..59fdf67 100644 --- a/src/components/result_board.rs +++ b/src/components/result_board.rs @@ -1,30 +1,40 @@ -use crate::consts::MAX_ATTEMPTS; +use crate::consts::{GameResult, MAX_ATTEMPTS}; use yew::prelude::*; use crate::consts::{Attempts, Status}; #[derive(Properties, PartialEq)] pub struct ResultBoardProps { + pub result: GameResult, pub attempts: Attempts, } #[function_component] pub fn ResultBoard(props: &ResultBoardProps) -> Html { let ResultBoardProps { + result, attempts, } = props; + let game_result_text = match result { + GameResult::Win => { + format!("Palabra encontrada en {}/{} intentos", attempts.fields.len(), MAX_ATTEMPTS) + } + GameResult::Fail => { + format!("Palabra no encontrada :c") + } + }; + html! {
- { format!("Palabra encontrada en {}/{} intentos", attempts.fields.len(), MAX_ATTEMPTS) } -
{ +
{ game_result_text }
+{
for attempts.fields.iter().map(|attempt| {
html_nested! {
<> {
for attempt.iter().map(| att| {
match att.status {
- Status::Found => html_nested! { <> { "🟩" } > },
+ Status::Found => html_nested! { <>{ "🟩" }> },
Status::Almost => html_nested! { <>{ "🟨" }> },
Status::NotFound => html_nested! { <>{ "⬛" }> }
@@ -33,7 +43,9 @@ pub fn ResultBoard(props: &ResultBoardProps) -> Html {
}
>
}
})
- }
{ "Vuelve mañana para otro reto" }