fix: enhance event submission logic to show details after successful insert and update

This commit is contained in:
Shariq Ansari 2025-08-08 17:56:07 +05:30
parent 68ac2b80ff
commit b6e8d83c3b

View File

@ -155,13 +155,17 @@ const events = createListResource({
}) })
}, },
insert: { insert: {
onSuccess: () => events.reload(), onSuccess: async (e) => {
}, await events.reload()
delete: { showDetails({ id: e.name })
onSuccess: () => events.reload(), },
}, },
delete: { onSuccess: () => events.reload() },
setValue: { setValue: {
onSuccess: () => events.reload(), onSuccess: async (e) => {
await events.reload()
showEventPanel.value && showDetails({ id: e.name })
},
}, },
}) })
@ -180,41 +184,31 @@ function saveEvent(_event) {
function createEvent(_event) { function createEvent(_event) {
if (!_event.title) return if (!_event.title) return
events.insert.submit( events.insert.submit({
{ subject: _event.title,
subject: _event.title, description: _event.description,
description: _event.description, starts_on: _event.fromDate + ' ' + _event.fromTime,
starts_on: _event.fromDate + ' ' + _event.fromTime, ends_on: _event.toDate + ' ' + _event.toTime,
ends_on: _event.toDate + ' ' + _event.toTime, all_day: _event.isFullDay || false,
all_day: _event.isFullDay || false, event_type: _event.eventType,
event_type: _event.eventType, color: _event.color,
color: _event.color, })
},
{ onSuccess: (e) => showDetails({ id: e.name }) },
)
} }
function updateEvent(_event) { function updateEvent(_event) {
if (!_event.id) return if (!_event.id) return
if (!mode.value || mode.value === 'edit' || mode.value === 'details') { if (!mode.value || mode.value === 'edit' || mode.value === 'details') {
events.setValue.submit( events.setValue.submit({
{ name: _event.id,
name: _event.id, subject: _event.title,
subject: _event.title, description: _event.description,
description: _event.description, starts_on: _event.fromDate + ' ' + _event.fromTime,
starts_on: _event.fromDate + ' ' + _event.fromTime, ends_on: _event.toDate + ' ' + _event.toTime,
ends_on: _event.toDate + ' ' + _event.toTime, all_day: _event.isFullDay,
all_day: _event.isFullDay, event_type: _event.eventType,
event_type: _event.eventType, color: _event.color,
color: _event.color, })
},
{
onSuccess: (e) => {
showEventPanel.value && showDetails({ id: e.name })
},
},
)
} }
event.value = _event event.value = _event