Enables marking scheduled events as complete
Implements a feature to mark scheduled events as complete, replacing the checkbox with a button for improved UX. This commit enhances the Scheduled Events functionality by allowing users to mark events as complete. It also includes: - Replaces the checkbox with a "Mark Complete" button for better usability. - Adds logging for debugging purposes during event completion toggling. - Routes completion events (kind 31925) to the ScheduledEventService. - Optimistically updates the local state after publishing completion events.
This commit is contained in:
parent
b15a8c21c0
commit
5d6f702859
5 changed files with 91 additions and 60 deletions
|
|
@ -54,7 +54,10 @@ export function useScheduledEvents() {
|
|||
* Toggle completion status of an event
|
||||
*/
|
||||
const toggleComplete = async (event: ScheduledEvent, notes: string = ''): Promise<void> => {
|
||||
console.log('🔧 useScheduledEvents: toggleComplete called for event:', event.title)
|
||||
|
||||
if (!scheduledEventService) {
|
||||
console.error('❌ useScheduledEvents: Scheduled event service not available')
|
||||
toast.error('Scheduled event service not available')
|
||||
return
|
||||
}
|
||||
|
|
@ -62,11 +65,14 @@ export function useScheduledEvents() {
|
|||
try {
|
||||
const eventAddress = `31922:${event.pubkey}:${event.dTag}`
|
||||
const currentlyCompleted = scheduledEventService.isCompleted(eventAddress)
|
||||
console.log('📊 useScheduledEvents: Current completion status:', currentlyCompleted)
|
||||
|
||||
if (currentlyCompleted) {
|
||||
console.log('⬇️ useScheduledEvents: Marking as incomplete...')
|
||||
await scheduledEventService.uncompleteEvent(event)
|
||||
toast.success('Event marked as incomplete')
|
||||
} else {
|
||||
console.log('⬆️ useScheduledEvents: Marking as complete...')
|
||||
await scheduledEventService.completeEvent(event, notes)
|
||||
toast.success('Event completed!')
|
||||
}
|
||||
|
|
@ -81,7 +87,7 @@ export function useScheduledEvents() {
|
|||
toast.error(message)
|
||||
}
|
||||
|
||||
console.error('Failed to toggle completion:', error)
|
||||
console.error('❌ useScheduledEvents: Failed to toggle completion:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue