1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-20 21:39:37 +02:00

Fix date validation logic in CollectionModal to ensure start date is before end date and handle missing start date

This commit is contained in:
Sean Morley 2024-12-27 22:27:17 -05:00
parent 46e3e91679
commit 5d3ec181a0
2 changed files with 14 additions and 1 deletions

View file

@ -51,6 +51,19 @@
collection.end_date = collection.start_date;
}
if (
collection.start_date &&
collection.end_date &&
collection.start_date > collection.end_date
) {
addToast('error', $t('adventures.start_before_end_error'));
return;
}
if (!collection.start_date && collection.end_date) {
collection.start_date = collection.end_date;
}
if (collection.id === '') {
let res = await fetch('/api/collections', {
method: 'POST',