Skip to content

Commit b656fb9

Browse files
committed
feat: add personal note in rsvp
1 parent 745a510 commit b656fb9

File tree

4 files changed

+81
-61
lines changed

4 files changed

+81
-61
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "Guest" ADD COLUMN "personal_note" TEXT;

prisma/schema.prisma

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ enum MessageStatus {
6565
}
6666

6767
model User {
68-
id String @id @default(uuid())
69-
name String
70-
dob DateTime
71-
mobile_number String @unique
72-
email String? @unique
73-
gender Gender @default(Unspecified)
74-
profile_pic String?
75-
preferred_language Language @default(English)
76-
verification_status VerificationStatus @default(unverified)
77-
created_at DateTime @default(now())
68+
id String @id @default(uuid())
69+
name String
70+
dob DateTime
71+
mobile_number String @unique
72+
email String? @unique
73+
gender Gender @default(Unspecified)
74+
profile_pic String?
75+
preferred_language Language @default(English)
76+
verification_status VerificationStatus @default(unverified)
77+
created_at DateTime @default(now())
7878
7979
// Relations
80-
hostedEvents Event[] @relation("HostEvents")
80+
hostedEvents Event[] @relation("HostEvents")
8181
guestRecords Guest[]
82-
coHostedEvents Event[] @relation("CoHostEvents")
83-
createdGuestGroups GuestGroup[] @relation("CreatedGuestGroups")
84-
guestGroupMemberships GuestGroupUsers[] @relation("GroupMember")
85-
addedToGroups GuestGroupUsers[] @relation("AddedBy")
82+
coHostedEvents Event[] @relation("CoHostEvents")
83+
createdGuestGroups GuestGroup[] @relation("CreatedGuestGroups")
84+
guestGroupMemberships GuestGroupUsers[] @relation("GroupMember")
85+
addedToGroups GuestGroupUsers[] @relation("AddedBy")
8686
createdInviteLinks InviteLink[]
8787
}
8888

