fixes
Build And Push Image / docker (push) Successful in 1m42s
Details
Build And Push Image / docker (push) Successful in 1m42s
Details
This commit is contained in:
parent
400f9cdd52
commit
0952d6c381
|
|
@ -489,19 +489,15 @@ watch(startDate, (newStartDate) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Watch for separate date and time changes to combine them
|
// Watch for separate date and time changes to combine them using robust parsing
|
||||||
watch([startDate, startTime], ([newDate, newTime]) => {
|
watch([startDate, startTime], ([newDate, newTime]) => {
|
||||||
if (newDate && newTime) {
|
if (newDate && newTime) {
|
||||||
console.log('[CreateEventDialog] Combining start date/time:', { date: newDate, time: newTime });
|
console.log('[CreateEventDialog] Combining start date/time:', { date: newDate, time: newTime });
|
||||||
|
|
||||||
// Ensure time is in 24-hour format (HH:MM)
|
const combinedDateTime = createDateTimeFromParts(newDate, newTime);
|
||||||
const normalizedTime = normalizeTimeFormat(newTime);
|
|
||||||
console.log('[CreateEventDialog] Normalized start time:', normalizedTime);
|
|
||||||
|
|
||||||
const combinedDateTime = new Date(`${newDate}T${normalizedTime}`);
|
if (!combinedDateTime) {
|
||||||
|
console.error('[CreateEventDialog] Failed to create start datetime from parts:', { date: newDate, time: newTime });
|
||||||
if (isNaN(combinedDateTime.getTime())) {
|
|
||||||
console.error('[CreateEventDialog] Invalid start datetime created:', { date: newDate, time: newTime, normalized: normalizedTime });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -514,14 +510,10 @@ watch([endDate, endTime], ([newDate, newTime]) => {
|
||||||
if (newDate && newTime) {
|
if (newDate && newTime) {
|
||||||
console.log('[CreateEventDialog] Combining end date/time:', { date: newDate, time: newTime });
|
console.log('[CreateEventDialog] Combining end date/time:', { date: newDate, time: newTime });
|
||||||
|
|
||||||
// Ensure time is in 24-hour format (HH:MM)
|
const combinedDateTime = createDateTimeFromParts(newDate, newTime);
|
||||||
const normalizedTime = normalizeTimeFormat(newTime);
|
|
||||||
console.log('[CreateEventDialog] Normalized end time:', normalizedTime);
|
|
||||||
|
|
||||||
const combinedDateTime = new Date(`${newDate}T${normalizedTime}`);
|
if (!combinedDateTime) {
|
||||||
|
console.error('[CreateEventDialog] Failed to create end datetime from parts:', { date: newDate, time: newTime });
|
||||||
if (isNaN(combinedDateTime.getTime())) {
|
|
||||||
console.error('[CreateEventDialog] Invalid end datetime created:', { date: newDate, time: newTime, normalized: normalizedTime });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -578,14 +570,76 @@ const normalizeTimeFormat = (timeString: string): string => {
|
||||||
// Ensure time is in HH:MM 24-hour format
|
// Ensure time is in HH:MM 24-hour format
|
||||||
if (!timeString) return '';
|
if (!timeString) return '';
|
||||||
|
|
||||||
// If already in HH:MM format, return as is
|
// Remove any whitespace
|
||||||
if (/^\d{2}:\d{2}$/.test(timeString)) {
|
const cleaned = timeString.trim();
|
||||||
return timeString;
|
|
||||||
|
// If already in HH:MM format, validate and return
|
||||||
|
if (/^\d{2}:\d{2}$/.test(cleaned)) {
|
||||||
|
const [hours, minutes] = cleaned.split(':').map(Number);
|
||||||
|
if (hours >= 0 && hours <= 23 && minutes >= 0 && minutes <= 59) {
|
||||||
|
return cleaned;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle other potential formats (this is basic, can be expanded)
|
// If in H:MM format, pad with zero
|
||||||
// For now, assume HTML time input gives us the correct format
|
if (/^\d{1}:\d{2}$/.test(cleaned)) {
|
||||||
return timeString;
|
const [hours, minutes] = cleaned.split(':');
|
||||||
|
const paddedHours = hours.padStart(2, '0');
|
||||||
|
const numHours = Number(paddedHours);
|
||||||
|
const numMinutes = Number(minutes);
|
||||||
|
if (numHours >= 0 && numHours <= 23 && numMinutes >= 0 && numMinutes <= 59) {
|
||||||
|
return `${paddedHours}:${minutes}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle seconds format HH:MM:SS by truncating
|
||||||
|
if (/^\d{2}:\d{2}:\d{2}$/.test(cleaned)) {
|
||||||
|
const timePart = cleaned.substring(0, 5);
|
||||||
|
return normalizeTimeFormat(timePart);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error('[CreateEventDialog] Invalid time format:', timeString);
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const createDateTimeFromParts = (dateString: string, timeString: string): Date | null => {
|
||||||
|
if (!dateString || !timeString) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Normalize the time format first
|
||||||
|
const normalizedTime = normalizeTimeFormat(timeString);
|
||||||
|
if (!normalizedTime) {
|
||||||
|
console.error('[CreateEventDialog] Failed to normalize time:', timeString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split time into parts
|
||||||
|
const [hours, minutes] = normalizedTime.split(':').map(Number);
|
||||||
|
|
||||||
|
// Create date object from date string (YYYY-MM-DD format)
|
||||||
|
const dateObj = new Date(dateString + 'T00:00:00');
|
||||||
|
|
||||||
|
if (isNaN(dateObj.getTime())) {
|
||||||
|
console.error('[CreateEventDialog] Invalid date string:', dateString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the time components
|
||||||
|
dateObj.setHours(hours, minutes, 0, 0);
|
||||||
|
|
||||||
|
// Validate the final result
|
||||||
|
if (isNaN(dateObj.getTime())) {
|
||||||
|
console.error('[CreateEventDialog] Invalid combined datetime:', { dateString, timeString, normalizedTime, hours, minutes });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateObj;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[CreateEventDialog] Error creating datetime:', error, { dateString, timeString });
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Validation functions
|
// Validation functions
|
||||||
|
|
@ -603,22 +657,13 @@ const validateEndTime = () => {
|
||||||
|
|
||||||
// Only validate if start and end are on the same date
|
// Only validate if start and end are on the same date
|
||||||
if (startDate.value === endDate.value) {
|
if (startDate.value === endDate.value) {
|
||||||
// Normalize time formats before creating Date objects
|
// Use robust parsing to create datetime objects
|
||||||
const normalizedStartTime = normalizeTimeFormat(startTime.value);
|
const startDateTime = createDateTimeFromParts(startDate.value, startTime.value);
|
||||||
const normalizedEndTime = normalizeTimeFormat(endTime.value);
|
const endDateTime = createDateTimeFromParts(endDate.value, endTime.value);
|
||||||
|
|
||||||
// Convert times to comparable format by creating full datetime objects
|
|
||||||
const startDateTime = new Date(`${startDate.value}T${normalizedStartTime}`);
|
|
||||||
const endDateTime = new Date(`${endDate.value}T${normalizedEndTime}`);
|
|
||||||
|
|
||||||
// Check if dates are valid
|
// Check if dates are valid
|
||||||
if (isNaN(startDateTime.getTime()) || isNaN(endDateTime.getTime())) {
|
if (!startDateTime || !endDateTime) {
|
||||||
console.error('[CreateEventDialog] Invalid datetime created in validation:', {
|
console.error('[CreateEventDialog] Failed to create datetime objects in validation');
|
||||||
startDateTime: startDateTime.toString(),
|
|
||||||
endDateTime: endDateTime.toString(),
|
|
||||||
normalizedStartTime,
|
|
||||||
normalizedEndTime
|
|
||||||
});
|
|
||||||
return true; // Return error if dates are invalid
|
return true; // Return error if dates are invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -712,30 +757,30 @@ const handleSubmit = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Combine date and time properly
|
// Combine date and time properly using robust parsing
|
||||||
const startDateTime = new Date(`${startDate.value}T${startTime.value}`);
|
const startDateTime = createDateTimeFromParts(startDate.value, startTime.value);
|
||||||
const endDateTime = new Date(`${endDate.value}T${endTime.value}`);
|
const endDateTime = createDateTimeFromParts(endDate.value, endTime.value);
|
||||||
|
|
||||||
console.log('[CreateEventDialog] DateTime validation:', {
|
console.log('[CreateEventDialog] DateTime validation:', {
|
||||||
startDate: startDate.value,
|
startDate: startDate.value,
|
||||||
startTime: startTime.value,
|
startTime: startTime.value,
|
||||||
endDate: endDate.value,
|
endDate: endDate.value,
|
||||||
endTime: endTime.value,
|
endTime: endTime.value,
|
||||||
startDateTime: startDateTime.toISOString(),
|
startDateTime: startDateTime?.toISOString(),
|
||||||
endDateTime: endDateTime.toISOString(),
|
endDateTime: endDateTime?.toISOString(),
|
||||||
startTimestamp: startDateTime.getTime(),
|
startTimestamp: startDateTime?.getTime(),
|
||||||
endTimestamp: endDateTime.getTime()
|
endTimestamp: endDateTime?.getTime()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Validate dates are valid
|
// Validate dates are valid
|
||||||
if (isNaN(startDateTime.getTime())) {
|
if (!startDateTime) {
|
||||||
errorMessage.value = 'Invalid start date or time';
|
errorMessage.value = 'Invalid start date or time format';
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNaN(endDateTime.getTime())) {
|
if (!endDateTime) {
|
||||||
errorMessage.value = 'Invalid end date or time';
|
errorMessage.value = 'Invalid end date or time format';
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue