4 Commits

Author SHA1 Message Date
cd8b52cd29 Co-authored-by: jkassman <jkassman@users.noreply.github.com>
All checks were successful
Build Crate / build (push) Successful in 8m23s
2023-10-29 23:30:38 -04:00
319c77cfa3 Merge branch 'add_api' into main
All checks were successful
Build Crate / build (push) Successful in 3m16s
2023-09-22 14:35:36 -04:00
ae4cb23acb Merge pull request 'add_api' (#4) from add_api into main
Some checks failed
Build Crate / build (push) Failing after 3m31s
Reviewed-on: https://questia.dev/git/vsquad/pool-elo/pulls/4
2023-09-22 07:46:59 +00:00
f31e87780f Merge pull request 'Add simple data store' (#3) from simple_data_store into main
All checks were successful
Build Crate / build (push) Successful in 5m7s
Reviewed-on: https://questia.dev/git/vsquad/pool-elo/pulls/3
2023-09-20 05:07:31 +00:00
3 changed files with 38 additions and 18 deletions

View File

@@ -6,19 +6,17 @@ use serde::{Deserialize, Serialize};
pub type MatchId = u32;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum MatchData {
Standard8Ball {
winner: PlayerId,
loser: PlayerId,
},
Standard9Ball {
winner: PlayerId,
loser: PlayerId,
},
CutThroat {
winner: PlayerId,
losers: [PlayerId; 2],
},
pub enum MatchType {
Standard8Ball,
Standard9Ball,
CutThroat,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MatchData {
pub type_: MatchType,
pub winners: Vec<PlayerId>,
pub losers: Vec<PlayerId>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
@@ -28,6 +26,7 @@ pub struct PoolMatch {
#[serde(with = "ts_seconds")]
pub time: DateTime<Utc>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct PoolMatchList {
pub pool_matches: Vec<PoolMatch>,

View File

@@ -1,3 +1,4 @@
use crate::data::pool_match::MatchType;
use crate::{components::layout::Layout, data::pool_match::MatchData};
use perseus::prelude::*;
use serde::{Deserialize, Serialize};
@@ -28,7 +29,14 @@ fn add_game_form_page<'a, G: Html>(cx: BoundedScope<'_, 'a>, state: &'a PageStat
{
// state.name.get().as_ref().clone()
spawn_local_scoped(cx, async move {
let new_match = PoolMatch::new(MatchData::Standard8Ball { winner: 1, loser: 2 }, Utc::now());
let new_match = PoolMatch::new(
MatchData {
type_: MatchType::Standard8Ball,
winners: vec![1],
losers: vec![2, 3, 4],
},
Utc::now(),
);
let client = reqwest::Client::new();
let new_matches = client
.post(get_api_path(MATCH).as_str())

View File

@@ -1,13 +1,22 @@
use crate::{components::layout::Layout, templates::global_state::AppStateRx};
use crate::{components::layout::Layout, templates::global_state::AppStateRx, data::user::PlayerId};
use perseus::prelude::*;
use serde::{Deserialize, Serialize};
use sycamore::prelude::*;
use crate::data::pool_match::PoolMatch;
#[derive(Serialize, Deserialize, Clone, ReactiveState)]
#[rx(alias = "PageStateRx")]
struct PageState {}
fn format_list_or_single(to_format: &Vec<PlayerId>) -> String{
match to_format.len() {
1 => to_format[0].to_string(),
_ => format!("{:?}", to_format),
}
}
fn overall_board_page<'a, G: Html>(cx: BoundedScope<'_, 'a>, _state: &'a PageStateRx) -> View<G> {
let global_state = Reactor::<G>::from_cx(cx).get_global_state::<AppStateRx>(cx);
@@ -19,12 +28,16 @@ fn overall_board_page<'a, G: Html>(cx: BoundedScope<'_, 'a>, _state: &'a PageSta
.pool_matches
.iter()
.rev()
.enumerate()
.map(|(_index, item)| {
.map(|item: &PoolMatch| {
let game = item.clone();
view! { cx,
li {
li (class = "text-blue-700", id = "ha",) {
(game.id)
(" ")
(format_list_or_single(&game.data.winners))
(" ")
(format_list_or_single(&game.data.losers))
}
}
})