@@ -98,8 +98,8 @@ model Event {
9898
created_at DateTime @default(now())
9999
start_date_time DateTime
100100
end_date_time DateTime?
101-
hostId String
102-
host User @relation("HostEvents", fields: [hostId], references: [id])
101+
hostId String
102+
host User @relation("HostEvents", fields: [hostId], references: [id])
103103
104104
weddingDetails WeddingEvent?
105105
birthdayDetails BirthdayEvent?
@@ -110,11 +110,11 @@ model Event {
110110
otherDetails OtherEvent?
111111
112112
// Relations
113-
co_hosts User[] @relation("CoHostEvents")
114-
sub_events SubEvent[] @relation("ParentEvent")
115-
guests Guest[]
116-
messages Message[]
117-
invites Invite[]
113+
co_hosts User[] @relation("CoHostEvents")
114+
sub_events SubEvent[] @relation("ParentEvent")
115+
guests Guest[]
116+
messages Message[]
117+
invites Invite[]
118118
guestGroups EventGuestGroup[]
119119
}
120120

@@ -131,6 +131,7 @@ model WeddingEvent {
131131
// Relation back to the main Event
132132
event Event @relation(fields: [id], references: [id], onDelete: Cascade)
133133
}
134+
134135
model BirthdayEvent {
135136
id String @id // This ID must match the Event's ID
136137
person_image String?
@@ -165,7 +166,7 @@ model TravelEvent {
165166
}
166167

167168
model CorporateEvent {
168-
id String @id // This ID must match the Event's ID
169+
id String @id // This ID must match the Event's ID
169170
event_details String
170171
terms String?
171172
@@ -174,7 +175,7 @@ model CorporateEvent {
174175
}
175176

176177
model CollegeEvent {
177-
id String @id // This ID must match the Event's ID
178+
id String @id // This ID must match the Event's ID
178179
event_details String
179180
terms String?
180181
@@ -183,7 +184,7 @@ model CollegeEvent {
183184
}
184185

185186
model OtherEvent {
186-
id String @id // This ID must match the Event's ID
187+
id String @id // This ID must match the Event's ID
187188
event_details String
188189
terms String?
189190
@@ -207,29 +208,32 @@ model SubEvent {
207208
guests String[]
208209
messages String[]
209210
}
211+
210212
model Guest {
211-
id String @id @default(uuid())
212-
rsvp RSVP @default(no_response)
213-
food String?
213+
id String @id @default(uuid())
214+
rsvp RSVP @default(no_response)
215+
food String?
214216
// HIGHLIGHT: Changed alcohol from String? to Boolean?
215-
alcohol Boolean?
216-
count Int @default(1)
217+
alcohol Boolean?
218+
count Int @default(1)
217219
218220
// HIGHLIGHT: Removed accommodation and added new transport fields
219221
pickup_date_time DateTime?
220222
pickup_location String?
221223
dropoff_date_time DateTime?
222224
dropoff_location String?
223-
225+
224226
// Make user_id optional for unlinked web RSVPs
225-
user_id String?
226-
event_id String
227-
group_id String?
228-
227+
user_id String?
228+
event_id String
229+
group_id String?
230+
229231
// Add contact fields for unlinked guests
230-
name String?
231-
phone_no String?
232-
email String?
232+
name String?
233+
phone_no String?
234+
email String?
235+
// Optional personal note left by the guest while filling RSVP
236+
personal_note String?
233237
234238
user User? @relation(fields: [user_id], references: [id])
235239
event Event @relation(fields: [event_id], references: [id])
@@ -238,35 +242,36 @@ model Guest {
238242
239243
@@unique([user_id, event_id])
240244
}
245+
241246
model GuestGroup {
242-
id String @id @default(uuid())
247+
id String @id @default(uuid())
243248
name String
244249
createdBy String
245-
246-
creator User @relation("CreatedGuestGroups", fields: [createdBy], references: [id])
247-
members GuestGroupUsers[]
248-
guests Guest[]
249-
inviteLinks InviteLink[]
250-
invites Invite[]
251-
events EventGuestGroup[]
250+
251+
creator User @relation("CreatedGuestGroups", fields: [createdBy], references: [id])
252+
members GuestGroupUsers[]
253+
guests Guest[]
254+
inviteLinks InviteLink[]
255+
invites Invite[]
256+
events EventGuestGroup[]
252257
}
253258

254259
model EventGuestGroup {
255260
event_id String
256261
guest_group_id String
257262
258263
// RSVP Global Settings (applied to all groups in this event)
259-
rsvp_lock_date DateTime? // Lock RSVP response datetime
260-
collect_food Boolean? @default(false) // Food preferences
261-
collect_alcohol Boolean? @default(false) // Alcohol preference
264+
rsvp_lock_date DateTime? // Lock RSVP response datetime
265+
collect_food Boolean? @default(false) // Food preferences
266+
collect_alcohol Boolean? @default(false) // Alcohol preference
262267
global_additional_details String? // Additional details for all groups
263268
264269
// Group-specific RSVP Settings
265270
allow_additional_guests Boolean? @default(false) // Additional guests allowed
266271
collect_accommodation Boolean? @default(false) // Accommodation preference
267-
accommodation_details String? // Accommodation details if collect_accommodation is true
272+
accommodation_details String? // Accommodation details if collect_accommodation is true
268273
collect_transport Boolean? @default(false) // Transport preference
269-
transport_details String? // Transportation details if collect_transport is true
274+
transport_details String? // Transportation details if collect_transport is true
270275
271276
created_at DateTime @default(now())
272277
updated_at DateTime @updatedAt
@@ -303,12 +308,12 @@ model InviteLink {
303308
}
304309

305310
model Invite {
306-
id String @id @default(uuid())
311+
id String @id @default(uuid())
307312
name String
308313
email String?
309314
phone_no String
310-
rsvp_status RSVP @default(no_response)
311-
additional_guest_count Int @default(0)
315+
rsvp_status RSVP @default(no_response)
316+
additional_guest_count Int @default(0)
312317
food_preference FoodPreference?
313318
alcohol_preference Boolean?
314319
pickup_date_time DateTime?
@@ -317,7 +322,7 @@ model Invite {
317322
dropoff_location String?
318323
event_id String
319324
group_id String
320-
created_at DateTime @default(now())
325+
created_at DateTime @default(now())
321326
message_status MessageStatus?
322327
323328
event Event @relation(fields: [event_id], references: [id], onDelete: Cascade)
@@ -327,8 +332,7 @@ model Invite {
327332
}
328333

329334
model Message {
330-
331-
id String @id @default(uuid())
335+
id String @id @default(uuid())
332336
message String
333337
time DateTime @default(now())
334338
event_id String
@@ -337,7 +341,8 @@ model Message {
337341
event Event @relation(fields: [event_id], references: [id], onDelete: Cascade)
338342
guest Guest @relation(fields: [guest_id], references: [id])
339343
}
344+
340345
model VerifiedPhone {
341346
phone String @id
342347
created_at DateTime @default(now())
343-
}
348+
}

src/routes/inviteRoutes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ router.put('/rsvp/event/:eventId', verifyIdToken, async (req: Request, res: Resp
163163
res.status(401).json({ message: 'Unauthorized' });
164164
return;
165165
}
166-
const { rsvp, food, alcohol, pickup_date_time, pickup_location, dropoff_date_time, dropoff_location, count, name, email, phone_no } = req.body;
166+
const { rsvp, food, alcohol, pickup_date_time, pickup_location, dropoff_date_time, dropoff_location, count, name, email, phone_no,
167+
personal_note } = req.body;
167168

168169
// Validate RSVP status
169170
const validRsvpStatuses = ['accepted', 'declined', 'maybe'];
@@ -176,6 +177,7 @@ router.put('/rsvp/event/:eventId', verifyIdToken, async (req: Request, res: Resp
176177
rsvp,
177178
food,
178179
alcohol,
180+
personal_note,
179181
pickup_date_time: pickup_date_time ? new Date(pickup_date_time) : undefined,
180182
pickup_location,
181183
dropoff_date_time: dropoff_date_time ? new Date(dropoff_date_time) : undefined,
@@ -435,7 +437,8 @@ router.post('/:eventId/:groupId/rsvp', optionalAuth, async (req: Request, res: R
435437
const userId = req.userId;
436438
const {
437439
name, phone_no, email, rsvp, food, alcohol,
438-
pickup_date_time, pickup_location, dropoff_date_time, dropoff_location, count
440+
pickup_date_time, pickup_location, dropoff_date_time, dropoff_location, count,
441+
personal_note
439442
} = req.body;
440443

441444
// Validation
@@ -451,6 +454,7 @@ router.post('/:eventId/:groupId/rsvp', optionalAuth, async (req: Request, res: R
451454
rsvp,
452455
food,
453456
alcohol,
457+
personal_note,
454458
pickup_date_time: pickup_date_time ? new Date(pickup_date_time) : undefined,
455459
pickup_location,
456460
dropoff_date_time: dropoff_date_time ? new Date(dropoff_date_time) : undefined,

src/services/inviteService.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export const getGroupInviteDetails = async (eventId: string, groupId: string, us
164164
pickup_location: true,
165165
dropoff_date_time: true,
166166
dropoff_location: true,
167-
count: true
167+
count: true,
168+
personal_note: true
168169
}
169170
});
170171

@@ -218,6 +219,7 @@ export const submitGroupRsvp = async (
218219
dropoff_date_time?: Date;
219220
dropoff_location?: string;
220221
count?: number;
222+
personal_note?: string;
221223
},
222224
authenticatedUserId?: string
223225
) => {
@@ -327,6 +329,7 @@ export const submitGroupRsvp = async (
327329
email: data.email || user.email,
328330
...(data.food && { food: data.food }),
329331
...(typeof data.alcohol === 'boolean' && { alcohol: data.alcohol }),
332+
...(data.personal_note !== undefined && { personal_note: data.personal_note }),
330333
...(data.pickup_date_time && { pickup_date_time: data.pickup_date_time }),
331334
...(data.pickup_location && { pickup_location: data.pickup_location }),
332335
...(data.dropoff_date_time && { dropoff_date_time: data.dropoff_date_time }),
@@ -375,6 +378,7 @@ export const submitGroupRsvp = async (
375378
count: data.count || 1,
376379
...(data.food && { food: data.food }),
377380
...(typeof data.alcohol === 'boolean' && { alcohol: data.alcohol }),
381+
...(data.personal_note && { personal_note: data.personal_note }),
378382
...(data.pickup_date_time && { pickup_date_time: data.pickup_date_time }),
379383
...(data.pickup_location && { pickup_location: data.pickup_location }),
380384
...(data.dropoff_date_time && { dropoff_date_time: data.dropoff_date_time }),
@@ -446,6 +450,7 @@ export const submitGroupRsvp = async (
446450
count: data.count || 1,
447451
...(data.food && { food: data.food }),
448452
...(typeof data.alcohol === 'boolean' && { alcohol: data.alcohol }),
453+
...(data.personal_note && { personal_note: data.personal_note }),
449454
...(data.pickup_date_time && { pickup_date_time: data.pickup_date_time }),
450455
...(data.pickup_location && { pickup_location: data.pickup_location }),
451456
...(data.dropoff_date_time && { dropoff_date_time: data.dropoff_date_time }),
@@ -543,6 +548,7 @@ export const getGroupRsvpStatus = async (eventId: string, groupId: string, phone
543548
rsvp: true,
544549
food: true,
545550
alcohol: true,
551+
personal_note: true,
546552
pickup_date_time: true,
547553
pickup_location: true,
548554
dropoff_date_time: true,
@@ -589,6 +595,7 @@ export const getGroupRsvpStatus = async (eventId: string, groupId: string, phone
589595
rsvp: true,
590596
food: true,
591597
alcohol: true,
598+
personal_note: true,
592599
pickup_date_time: true,
593600
pickup_location: true,
594601
dropoff_date_time: true,
@@ -700,6 +707,7 @@ export const updateUserRsvp = async (
700707
name?: string;
701708
email?: string;
702709
phone_no?: string;
710+
personal_note?: string;
703711
}
704712
) => {
705713
try {
@@ -753,6 +761,7 @@ export const updateUserRsvp = async (
753761

754762
if (data.food !== undefined) updateData.food = data.food;
755763
if (data.alcohol !== undefined) updateData.alcohol = data.alcohol;
764+
if (data.personal_note !== undefined) updateData.personal_note = data.personal_note;
756765
if (data.pickup_date_time !== undefined) updateData.pickup_date_time = data.pickup_date_time;
757766
if (data.pickup_location !== undefined) updateData.pickup_location = data.pickup_location;
758767
if (data.dropoff_date_time !== undefined) updateData.dropoff_date_time = data.dropoff_date_time;

0 commit comments

Comments
 (0)