feat: add option to link Google Maps to events

This commit is contained in:
Levente Orban
2025-09-24 21:15:31 +02:00
parent 69a760d3f1
commit cc3c868f7d
14 changed files with 353 additions and 93 deletions

View File

@@ -21,6 +21,8 @@ export const actions: Actions = {
const date = formData.get('date') as string;
const time = formData.get('time') as string;
const location = formData.get('location') as string;
const locationType = formData.get('location_type') as 'text' | 'maps';
const locationUrl = formData.get('location_url') as string;
const type = formData.get('type') as 'limited' | 'unlimited';
const attendeeLimit = formData.get('attendee_limit') as string;
const visibility = formData.get('visibility') as 'public' | 'private';
@@ -33,6 +35,8 @@ export const actions: Actions = {
if (!date) missingFields.push('date');
if (!time) missingFields.push('time');
if (!location?.trim()) missingFields.push('location');
if (!locationType) missingFields.push('location_type');
if (locationType === 'maps' && !locationUrl?.trim()) missingFields.push('location_url');
if (!userId) missingFields.push('userId');
if (missingFields.length > 0) {
@@ -43,6 +47,8 @@ export const actions: Actions = {
date,
time,
location,
location_type: locationType,
location_url: locationUrl,
type,
attendee_limit: attendeeLimit,
visibility
@@ -53,14 +59,34 @@ export const actions: Actions = {
if (new Date(date) < new Date()) {
return fail(400, {
error: 'Date cannot be in the past.',
values: { name, date, time, location, type, attendee_limit: attendeeLimit, visibility }
values: {
name,
date,
time,
location,
location_type: locationType,
location_url: locationUrl,
type,
attendee_limit: attendeeLimit,
visibility
}
});
}
if (type === 'limited' && (!attendeeLimit || parseInt(attendeeLimit) < 2)) {
return fail(400, {
error: 'Limit must be at least 2 for limited events.',
values: { name, date, time, location, type, attendee_limit: attendeeLimit, visibility }
values: {
name,
date,
time,
location,
location_type: locationType,
location_url: locationUrl,
type,
attendee_limit: attendeeLimit,
visibility
}
});
}
@@ -74,6 +100,8 @@ export const actions: Actions = {
date: date,
time: time,
location: location.trim(),
locationType: locationType,
locationUrl: locationType === 'maps' ? locationUrl?.trim() : null,
type: type,
attendeeLimit: type === 'limited' ? parseInt(attendeeLimit) : null,
visibility: visibility,