Enables recurring scheduled event completion

Extends scheduled event completion to support recurring events.

The changes introduce the concept of an "occurrence" for recurring events,
allowing users to mark individual instances of a recurring event as complete.
This involves:
- Adding recurrence information to the ScheduledEvent model.
- Modifying completion logic to handle recurring events with daily/weekly frequencies
- Updating UI to display recurrence information and mark individual occurrences as complete.
This commit is contained in:
padreug 2025-10-22 00:16:47 +02:00
parent f8802a6304
commit 6c432b45be
4 changed files with 147 additions and 46 deletions

View file

@ -56,10 +56,10 @@ export function useScheduledEvents() {
}
/**
* Toggle completion status of an event
* Toggle completion status of an event (optionally for a specific occurrence)
*/
const toggleComplete = async (event: ScheduledEvent, notes: string = ''): Promise<void> => {
console.log('🔧 useScheduledEvents: toggleComplete called for event:', event.title)
const toggleComplete = async (event: ScheduledEvent, occurrence?: string, notes: string = ''): Promise<void> => {
console.log('🔧 useScheduledEvents: toggleComplete called for event:', event.title, 'occurrence:', occurrence)
if (!scheduledEventService) {
console.error('❌ useScheduledEvents: Scheduled event service not available')
@ -69,16 +69,16 @@ export function useScheduledEvents() {
try {
const eventAddress = `31922:${event.pubkey}:${event.dTag}`
const currentlyCompleted = scheduledEventService.isCompleted(eventAddress)
const currentlyCompleted = scheduledEventService.isCompleted(eventAddress, occurrence)
console.log('📊 useScheduledEvents: Current completion status:', currentlyCompleted)
if (currentlyCompleted) {
console.log('⬇️ useScheduledEvents: Marking as incomplete...')
await scheduledEventService.uncompleteEvent(event)
await scheduledEventService.uncompleteEvent(event, occurrence)
toast.success('Event marked as incomplete')
} else {
console.log('⬆️ useScheduledEvents: Marking as complete...')
await scheduledEventService.completeEvent(event, notes)
await scheduledEventService.completeEvent(event, notes, occurrence)
toast.success('Event completed!')
}
} catch (error) {