diff --git a/src/lib/calendar.ts b/src/lib/calendar.ts
index af28c21..e00a57c 100644
--- a/src/lib/calendar.ts
+++ b/src/lib/calendar.ts
@@ -2,7 +2,7 @@ function toGCalDate(d: Date) {
return d.toISOString().replace(/[-:.]/g, '').slice(0, 15) + 'Z';
}
-export function makeIcs(title: string, startsAt: Date, description: string) {
+export function makeIcs(title: string, startsAt: Date, description: string, location?: string) {
const start = toGCalDate(startsAt);
const end = toGCalDate(new Date(startsAt.getTime() + 60 * 60 * 1000));
return [
@@ -10,12 +10,14 @@ export function makeIcs(title: string, startsAt: Date, description: string) {
'BEGIN:VEVENT',
`DTSTART:${start}`, `DTEND:${end}`,
`SUMMARY:${title}`, `DESCRIPTION:${description}`,
+ ...(location ? [`LOCATION:${location}`] : []),
'END:VEVENT', 'END:VCALENDAR',
].join('\r\n');
}
-export function makeGCalUrl(title: string, startsAt: Date, description: string) {
+export function makeGCalUrl(title: string, startsAt: Date, description: string, location?: string) {
const start = toGCalDate(startsAt);
const end = toGCalDate(new Date(startsAt.getTime() + 60 * 60 * 1000));
- return `https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(title)}&dates=${start}/${end}&details=${encodeURIComponent(description)}`;
+ const locationParam = location ? `&location=${encodeURIComponent(location)}` : '';
+ return `https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(title)}&dates=${start}/${end}&details=${encodeURIComponent(description)}${locationParam}`;
}
diff --git a/src/lib/proposal-create.ts b/src/lib/proposal-create.ts
index 2f48bcf..616a751 100644
--- a/src/lib/proposal-create.ts
+++ b/src/lib/proposal-create.ts
@@ -29,6 +29,7 @@ export async function createProposal(
create: data.activities.map((a, i) => ({
title: a.title,
description: a.description ?? null,
+ location: a.location ?? null,
emoji: a.emoji ?? '🎉',
order: i,
slots: a.slots?.length
diff --git a/src/lib/proposal-schema.ts b/src/lib/proposal-schema.ts
index 20fbd21..22832d5 100644
--- a/src/lib/proposal-schema.ts
+++ b/src/lib/proposal-schema.ts
@@ -19,6 +19,7 @@ export const slotSchema = z.object({
export const activitySchema = z.object({
title: cipherText(100),
description: cipherTextOptional(300),
+ location: cipherTextOptional(200),
emoji: z.string().max(8).optional(),
slots: z.array(slotSchema).optional(),
});
@@ -37,7 +38,7 @@ export const proposalBodySchema = z.object({
gifUrl: cipherTextOptional(500),
evasiveNo: z.boolean().optional().default(false),
expiresAt: z.string().datetime().optional(),
- activities: z.array(activitySchema).min(2).max(5),
+ activities: z.array(activitySchema).min(1).max(5),
});
export type ProposalBody = z.infer;