router implementation

This commit is contained in:
Priec
2025-08-22 22:19:59 +02:00
parent 6833ac5fad
commit 957f5bf9f0
9 changed files with 225 additions and 180 deletions

3
client/src/pages/mod.rs Normal file
View File

@@ -0,0 +1,3 @@
// src/pages/mod.rs
pub mod routing;

View File

@@ -0,0 +1,5 @@
// src/pages/routing/mod.rs
pub mod router;
pub use router::{Page, Router};

View File

@@ -0,0 +1,36 @@
// src/pages/routing/router.rs
use crate::state::pages::{
admin::AdminState,
auth::{AuthState, LoginState, RegisterState},
form::FormState,
intro::IntroState,
add_logic::AddLogicState,
add_table::AddTableState,
};
#[derive(Debug)]
pub enum Page {
Intro(IntroState),
Login(LoginState),
Register(RegisterState),
Admin(AdminState),
AddLogic(AddLogicState),
AddTable(AddTableState),
Form(FormState),
}
pub struct Router {
pub current: Page,
}
impl Router {
pub fn new() -> Self {
Self {
current: Page::Intro(IntroState::default()),
}
}
pub fn navigate(&mut self, page: Page) {
self.current = page;
}
}