diff --git a/Cargo.toml b/Cargo.toml index 1b23cb8..a9ebcd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,6 @@ wasm-bindgen = "0.2" # HTTP client for CalDAV requests reqwest = { version = "0.11", features = ["json"] } -wasm-bindgen-futures = "0.4" - # Calendar and iCal parsing ical = "0.7" serde = { version = "1.0", features = ["derive"] } @@ -30,7 +28,8 @@ log = "0.4" console_log = "1.0" # UUID generation for calendar events -uuid = { version = "1.0", features = ["v4", "wasm-bindgen"] } +uuid = { version = "1.0", features = ["v4", "wasm-bindgen", "serde"] } +getrandom = { version = "0.2", features = ["js"] } # Environment variable handling dotenvy = "0.15" @@ -39,5 +38,16 @@ base64 = "0.21" # XML/Regex parsing regex = "1.0" +# Frontend authentication (backend removed for WASM compatibility) +# sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "sqlite", "chrono", "uuid", "migrate"] } +# bcrypt = "0.15" +# jsonwebtoken = "9.0" + +# Yew routing and local storage +yew-router = "0.18" +gloo-storage = "0.3" +gloo-timers = "0.3" +wasm-bindgen-futures = "0.4" + [dev-dependencies] tokio = { version = "1.0", features = ["macros", "rt"] } \ No newline at end of file diff --git a/index.html b/index.html index 852782b..4fdf8c6 100644 --- a/index.html +++ b/index.html @@ -2,38 +2,260 @@ - Yew App + Calendar App diff --git a/src/app.rs b/src/app.rs index ca0bff9..694d188 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,7 +1,109 @@ use yew::prelude::*; +use yew_router::prelude::*; +use gloo_storage::{LocalStorage, Storage}; +use crate::components::{Login, Register}; + +#[derive(Clone, Routable, PartialEq)] +enum Route { + #[at("/")] + Home, + #[at("/login")] + Login, + #[at("/register")] + Register, + #[at("/calendar")] + Calendar, +} #[function_component] pub fn App() -> Html { + let auth_token = use_state(|| -> Option { + LocalStorage::get("auth_token").ok() + }); + + let on_login = { + let auth_token = auth_token.clone(); + Callback::from(move |token: String| { + auth_token.set(Some(token)); + }) + }; + + let on_logout = { + let auth_token = auth_token.clone(); + Callback::from(move |_| { + let _ = LocalStorage::delete("auth_token"); + auth_token.set(None); + }) + }; + + html! { + +
+
+

{"Calendar App"}

+ { + if auth_token.is_some() { + html! { + + } + } else { + html! { + + } + } + } +
+ +
+ render={move |route| { + let auth_token = (*auth_token).clone(); + let on_login = on_login.clone(); + + match route { + Route::Home => { + if auth_token.is_some() { + html! { to={Route::Calendar}/> } + } else { + html! { to={Route::Login}/> } + } + } + Route::Login => { + if auth_token.is_some() { + html! { to={Route::Calendar}/> } + } else { + html! { } + } + } + Route::Register => { + if auth_token.is_some() { + html! { to={Route::Calendar}/> } + } else { + html! { } + } + } + Route::Calendar => { + if auth_token.is_some() { + html! { } + } else { + html! { to={Route::Login}/> } + } + } + } + }} /> +
+
+
+ } +} + +#[function_component] +fn CalendarView() -> Html { let counter = use_state(|| 0); let onclick = { let counter = counter.clone(); @@ -12,13 +114,27 @@ pub fn App() -> Html { }; html! { -
-

{ "Hello Yew!" }

-

{ "This is a basic Yew application template." }

-
+
+

{"Welcome to your Calendar!"}

+

{"You are now authenticated and can access your calendar."}

+ + // Temporary counter demo - will be replaced with calendar functionality +
+

{"Demo Counter"}

{ format!("Counter: {}", *counter) }

+ +
+

{"Calendar functionality will be implemented here."}

+

{"This will include:"}

+
    +
  • {"Calendar view with events"}
  • +
  • {"Integration with CalDAV server"}
  • +
  • {"Event creation and editing"}
  • +
  • {"Synchronization with Baikal server"}
  • +
+
} } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4b28a47..0380f46 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,9 @@ -use yew::prelude::*; mod app; mod config; mod calendar; +mod auth; +mod components; use app::App;