Loaded edit pages for each
This commit is contained in:
parent
661127b7e9
commit
71ec8e2234
@ -6,7 +6,7 @@ use yew_router::prelude::use_navigator;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api::backend::{
|
api::backend::{
|
||||||
get_project_listing, get_agent_with_id,
|
get_project_listing, get_agent_with_id, get_unit_with_id,
|
||||||
},
|
},
|
||||||
components::{
|
components::{
|
||||||
admin_nav_bar::AdminNavigationBar,
|
admin_nav_bar::AdminNavigationBar,
|
||||||
@ -23,6 +23,8 @@ pub fn edit_page(props: &AdminEditPageProps) -> Html {
|
|||||||
let unit = use_state(|| None);
|
let unit = use_state(|| None);
|
||||||
use_state(|| {
|
use_state(|| {
|
||||||
let listing = listing.clone();
|
let listing = listing.clone();
|
||||||
|
let agent = agent.clone();
|
||||||
|
let unit = unit.clone();
|
||||||
match props.edit_item {
|
match props.edit_item {
|
||||||
EditItem::Agent => {
|
EditItem::Agent => {
|
||||||
match props.edit_type {
|
match props.edit_type {
|
||||||
@ -56,7 +58,22 @@ pub fn edit_page(props: &AdminEditPageProps) -> Html {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EditItem::Unit(_) => {}
|
EditItem::Unit(_) => {
|
||||||
|
match props.edit_type {
|
||||||
|
EditType::New => {}
|
||||||
|
EditType::Existing(uid) => {
|
||||||
|
wasm_bindgen_futures::spawn_local(async move {
|
||||||
|
let unit_result = get_unit_with_id(&uid).await;
|
||||||
|
match unit_result {
|
||||||
|
Ok(unit_persisted) => {
|
||||||
|
unit.set(Some(unit_persisted));
|
||||||
|
}
|
||||||
|
Err(error) => log::error!("Error loading unit: {error}"),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,9 +95,9 @@ pub fn edit_page(props: &AdminEditPageProps) -> Html {
|
|||||||
<div class={"admin-project-fields-container"}>
|
<div class={"admin-project-fields-container"}>
|
||||||
{
|
{
|
||||||
match props.edit_item {
|
match props.edit_item {
|
||||||
EditItem::Agent => { html! { <AgentFields edittype={props.edit_type.clone()} agent={(*agent).clone()} /> } },
|
EditItem::Agent => { html! { <AgentFields agent={(*agent).clone()} edittype={props.edit_type.clone()} /> } },
|
||||||
EditItem::Project => { html! { <ProjectFields listing={(*listing).clone()} edittype={props.edit_type.clone()}/> } },
|
EditItem::Project => { html! { <ProjectFields listing={(*listing).clone()} edittype={props.edit_type.clone()}/> } },
|
||||||
EditItem::Unit(project_id) => { html! { <UnitFields edittype={props.edit_type.clone()} unit={}/> } },
|
EditItem::Unit(project_id) => { html! { <UnitFields edittype={props.edit_type.clone()} unit={(*unit).clone()} projectid={project_id}/> } },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use jl_types::domain::unit::Unit;
|
use jl_types::domain::unit::Unit;
|
||||||
|
use uuid::Uuid;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yew_router::prelude::use_navigator;
|
use yew_router::prelude::use_navigator;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user