fix: calculate from & to date and create/update with more details
This commit is contained in:
parent
fa105079d7
commit
19e699ea54
@ -115,25 +115,44 @@ const events = createListResource({
|
|||||||
color: event.color,
|
color: event.color,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
})
|
|
||||||
|
function getFromDate(event) {
|
||||||
|
return event.date + ' ' + (event.from_time ? event.from_time : '00:00:00')
|
||||||
|
}
|
||||||
|
|
||||||
|
function getToDate(event) {
|
||||||
|
return event.date + ' ' + (event.to_time ? event.to_time : '00:00:00')
|
||||||
|
}
|
||||||
|
|
||||||
function createEvent(event) {
|
function createEvent(event) {
|
||||||
|
if (!event.title) return
|
||||||
|
|
||||||
events.insert.submit({
|
events.insert.submit({
|
||||||
subject: event.title,
|
subject: event.title,
|
||||||
starts_on: event.fromDate,
|
description: event.description,
|
||||||
ends_on: event.toDate,
|
starts_on: getFromDate(event),
|
||||||
|
ends_on: getToDate(event),
|
||||||
|
all_day: event.isFullDay,
|
||||||
|
event_type: event.eventType,
|
||||||
color: event.color,
|
color: event.color,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEvent(event) {
|
function updateEvent(event) {
|
||||||
|
if (!event.id) return
|
||||||
|
|
||||||
events.setValue.submit({
|
events.setValue.submit({
|
||||||
name: event.id,
|
name: event.id,
|
||||||
subject: event.title,
|
subject: event.title,
|
||||||
starts_on: event.fromDate,
|
description: event.description,
|
||||||
ends_on: event.toDate,
|
starts_on: getFromDate(event),
|
||||||
|
ends_on: getToDate(event),
|
||||||
|
all_day: event.isFullDay,
|
||||||
|
event_type: event.eventType,
|
||||||
color: event.color,
|
color: event.color,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteEvent(eventID) {
|
function deleteEvent(eventID) {
|
||||||
events.delete.submit(eventID)
|
events.delete.submit(eventID)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user