Implement provider scholarship edit form #33

Merged
BobdaFett merged 10 commits from feature/scholarship-edit-form into main 2025-12-22 17:49:27 +00:00
Showing only changes of commit bab47ac4af - Show all commits
+145 -136
View File
1
@@ -259,7 +259,7 @@ fn ScholarshipForm(
}); });
let comparison_list: Resource<Vec<ComparisonData>> = Resource::new( let comparison_list: Resource<Vec<ComparisonData>> = Resource::new(
move || (), // There's no input to this function. move || scholarship_id.get(), // There's no input to this function.
async move |_| { async move |_| {
get_comparison_info().await get_comparison_info().await
.unwrap_or_else(|e| { .unwrap_or_else(|e| {
@@ -269,10 +269,14 @@ fn ScholarshipForm(
} }
); );
let scholarship_info: Resource<Result<ExpandableInfo, ServerFnError>> = Resource::new( let scholarship_info = Resource::new(
move || scholarship_id.get().unwrap_or_default(), move || scholarship_id.get(),
async move |id| { async move |opt_id| {
get_scholarship_info(id).await if let Some(id) = opt_id {
get_scholarship_info(id).await
} else {
Err(ServerFnError::new("Cannot get from server with no ID."))
}
} }
); );
@@ -296,139 +300,144 @@ fn ScholarshipForm(
view! { view! {
<Panel> <Panel>
<Suspense fallback=Loading> <Show
{move || { when=move || scholarship_id.get().is_some()
scholarship_info.get() fallback=|| view! { <p>"Choose a scholarship from the right, or create a new one."</p> }
.map(|res_scholarship| { >
match res_scholarship { <Suspense fallback=Loading>
Ok(scholarship) => { {move || {
let reactive_info = scholarship.as_reactive(); scholarship_info.get()
.map(|res_scholarship| {
match res_scholarship {
Ok(scholarship) => {
let reactive_info = scholarship.as_reactive();
Either::Left(view! { Either::Left(view! {
<Row> <Row>
<h1 class="text-3xl font-bold"> <h1 class="text-3xl font-bold">
"Scholarship Info Form (test)" "Scholarship Info Form (test)"
</h1> </h1>
</Row> </Row>
<Row> <Row>
<OutlinedTextField <OutlinedTextField
label="Scholarship Name" label="Scholarship Name"
placeholder="Example Scholarship Name" placeholder="Example Scholarship Name"
disabled=elements_disabled disabled=elements_disabled
data_member="name" data_member="name"
data_map=reactive_info.data data_map=reactive_info.data
/> />
</Row> </Row>
<Row> <Row>
<OutlinedTextField <OutlinedTextField
label="Amount per award: (if multiple, enter the highest value)" label="Amount per award: (if multiple, enter the highest value)"
placeholder="Enter an amount..." placeholder="Enter an amount..."
disabled=elements_disabled disabled=elements_disabled
data_member="amount_per_award" data_member="amount_per_award"
data_map=reactive_info.data data_map=reactive_info.data
input_type="number" input_type="number"
/> />
</Row> </Row>
<Row> <Row>
<OutlinedTextField <OutlinedTextField
label="Total number of awards:" label="Total number of awards:"
placeholder="Enter an amount..." placeholder="Enter an amount..."
disabled=elements_disabled disabled=elements_disabled
data_member="num_awards" data_member="num_awards"
data_map=reactive_info.data data_map=reactive_info.data
input_type="number" input_type="number"
/> />
</Row> </Row>
<Row> <Row>
<OutlinedTextField <OutlinedTextField
label="Total amount of all awards:" label="Total amount of all awards:"
placeholder="Enter an amount..." placeholder="Enter an amount..."
disabled=elements_disabled disabled=elements_disabled
data_member="total_awards" data_member="total_awards"
data_map=reactive_info.data data_map=reactive_info.data
input_type="number" input_type="number"
/> />
</Row> </Row>
<Row> <Row>
<RadioList <RadioList
data_member="fafsa_required" data_member="fafsa_required"
data_map=reactive_info.data data_map=reactive_info.data
items=vec!["Yes".to_string(), "No".to_string()] items=vec!["Yes".to_string(), "No".to_string()]
disabled=elements_disabled disabled=elements_disabled
label="Do you require student financial information?" label="Do you require student financial information?"
meraghon commented 2025-12-19 18:27:43 +00:00 (Migrated from github.com)
Review

of created scholarship doesn't update after submit.

<no name found> of created scholarship doesn't update after submit.
/> />
</Row> </Row>
<Row> <Row>
<RadioList <RadioList
data_member="transcript_required" data_member="transcript_required"
data_map=reactive_info.data data_map=reactive_info.data
items=vec!["Yes".to_string(), "No".to_string()] items=vec!["Yes".to_string(), "No".to_string()]
disabled=elements_disabled disabled=elements_disabled
label="Do you require a student transcript?" label="Do you require a student transcript?"
/> />
</Row> </Row>
<Row> <Row>
<RadioList <RadioList
data_member="award_to" data_member="award_to"
data_map=reactive_info.data data_map=reactive_info.data
items=vec!["School".to_string(), "Student".to_string()] items=vec!["School".to_string(), "Student".to_string()]
disabled=elements_disabled disabled=elements_disabled
label="Will the award be made to the school or the student?" label="Will the award be made to the school or the student?"
/> />
</Row> </Row>
<Row> <Row>
<RadioList <RadioList
data_member="essay_required" data_member="essay_required"
data_map=reactive_info.data data_map=reactive_info.data
items=vec!["Yes".to_string(), "No".to_string()] items=vec!["Yes".to_string(), "No".to_string()]
disabled=elements_disabled disabled=elements_disabled
label="Do you require a student essay?" label="Do you require a student essay?"
/> />
</Row> </Row>
<Row> <Row>
<RadioList <RadioList
data_member="essay_prompt" data_member="essay_prompt"
data_map=reactive_info.data data_map=reactive_info.data
items=vec!["Test 1", "Test 2", "Test 3"].iter().map(|s| s.to_string()).collect() items=vec!["Test 1", "Test 2", "Test 3"].iter().map(|s| s.to_string()).collect()
disabled=elements_disabled disabled=elements_disabled
label="If so, select a prompt from the list below." label="If so, select a prompt from the list below."
/> />
</Row> </Row>
<Row> <Row>
<ChipsList <ChipsList
label="Scholarship Requirements" label="Scholarship Requirements"
data_member="requirements" data_member="requirements"
data_map=reactive_info.data data_map=reactive_info.data
values=comparison_ids values=comparison_ids
displayed_text=comparison_text displayed_text=comparison_text
/> />
</Row> </Row>
<Row> <Row>
<ActionButton <ActionButton
disabled=elements_disabled disabled=elements_disabled
on:click=move |_| { on:click=move |_| {
let captured = reactive_info.capture(); let captured = reactive_info.capture();
log!("Map values: {:?}", captured); log!("Map values: {:?}", captured);
submit_action.dispatch(CreateScholarshipInfo { submit_action.dispatch(CreateScholarshipInfo {
info: captured info: captured
}); });
} }
>"Submit"</ActionButton> >"Submit"</ActionButton>
</Row> </Row>
<Row> <Row>
<p>{result_msg}</p> <p>{result_msg}</p>
</Row> </Row>
}) })
}
Err(err) => {
Either::Right(view! {
<p>"Error while getting scholarship: "{err.to_string()}</p>
})
}
} }
Err(err) => { }).collect_view()
Either::Right(view! { }}
<p>"Error while getting scholarship: "{err.to_string()}</p> </Suspense>
}) </Show>
}
}
}).collect_view()
}}
</Suspense>
</Panel> </Panel>
} }
} }