Add date list component #50

Merged
BobdaFett merged 37 commits from feat/date-component into main 2026-01-16 14:02:18 +00:00
Showing only changes of commit bde15de634 - Show all commits
+1 -94
View File
@@ -5,96 +5,7 @@ use leptos::prelude::*;
use crate::pages::api::{get_important_dates, CreateDates};
#[component]
pub fn TestPage() -> impl IntoView {
let reload_signal = RwSignal::new(0);
let dates_resource = Resource::new(
move || reload_signal.get(),
async move |_| {
get_important_dates().await
}
);
let dates_list = RwSignal::new(Vec::new());
Effect::new(move || {
if let Some(Ok(mut dates)) = dates_resource.get() {
dates.sort_by_key(|info| info.date.get_status());
dates_list.set(dates);
}
});
let create_dates = ServerAction::<CreateDates>::new();
let on_click = move |_| {
let dates_list = vec![
DateInfo {
id: uuid::Uuid::new_v4().to_string(),
title: "Open Example".to_string(),
date: DateRange::Range(
DateTime::parse_from_rfc3339("2026-01-15T07:15:00-05:00")
.unwrap_or_default(),
DateTime::parse_from_rfc3339("2026-01-30T14:05:00-05:00")
.unwrap_or_default()
),
description: "This is a test".to_string(),
},
DateInfo {
id: uuid::Uuid::new_v4().to_string(),
title: "Closed Example".to_string(),
date: DateRange::Range(
DateTime::parse_from_rfc3339("2026-01-01T07:15:00-05:00")
.unwrap_or_default(),
DateTime::parse_from_rfc3339("2026-01-14T14:05:00-05:00")
.unwrap_or_default()
),
description: "".to_string(),
},
DateInfo {
id: uuid::Uuid::new_v4().to_string(),
title: "Deadline Example".to_string(),
date: DateRange::Range(
DateTime::parse_from_rfc3339("2026-01-15T07:15:00-05:00")
.unwrap_or_default(),
DateTime::parse_from_rfc3339("2026-01-20T14:05:00-05:00")
.unwrap_or_default()
),
description: "This is a test".to_string(),
},
DateInfo {
id: uuid::Uuid::new_v4().to_string(),
title: "Upcoming Example".to_string(),
date: DateRange::Range(
DateTime::parse_from_rfc3339("2026-01-30T07:15:00-05:00")
.unwrap_or_default(),
DateTime::parse_from_rfc3339("2026-02-20T14:05:00-05:00")
.unwrap_or_default()
),
description: "This is a test".to_string(),
},
DateInfo {
id: uuid::Uuid::new_v4().to_string(),
title: "Single Date (Blank)".to_string(),
date: DateRange::Single(
DateTime::parse_from_rfc3339("2026-01-15T14:05:00-05:00")
.unwrap_or_default()
),
description: "".to_string(),
}
];
create_dates.dispatch(CreateDates {
dates: dates_list
});
};
Effect::new(move || {
if let Some(Ok(_)) = create_dates.value().get() {
create_dates.clear();
reload_signal.update(|v| *v += 1);
}
});
pub fn TestPage() -> impl IntoView {
view! {
<div class="mx-auto px-6">
<div class="container mx-auto px-6 py-8 space-y-8">
@@ -126,14 +37,10 @@ pub fn TestPage() -> impl IntoView {
</div>
<div class="p-2">
<div class="flex flex-col p-3 gap-3">
<DateList dates=dates_list />
</div>
</div>
</div>
</section>
<section>
<ActionButton on:click=on_click>"Create Dates List"</ActionButton>
</section>
</div>
</div>
</div>