Adds date navigation to scheduled events
Implements date navigation for scheduled events, allowing users to view events for different days. This change replaces the static "Today's Events" section with a dynamic date selector. It introduces buttons for navigating to the previous and next days, as well as a "Today" button to return to the current date. A date display shows the selected date, and a message indicates when there are no scheduled events for a given day.
This commit is contained in:
parent
a27a8232f2
commit
0e42318036
3 changed files with 137 additions and 23 deletions
|
|
@ -251,22 +251,24 @@ export class ScheduledEventService extends BaseService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get events for today, optionally filtered by user participation
|
||||
* Get events for a specific date, optionally filtered by user participation
|
||||
* @param date - ISO date string (YYYY-MM-DD). Defaults to today.
|
||||
* @param userPubkey - Optional user pubkey to filter by participation
|
||||
*/
|
||||
getTodaysEvents(userPubkey?: string): ScheduledEvent[] {
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
getEventsForSpecificDate(date?: string, userPubkey?: string): ScheduledEvent[] {
|
||||
const targetDate = date || new Date().toISOString().split('T')[0]
|
||||
|
||||
// Get one-time events for today (exclude recurring events to avoid duplicates)
|
||||
const oneTimeEvents = this.getEventsForDate(today).filter(event => !event.recurrence)
|
||||
// Get one-time events for the date (exclude recurring events to avoid duplicates)
|
||||
const oneTimeEvents = this.getEventsForDate(targetDate).filter(event => !event.recurrence)
|
||||
|
||||
// Get all events and check for recurring events that occur today
|
||||
// Get all events and check for recurring events that occur on this date
|
||||
const allEvents = this.getScheduledEvents()
|
||||
const recurringEventsToday = allEvents.filter(event =>
|
||||
event.recurrence && this.doesRecurringEventOccurOnDate(event, today)
|
||||
const recurringEventsOnDate = allEvents.filter(event =>
|
||||
event.recurrence && this.doesRecurringEventOccurOnDate(event, targetDate)
|
||||
)
|
||||
|
||||
// Combine one-time and recurring events
|
||||
let events = [...oneTimeEvents, ...recurringEventsToday]
|
||||
let events = [...oneTimeEvents, ...recurringEventsOnDate]
|
||||
|
||||
// Filter events based on participation (if user pubkey provided)
|
||||
if (userPubkey) {
|
||||
|
|
@ -288,6 +290,13 @@ export class ScheduledEventService extends BaseService {
|
|||
return events
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events for today, optionally filtered by user participation
|
||||
*/
|
||||
getTodaysEvents(userPubkey?: string): ScheduledEvent[] {
|
||||
return this.getEventsForSpecificDate(undefined, userPubkey)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get completion status for an event (optionally for a specific occurrence)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue