Created a domain module to decouple flows from the core.

This commit is contained in:
2025-05-03 22:49:01 +02:00
parent fce0ebd76b
commit 4e26d3cdcb
9 changed files with 54 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
use gamenight_api_client_rs::{apis::default_api::post_gamenight, models};
use inquire::{Text, DateSelect};
use inquire::{CustomType, DateSelect, Text};
use chrono::{self, Local, NaiveTime};
use super::*;
@@ -21,9 +21,14 @@ impl<'a> Flow<'a> for AddGamenight {
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
let mut add_gamenight = models::AddGamenightRequestBody::new();
add_gamenight.name = Some(Text::new("What should we call your gamenight").prompt()?);
add_gamenight.datetime = Some(DateSelect::new("When is your gamenight").prompt()?
.and_time(NaiveTime::default())
add_gamenight.name = Some(Text::new("What should we call your gamenight")
.prompt()?);
let naive_date = DateSelect::new("When is your gamenight")
.prompt()?;
let naive_time = CustomType::<NaiveTime>::new("At What time")
.prompt()?;
add_gamenight.datetime = Some(naive_date
.and_time(naive_time)
.and_local_timezone(Local)
.earliest()
.unwrap()