-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*Adds tournament schedules, refactors and styles tournament page --------- Co-authored-by: ioni <[email protected]>
- Loading branch information
1 parent
6204ec6
commit a2335ae
Showing
51 changed files
with
1,361 additions
and
404 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
use shared_types::{GameId, TournamentId}; | ||
use std::fmt; | ||
use uuid::Uuid; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum ScheduleAction { | ||
Propose(DateTime<Utc>, GameId), | ||
Accept(Uuid), | ||
Cancel(Uuid), | ||
TournamentPublic(TournamentId), | ||
TournamentOwn(TournamentId), | ||
} | ||
|
||
impl fmt::Display for ScheduleAction { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Self::Propose(date, game_id) => write!(f, "Propose({date}, {game_id})"), | ||
Self::Accept(game_id) => write!(f, "Accept({game_id})"), | ||
Self::Cancel(game_id) => write!(f, "Cancel({game_id})"), | ||
Self::TournamentPublic(id) => write!(f, "TournamentPublic({id})"), | ||
Self::TournamentOwn(id) => write!(f, "TournamentOwn({id})"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use chrono::{DateTime, Duration, Local, NaiveDateTime, Utc}; | ||
use leptos::*; | ||
|
||
#[component] | ||
pub fn DateTimePicker( | ||
text: &'static str, | ||
min: DateTime<Local>, | ||
max: DateTime<Local>, | ||
success_callback: Callback<DateTime<Utc>>, | ||
#[prop(optional)] failure_callback: Option<Callback<()>>, | ||
) -> impl IntoView { | ||
view! { | ||
<label>{text}</label> | ||
<input | ||
type="datetime-local" | ||
id="start-time" | ||
name="start-time" | ||
class="p-1 rounded-md" | ||
attr:min=move || { min.format("%Y-%m-%dT%H:%M").to_string() } | ||
|
||
attr:max=move || { max.format("%Y-%m-%dT%H:%M").to_string() } | ||
|
||
value=(min + Duration::minutes(1)).format("%Y-%m-%dT%H:%M").to_string() | ||
on:input=move |evt| { | ||
if let Ok(date) = NaiveDateTime::parse_from_str( | ||
&event_target_value(&evt), | ||
"%Y-%m-%dT%H:%M", | ||
) { | ||
let dt = Local::now(); | ||
let offset = dt.offset(); | ||
if let chrono::LocalResult::Single(local) = NaiveDateTime::and_local_timezone( | ||
&date, | ||
*offset, | ||
) { | ||
let utc = local.to_utc(); | ||
success_callback(utc); | ||
} | ||
} else if let Some(failure_callback) = failure_callback { | ||
failure_callback(()); | ||
} | ||
} | ||
/> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.