PR with too many features #58

Merged
BobdaFett merged 56 commits from feat/admin-page into main 2026-02-10 14:31:49 +00:00
4 changed files with 15 additions and 18 deletions
Showing only changes of commit 7d02c6505e - Show all commits

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
use leptos::prelude::*; use leptos::prelude::*;
use leptos::logging::log; use leptos::logging::debug_log;
use std::collections::HashMap; use std::collections::HashMap;
use leptos::server_fn::codec::Json; use leptos::server_fn::codec::Json;
use crate::common::ValueType; use crate::common::ValueType;
@@ -17,7 +17,7 @@ pub async fn get_provider_contact(id: String) -> Result<HashMap<String, ValueTyp
let client = create_dynamo_client().await; let client = create_dynamo_client().await;
log!("Getting contact info for provider {}", id); debug_log!("Getting contact info for provider {}", id);
match client match client
.get_item() .get_item()
+7 -8
View File
@@ -1,22 +1,21 @@
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
mod imports { mod imports {
pub use leptos::logging::debug_log;
pub use aws_sdk_dynamodb::{ pub use aws_sdk_dynamodb::{
types::AttributeValue, types::AttributeValue,
error::ProvideErrorMetadata, error::ProvideErrorMetadata,
}; };
pub use leptos::leptos_dom::log; pub use leptos::leptos_dom::log;
pub use uuid::Uuid; pub use uuid::Uuid;
pub use crate::utils::server::{create_dynamo_client, into_attr_map}; pub use crate::utils::server::{create_dynamo_client};
pub use crate::common::ValueType; pub use crate::common::ValueType;
pub use super::super::SCHOLARSHIPS_TABLE;
} }
use crate::common::ExpandableInfo; use crate::common::ExpandableInfo;
use leptos::prelude::ServerFnError; use leptos::prelude::ServerFnError;
use leptos::server; use leptos::server;
use leptos::server_fn::codec::Json; use leptos::server_fn::codec::Json;
#[cfg(feature = "ssr")]
use super::SCHOLARSHIPS_TABLE;
#[server(GetScholarshipInfo)] #[server(GetScholarshipInfo)]
pub async fn get_scholarship_info(id: String) -> Result<ExpandableInfo, ServerFnError> { pub async fn get_scholarship_info(id: String) -> Result<ExpandableInfo, ServerFnError> {
@@ -79,7 +78,7 @@ pub async fn get_all_scholarship_info() -> Result<Vec<ExpandableInfo>, ServerFnE
use imports::*; use imports::*;
let client = create_dynamo_client().await; let client = create_dynamo_client().await;
log!("Getting all scholarship info"); debug_log!("Getting all scholarship info");
match client match client
.scan() .scan()
.table_name(SCHOLARSHIPS_TABLE) .table_name(SCHOLARSHIPS_TABLE)
@@ -107,7 +106,7 @@ pub async fn get_provider_scholarships(provider_id: String) -> Result<Vec<Expand
let client = create_dynamo_client().await; let client = create_dynamo_client().await;
log!("Getting provider scholarships for provider with ID {:?}", provider_id); debug_log!("Getting provider scholarships for provider with ID {:?}", provider_id);
match client match client
.scan() .scan()
@@ -138,7 +137,7 @@ pub async fn register_scholarship(provider_id: String) -> Result<String, ServerF
let client = create_dynamo_client().await; let client = create_dynamo_client().await;
log!("Creating scholarship for provider with ID {:?}", provider_id); debug_log!("Creating scholarship for provider with ID {:?}", provider_id);
let mut current_uuid = Uuid::new_v4().to_string(); let mut current_uuid = Uuid::new_v4().to_string();
let mut item = ExpandableInfo::new(current_uuid.clone()); let mut item = ExpandableInfo::new(current_uuid.clone());
@@ -184,7 +183,7 @@ pub async fn delete_provider_scholarship(provider_id: String, scholarship_id: St
let client = create_dynamo_client().await; let client = create_dynamo_client().await;
log!("Deleting scholarship with ID {:?} for provider with ID {:?}", scholarship_id, provider_id); debug_log!("Deleting scholarship with ID {:?} for provider with ID {:?}", scholarship_id, provider_id);
// When we delete a scholarship, we need to ensure that the provider's ID matches the scholarship, // When we delete a scholarship, we need to ensure that the provider's ID matches the scholarship,
// otherwise everyone can delete anyone else's scholarships. // otherwise everyone can delete anyone else's scholarships.
+2 -2
View File
@@ -8,6 +8,7 @@ mod imports {
pub use super::super::MAIN_TABLE_NAME; pub use super::super::MAIN_TABLE_NAME;
pub use crate::common::ValueType; pub use crate::common::ValueType;
pub use std::collections::HashMap; pub use std::collections::HashMap;
pub use leptos::logging::debug_log;
} }
#[server(input = Json)] #[server(input = Json)]
@@ -16,7 +17,6 @@ pub async fn put_student_data(
data_type: String, data_type: String,
data_map: std::collections::HashMap<String, crate::common::ValueType> data_map: std::collections::HashMap<String, crate::common::ValueType>
) -> Result<(), ServerFnError> { ) -> Result<(), ServerFnError> {
use leptos::logging::log;
use imports::*; use imports::*;
let client = create_dynamo_client().await; let client = create_dynamo_client().await;
@@ -31,7 +31,7 @@ pub async fn put_student_data(
AttributeValue::S(data_type.to_uppercase()) AttributeValue::S(data_type.to_uppercase())
); );
log!("Inserting this item: {:?}", data_map_attr); debug_log!("Inserting this item: {:?}", data_map_attr);
client client
.put_item() .put_item()
+4 -6
View File
@@ -1,4 +1,4 @@
use leptos::logging::log; use leptos::logging::debug_log;
use leptos::prelude::*; use leptos::prelude::*;
use crate::common::{ComparisonData, ExpandableInfo, ValueType}; use crate::common::{ComparisonData, ExpandableInfo, ValueType};
use crate::pages::api::{get_all_scholarship_info, get_comparison_info}; use crate::pages::api::{get_all_scholarship_info, get_comparison_info};
@@ -66,7 +66,7 @@ pub fn StudentEligibilityPage() -> impl IntoView {
let scholarship_name = scholarship.data.get("name") let scholarship_name = scholarship.data.get("name")
.unwrap_or(&ValueType::String(None)) .unwrap_or(&ValueType::String(None))
.as_string().ok().flatten().unwrap_or_default(); .as_string().ok().flatten().unwrap_or_default();
log!("Checking scholarship: {}", scholarship_name); debug_log!("Checking scholarship: {}", scholarship_name);
// Each scholarship will return Some(itself), or None. This is will be automatically // Each scholarship will return Some(itself), or None. This is will be automatically
// filtered based on the information. Invalid scholarships are None, along with those // filtered based on the information. Invalid scholarships are None, along with those
@@ -78,8 +78,6 @@ pub fn StudentEligibilityPage() -> impl IntoView {
.unwrap_or_default() .unwrap_or_default()
.values().cloned() .values().cloned()
.collect::<Vec<ValueType>>(); .collect::<Vec<ValueType>>();
log!("Requirements list after conversion: {:?}", requirements_map);
let resolved_requirements = requirements_map let resolved_requirements = requirements_map
.iter() .iter()
@@ -97,7 +95,7 @@ pub fn StudentEligibilityPage() -> impl IntoView {
}) })
.collect::<Vec<Vec<ComparisonData>>>(); .collect::<Vec<Vec<ComparisonData>>>();
log!("Resolved requirements: {:?}", resolved_requirements.iter().flatten().map(|rel| rel.display_text.clone()).collect::<Vec<String>>()); debug_log!("Resolved requirements: {:?}", resolved_requirements.iter().flatten().map(|rel| rel.display_text.clone()).collect::<Vec<String>>());
let valid = resolved_requirements.iter() let valid = resolved_requirements.iter()
.all(|list| { .all(|list| {
@@ -110,7 +108,7 @@ pub fn StudentEligibilityPage() -> impl IntoView {
}); });
if valid { if valid {
log!("Scholarship is valid."); debug_log!("Scholarship is valid.");
Some(scholarship.clone()) Some(scholarship.clone())
} else { } else {
None None