Files
scholarships-rs/src/pages/provider_entry.rs
T
alphafetus 059f904f5d feat: update checkbox component to use open-ended structures
Commit also includes changes to other components that make unused props optional.
2025-09-25 12:31:47 -04:00

51 lines
2.2 KiB
Rust

use std::collections::HashMap;
use crate::app::Unauthenticated;
use crate::common::UserClaims;
use crate::components::{Loading, MultiEntry, MultiEntryData, MultiEntryMember, OutlinedTextField, ValueType};
use leptos::leptos_dom::logging::console_log;
use leptos::prelude::*;
use leptos_oidc::{Algorithm, AuthLoaded, AuthSignal, Authenticated, LogoutLink};
#[component]
pub fn ProviderEntry() -> impl IntoView {
let auth = use_context::<AuthSignal>().expect("Couldn't find auth signal");
let auth_data = auth
.get()
.authenticated()
.and_then(|data| data.decoded_access_token::<UserClaims>(Algorithm::RS256, &["account"]));
let multi_entries: RwSignal<Vec<MultiEntryData>> = RwSignal::new(vec![]);
console_log(format!("User claims: {auth_data:?}").as_str());
view! (
<AuthLoaded fallback=Loading>
<Authenticated unauthenticated=Unauthenticated>
<LogoutLink class="text-logout">"Sign out"</LogoutLink>
<h1>This is the provider entry page</h1>
<h2>It would usually have a series of questions that we ask the providers</h2>
<div>
// Much of this is just a placeholder.
<OutlinedTextField
placeholder = "Testing information..."
name = "testing_input"
label = "This is a testing question."
data_member = "testing"
data_map = RwSignal::new(HashMap::new())
value = RwSignal::new(ValueType::String(None))
/>
</div>
<div>
<p>This is an example of the multientry element.</p>
<MultiEntry
entries=multi_entries
name_member=Signal::from(MultiEntryMember::from_str("Entry Name", "name"))
info_member=Signal::from(MultiEntryMember::from_str("Entry Info", "info"))
schema=vec![MultiEntryMember::from_str("Entry Name", "name"), MultiEntryMember::from_str("Entry Info", "info")]
/>
</div>
</Authenticated>
</AuthLoaded>
)
}