feat: add redirect buttons to forms
This commit is contained in:
1 parent
142a60bc7c
commit
80340d99b9
1 file changed
+26
-45
@@ -1,55 +1,36 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
use leptos::logging::log;
|
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use crate::common::ValueType;
|
use crate::components::DashboardButton;
|
||||||
use crate::components::ActionButton;
|
|
||||||
use crate::pages::api::students::{GetStudentData, PutStudentData};
|
|
||||||
use crate::utils::get_user_claims;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn StudentHomePage() -> impl IntoView {
|
pub fn StudentHomePage() -> impl IntoView {
|
||||||
let user_claims = get_user_claims();
|
|
||||||
let user_id = Memo::new(move |_| {
|
|
||||||
user_claims.get()
|
|
||||||
.map(|info| info.claims.subject.clone())
|
|
||||||
});
|
|
||||||
|
|
||||||
let create_student_data = ServerAction::<PutStudentData>::new();
|
|
||||||
let get_student_data = ServerAction::<GetStudentData>::new();
|
|
||||||
|
|
||||||
let on_click_student_test = move |_| {
|
|
||||||
create_student_data.dispatch(PutStudentData {
|
|
||||||
subject: user_id.get().unwrap_or_default(),
|
|
||||||
data_type: "TESTING".into(),
|
|
||||||
data_map: HashMap::from([
|
|
||||||
("testing_info".into(), ValueType::String(Some("hello!".to_string())))
|
|
||||||
]),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
let on_click_get_student = move |_| {
|
|
||||||
get_student_data.dispatch(GetStudentData {
|
|
||||||
subject: user_id.get().unwrap_or_default(),
|
|
||||||
data_type: "TESTING".into()
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Effect::new(move || {
|
|
||||||
let Some(value) = get_student_data.value().get() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
log!("{:?}", value);
|
|
||||||
});
|
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="flex flex-1 flex-col gap-4 items-center m-4">
|
<div class="flex-1" />
|
||||||
<div class="font-bold text-3xl">"Student Home Page"</div>
|
<div class="flex flex-2 flex-col gap-4 items-center m-4 mt-10">
|
||||||
|
<div class="font-bold text-3xl">"Region 15 Scholarship Application"</div>
|
||||||
<div class="text-lg">
|
<div class="text-lg">
|
||||||
"This is just a placeholder for now. We'll show some redirect buttons."
|
"Welcome to the R15 general scholarship application! If you have any questions, please direct them to Sara Smith at "
|
||||||
|
<a class="text-blue-500 underline" href="mailto:ssmith@region15.org">"ssmith@region15.org"</a>"."
|
||||||
</div>
|
</div>
|
||||||
<ActionButton on:click=on_click_student_test>"Test Put Student Function"</ActionButton>
|
<div class="text-lg">"Here are some links to get you started:"</div>
|
||||||
<ActionButton on:click=on_click_get_student>"Test Get Student Function"</ActionButton>
|
<DashboardButton
|
||||||
|
title="Scholarship Book"
|
||||||
|
description="View scholarship requirements"
|
||||||
|
icon="/Book.png"
|
||||||
|
path="https://docs.google.com/document/d/1qVs0Lwvwl1bVGHznocoev3AF56KlhTfs/view"
|
||||||
|
/>
|
||||||
|
<DashboardButton
|
||||||
|
title="Demographics Forms"
|
||||||
|
description="Basic student information"
|
||||||
|
icon="/Person_Black.png"
|
||||||
|
path="/students/demographics"
|
||||||
|
/>
|
||||||
|
<DashboardButton
|
||||||
|
title="Additional Forms"
|
||||||
|
description="Extra eligibility factors"
|
||||||
|
icon="/Form_Black.png"
|
||||||
|
path="/students/demographics"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex-1" />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user