feat: display a project form upon clicking the create button on the projects page

This commit is contained in:
2024-09-05 18:18:03 +02:00
parent 270e06de46
commit fe1837d6a1
13 changed files with 138 additions and 46 deletions

View File

@ -1,7 +1,36 @@
use dioxus::prelude::*;
use dioxus_query::prelude::QueryResult;
use crate::query::projects::use_projects_query;
use crate::query::QueryValue;
#[component]
pub(crate) fn ProjectsPage() -> Element {
let projects_query = use_projects_query();
rsx! {
match projects_query.result().value() {
QueryResult::Ok(QueryValue::Projects(projects))
| QueryResult::Loading(Some(QueryValue::Projects(projects))) => rsx! {
div {
class: "flex flex-col",
for project in projects {
div {
key: "{project.id()}",
class: "px-8 py-4",
{project.title()}
}
}
}
},
QueryResult::Loading(None) => rsx! {
// TODO: Add a loading indicator.
},
QueryResult::Err(errors) => rsx! {
div {
"Errors occurred: {errors:?}"
}
},
value => panic!("Unexpected query result: {value:?}")
}
}
}