42 lines
961 B
Rust
42 lines
961 B
Rust
|
|
use inquire::Select;
|
|
|
|
use crate::{domain::gamenight::Gamenight, flows::exit::Exit};
|
|
|
|
use super::*;
|
|
|
|
#[derive(Clone)]
|
|
pub struct ViewGamenight {
|
|
gamenight: Gamenight
|
|
}
|
|
|
|
impl ViewGamenight {
|
|
pub fn new(gamenight: Gamenight) -> Self {
|
|
Self {
|
|
gamenight
|
|
}
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
impl<'a> Flow<'a> for ViewGamenight {
|
|
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
|
|
|
|
print!("{}", self.gamenight);
|
|
let options: Vec<Box<dyn Flow<'a> + Send>> = vec![
|
|
Box::new(Exit::new())
|
|
];
|
|
let choice = Select::new("What do you want to do:", options)
|
|
.prompt_skippable()?;
|
|
|
|
handle_choice_option(&choice, self, state).await
|
|
}
|
|
}
|
|
|
|
impl Display for ViewGamenight {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{} {}", self.gamenight.name, self.gamenight.start_time.format("%d-%m-%Y %H:%M"))
|
|
}
|
|
}
|
|
|