Start on the client module

This commit is contained in:
Savanni D'Gerinel 2025-02-18 21:36:01 -05:00
parent 20b214df10
commit 1c4894df9a
2 changed files with 48 additions and 6 deletions

39
visions/ui/src/client.rs Normal file
View File

@ -0,0 +1,39 @@
use gloo_net::http::Request;
use serde::Deserialize;
#[derive(Deserialize)]
enum AuthResponse {
Ok(SessionId),
PasswordReset(SessionId),
}
#[derive(Deserialize)]
struct SessionId(String);
enum ClientError {
Unauthorized,
}
#[derive(Deserialize)]
struct UserId(String);
#[derive(Deserialize)]
struct UserInfo {
id: UserId,
name: String,
}
trait Client {
async fn auth(username: String, password: String) -> Result<AuthResponse, ClientError>;
async fn list_users(session_id: SessionId) -> Result<Vec<UserInfo>, ClientError>;
}
impl Client for Connection {
async fn auth(username: String, password: String) -> Result<AuthResponse, ClientError> {
let request = Request::post("http://localhost:8001")
.body().unwrap();
}
async fn list_users(session_id: SessionId) -> Result<Vec<UserInfo>, ClientError> {
}
}

View File

@ -2,6 +2,9 @@ use std::rc::Rc;
use yew::prelude::*;
mod client;
pub use client::*;
struct AuthInfo {
session_id: Option<String>,
}
@ -44,12 +47,12 @@ fn Login(LoginProps { on_click }: &LoginProps) -> Html {
};
html! {
<div class="login-form">
<div class="card">
<h1>{"Welcome to Visions VTT"}</h1>
<input type="text" name="username" placeholder="username" />
<input type="password" name="password" placeholder="password" />
<button onclick={on_click}>{"Login"}</button>
</div>
<div class="card">
<h1>{"Welcome to Visions VTT"}</h1>
<input type="text" name="username" placeholder="username" />
<input type="password" name="password" placeholder="password" />
<button onclick={on_click}>{"Login"}</button>
</div>
</div>
}
}