Skip to content

Commit 21f03bd

Browse files
committed
fix: storing name email phone number in submit rsvp
1 parent d61a84a commit 21f03bd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/services/inviteService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,16 @@ export const submitGroupRsvp = async (
285285
throw new Error('Authenticated user not found');
286286
}
287287

288-
// Update user details if they provided new information
289-
if (data.name !== user.name || data.email !== user.email) {
288+
// Update user details if they provided new information OR if existing fields are null
289+
if (
290+
(data.name && (data.name !== user.name || !user.name)) ||
291+
(data.email && (data.email !== user.email || !user.email))
292+
) {
290293
user = await tx.user.update({
291294
where: { id: authenticatedUserId },
292295
data: {
293-
...(data.name && data.name !== user.name && { name: data.name }),
294-
...(data.email && data.email !== user.email && { email: data.email })
296+
...(data.name && (data.name !== user.name || !user.name) && { name: data.name }),
297+
...(data.email && (data.email !== user.email || !user.email) && { email: data.email })
295298
}
296299
});
297300
}
@@ -311,6 +314,9 @@ export const submitGroupRsvp = async (
311314
where: { id: existingGuest.id },
312315
data: {
313316
rsvp: data.rsvp,
317+
name: user.name,
318+
phone_no: user.mobile_number,
319+
email: user.email,
314320
...(data.food && { food: data.food }),
315321
...(typeof data.alcohol === 'boolean' && { alcohol: data.alcohol }),
316322
...(data.pickup_date_time && { pickup_date_time: data.pickup_date_time }),
@@ -354,6 +360,9 @@ export const submitGroupRsvp = async (
354360
user_id: user.id,
355361
event_id: eventId,
356362
group_id: groupId,
363+
name: user.name,
364+
phone_no: user.mobile_number,
365+
email: user.email,
357366
rsvp: data.rsvp,
358367
count: data.count || 1,
359368
...(data.food && { food: data.food }),

0 commit comments

Comments
 (0)