Some checks failed
Build and Push Docker Image / docker (push) Failing after 1m7s
Moved event fetching logic from CalendarView to Calendar component to properly use the visible date range instead of hardcoded current month. The Calendar component already tracks the current visible date through navigation, so events now load correctly for August and other months when navigating. Changes: - Calendar component now manages its own events state and fetching - Event fetching responds to current_date changes from navigation - CalendarView simplified to just render Calendar component - Fixed cargo fmt/clippy formatting across codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
2.1 KiB
Rust
69 lines
2.1 KiB
Rust
use crate::components::ViewMode;
|
||
use chrono::{Datelike, NaiveDate};
|
||
use web_sys::MouseEvent;
|
||
use yew::prelude::*;
|
||
|
||
#[derive(Properties, PartialEq)]
|
||
pub struct CalendarHeaderProps {
|
||
pub current_date: NaiveDate,
|
||
pub view_mode: ViewMode,
|
||
pub on_prev: Callback<MouseEvent>,
|
||
pub on_next: Callback<MouseEvent>,
|
||
pub on_today: Callback<MouseEvent>,
|
||
#[prop_or_default]
|
||
pub time_increment: Option<u32>,
|
||
#[prop_or_default]
|
||
pub on_time_increment_toggle: Option<Callback<MouseEvent>>,
|
||
}
|
||
|
||
#[function_component(CalendarHeader)]
|
||
pub fn calendar_header(props: &CalendarHeaderProps) -> Html {
|
||
let title = format!(
|
||
"{} {}",
|
||
get_month_name(props.current_date.month()),
|
||
props.current_date.year()
|
||
);
|
||
|
||
html! {
|
||
<div class="calendar-header">
|
||
<div class="header-left">
|
||
<button class="nav-button" onclick={props.on_prev.clone()}>{"‹"}</button>
|
||
{
|
||
if let (Some(increment), Some(callback)) = (props.time_increment, &props.on_time_increment_toggle) {
|
||
html! {
|
||
<button class="time-increment-button" onclick={callback.clone()}>
|
||
{format!("{}", increment)}
|
||
</button>
|
||
}
|
||
} else {
|
||
html! {}
|
||
}
|
||
}
|
||
</div>
|
||
<h2 class="month-year">{title}</h2>
|
||
<div class="header-right">
|
||
<button class="today-button" onclick={props.on_today.clone()}>{"Today"}</button>
|
||
<button class="nav-button" onclick={props.on_next.clone()}>{"›"}</button>
|
||
</div>
|
||
</div>
|
||
}
|
||
}
|
||
|
||
fn get_month_name(month: u32) -> &'static str {
|
||
match month {
|
||
1 => "January",
|
||
2 => "February",
|
||
3 => "March",
|
||
4 => "April",
|
||
5 => "May",
|
||
6 => "June",
|
||
7 => "July",
|
||
8 => "August",
|
||
9 => "September",
|
||
10 => "October",
|
||
11 => "November",
|
||
12 => "December",
|
||
_ => "Invalid",
|
||
}
|
||
}
|