DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

034f40963ca7d9d9594f7cf7975f2b9536dd0105 — Jonni Liljamo 1 year, 10 months ago e722410
feat(sdbclient): adhere to new API responses
M sdbclient/src/api/game/types.rs => sdbclient/src/api/game/types.rs +6 -2
@@ 8,13 8,17 @@

use serde::{Deserialize, Serialize};

use crate::api::user::types::UserPub;

#[derive(Debug, Serialize, Deserialize)]
pub struct Game {
    pub id: String,
    pub created_at: String,
    pub updated_at: String,
    pub p1: String,
    pub p2: String,
    pub host_id: String,
    pub host: UserPub,
    pub guest_id: String,
    pub guest: UserPub,
    pub state: u8,
    pub ended_at: String,
}

M sdbclient/src/api/user/mod.rs => sdbclient/src/api/user/mod.rs +4 -9
@@ 1,6 1,6 @@
/*
 * This file is part of sdbclient
 * Copyright (C) 2022 Jonni Liljamo <jonni@liljamo.com>
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.


@@ 11,6 11,8 @@ use serde::{Deserialize, Serialize};

use super::APIErrorWrapper;

pub mod types;

#[derive(Serialize)]
pub struct PostToken {
    pub email: String,


@@ 50,17 52,10 @@ pub struct PostRegister {
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ResultRegister {
    pub id: String,
    pub username: String,
    pub email: String,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResponseRegister {
    Error(APIErrorWrapper),
    Valid(ResultRegister),
    Valid(types::UserPub),
}

pub fn register(

A sdbclient/src/api/user/types.rs => sdbclient/src/api/user/types.rs +17 -0
@@ 0,0 1,17 @@
/*
 * This file is part of sdbclient
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct UserPub {
    pub id: String,
    pub created_at: String,
    pub updated_at: String,
    pub username: String,
}

M sdbclient/src/plugins/menu/accountregister/mod.rs => sdbclient/src/plugins/menu/accountregister/mod.rs +1 -1
@@ 120,7 120,7 @@ fn handle_register_call(
                            user_token: token_res.token,
                            id: register_res.id,
                            username: register_res.username,
                            email: register_res.email,
                            email: inputs.email.clone(),
                        };

                        save_event_writer.send(SaveEvent {

M sdbclient/src/plugins/menu/play/ui.rs => sdbclient/src/plugins/menu/play/ui.rs +4 -1
@@ 100,7 100,10 @@ pub(super) fn show(
                                                    .inner_margin(4.)
                                                    .show(ui, |ui| {
                                                        ui.horizontal(|ui| {
                                                            ui.label(format!("Host: {}", game.p1));
                                                            ui.label(format!(
                                                                "Host: {}",
                                                                game.host.username
                                                            ));
                                                            ui.with_layout(
                                                                egui::Layout::right_to_left(
                                                                    egui::Align::Center,