Fixed default in dropdown (for project)

This commit is contained in:
Franklin 2023-04-25 08:04:10 -04:00
parent 04733dc806
commit 58c18625b6

View File

@ -198,19 +198,32 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html {
location_district.set(listing_opt.clone().unwrap_or_default().location.district);
agent.set(match listing_opt.clone() {
Some(listing) => Some(listing.agent),
None => None,
None => {
let agents = (*all_agents).clone();
if let Some(default_agent) = agents.last() {
Some(default_agent.clone())
} else {
None
}
},
});
project_state.set(match listing_opt.clone() {
Some(listing) => Some(listing.project.project_state),
None => None,
None => {
Some(ProjectState::InConstruction)
},
});
project_condition.set(match listing_opt.clone() {
Some(listing) => Some(listing.project.project_condition),
None => None,
None => {
Some(ProjectCondition::New)
},
});
project_type.set(match listing_opt.clone() {
Some(listing) => Some(listing.project.project_type),
None => None,
None => {
Some(ProjectType::Solar)
},
});
project_description.set(match listing_opt.clone() {
Some(listing) => listing.project.description,
@ -273,6 +286,7 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html {
let project_finish_date_handle = project_finish_date.clone();
let project_floors_handle = project_floors.clone();
let media_handle = media.clone();
wasm_bindgen_futures::spawn_local(async move {
let location = match get_location_with_city_and_district(
(*location_city_handle).clone(),
@ -297,7 +311,6 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html {
}
}
};
//TODO: Give all of these default values?
let agent_id = match (*agent_handle).clone() {
Some(selected_agent) => selected_agent.id,
None => {