Skip to content

Commit c873afd

Browse files
authored
Merge pull request #9 from IEEECS-VIT/darsh
Merge Conflicts Resolved
2 parents 3bba015 + 283f367 commit c873afd

File tree

4 files changed

+497
-9
lines changed

4 files changed

+497
-9
lines changed

prisma/schema.prisma

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ model Event {
6969
created_at DateTime @default(now())
7070
start_date_time DateTime
7171
end_date_time DateTime?
72+
bannerImage String?
7273
7374
hostId String
7475
host User @relation("HostEvents", fields: [hostId], references: [id])
7576
76-
// Event type-specific details
77-
weddingDetails WeddingEvent?
78-
birthdayDetails BirthdayEvent?
79-
housePartyDetails HousePartyEvent?
80-
travelDetails TravelEvent?
77+
weddingDetails WeddingEvent?
78+
birthdayDetails BirthdayEvent?
79+
housePartyDetails HousePartyEvent?
80+
travelDetails TravelEvent?
81+
anniversaryDetails AnniversaryEvent?
8182
8283
// Relations
8384
co_hosts User[] @relation("CoHostEvents")
@@ -110,7 +111,9 @@ model BirthdayEvent {
110111

111112
model HousePartyEvent {
112113
id String @id // This ID must match the Event's ID
114+
cost Float? @default(0.0) // Optional cost for the house party
113115
rules String?
116+
terms String?
114117
tags String[]
115118
116119
// Relation back to the main Event
@@ -119,6 +122,8 @@ model HousePartyEvent {
119122

120123
model TravelEvent {
121124
id String @id // This ID must match the Event's ID
125+
cost Float? @default(0.0) // Optional cost for the house party
126+
terms String?
122127
itinerary_included String[]
123128
itinerary_excluded String[]
124129
rules String?
@@ -128,6 +133,17 @@ model TravelEvent {
128133
event Event @relation(fields: [id], references: [id], onDelete: Cascade)
129134
}
130135

136+
model AnniversaryEvent {
137+
id String @id // This ID must match the Event's ID
138+
couple_names String
139+
anniversary_year Int?
140+
couple_image String?
141+
hashtag String?
142+
143+
// Relation back to the main Event
144+
event Event @relation(fields: [id], references: [id], onDelete: Cascade)
145+
}
146+
131147
model SubEvent {
132148
id String @id @default(uuid())
133149
title String

src/routes/eventRoutes.ts

Lines changed: 193 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import {
66
addCohost,
77
removeCohost,
88
updateEvent,
9-
deleteEvent,
9+
deleteEvent,
10+
addWeddingDetails,
11+
addBirthdayDetails,
12+
addHousePartyDetails,
13+
addTravelDetails,
14+
addAnniversaryDetails
1015
} from '../services/eventService';
1116
import { getUserByPhoneNumber } from '../services/userService';
1217
import { verifyIdToken } from '../middleware/verifyIdToken';
@@ -143,9 +148,9 @@ router.patch('/cohost/add', verifyIdToken, async (req: Request, res: Response) =
143148
router.patch('/cohost/remove', verifyIdToken, async (req: Request, res: Response) => {
144149
try {
145150
const userId = req.userId
146-
const {eventId, cohostId} = req.body
151+
const {eventId, phoneNumber} = req.body
147152

148-
if (!eventId || !cohostId) {
153+
if (!eventId || !phoneNumber) {
149154
res.status(401).json({message: 'Missing required fields'})
150155
return
151156
}
@@ -156,7 +161,13 @@ router.patch('/cohost/remove', verifyIdToken, async (req: Request, res: Response
156161
return
157162
}
158163

159-
const { success, event, error } = await removeCohost(eventId, cohostId);
164+
const cohost = await getUserByPhoneNumber(phoneNumber)
165+
if (!cohost) {
166+
res.status(404).json({message: 'Cohost not found'})
167+
return
168+
}
169+
170+
const { success, event, error } = await removeCohost(eventId, cohost.id);
160171

161172
if (success) {
162173
res.status(200).json({message: 'Cohost removed successfully', event})
@@ -169,6 +180,184 @@ router.patch('/cohost/remove', verifyIdToken, async (req: Request, res: Response
169180
}
170181
})
171182

183+
// Add Wedding Details
184+
router.post('/add-wedding-details', verifyIdToken, async (req: Request, res: Response) => {
185+
try {
186+
const userId = req.userId;
187+
const { eventId, bride_name, groom_name, bride_details, groom_details, bride_groom_images, hashtag } = req.body;
188+
189+
if (!eventId || !bride_name || !groom_name) {
190+
res.status(400).json({ message: 'Missing required fields: eventId, bride_name, groom_name' });
191+
return;
192+
}
193+
194+
const user = await getUser(userId);
195+
if (!user) {
196+
res.status(404).json({ message: 'User not found' });
197+
return;
198+
}
199+
200+
const { success, weddingDetails, error } = await addWeddingDetails(eventId, {
201+
bride_name,
202+
groom_name,
203+
bride_details,
204+
groom_details,
205+
bride_groom_images,
206+
hashtag
207+
});
208+
209+
if (success) {
210+
res.status(200).json({ message: 'Wedding details added successfully', weddingDetails });
211+
} else {
212+
res.status(500).json({ message: error ?? 'Internal Server Error' });
213+
}
214+
} catch (error) {
215+
console.error(error);
216+
res.status(500).json({ message: 'Internal Server Error' });
217+
}
218+
});
219+
220+
// Add Birthday Details
221+
router.post('/add-birthday-details', verifyIdToken, async (req: Request, res: Response) => {
222+
try {
223+
const userId = req.userId;
224+
const { eventId, person_image, hashtag } = req.body;
225+
226+
if (!eventId) {
227+
res.status(400).json({ message: 'Missing required field: eventId' });
228+
return;
229+
}
230+
231+
const user = await getUser(userId);
232+
if (!user) {
233+
res.status(404).json({ message: 'User not found' });
234+
return;
235+
}
236+
237+
const { success, birthdayDetails, error } = await addBirthdayDetails(eventId, {
238+
person_image,
239+
hashtag
240+
});
241+
242+
if (success) {
243+
res.status(200).json({ message: 'Birthday details added successfully', birthdayDetails });
244+
} else {
245+
res.status(500).json({ message: error ?? 'Internal Server Error' });
246+
}
247+
} catch (error) {
248+
console.error(error);
249+
res.status(500).json({ message: 'Internal Server Error' });
250+
}
251+
});
252+
253+
// Add House Party Details
254+
router.post('/add-houseparty-details', verifyIdToken, async (req: Request, res: Response) => {
255+
try {
256+
const userId = req.userId;
257+
const { eventId, cost, rules, terms, tags } = req.body;
258+
259+
if (!eventId) {
260+
res.status(400).json({ message: 'Missing required field: eventId' });
261+
return;
262+
}
263+
264+
const user = await getUser(userId);
265+
if (!user) {
266+
res.status(404).json({ message: 'User not found' });
267+
return;
268+
}
269+
270+
const { success, housePartyDetails, error } = await addHousePartyDetails(eventId, {
271+
cost,
272+
rules,
273+
terms,
274+
tags
275+
});
276+
277+
if (success) {
278+
res.status(200).json({ message: 'House party details added successfully', housePartyDetails });
279+
} else {
280+
res.status(500).json({ message: error ?? 'Internal Server Error' });
281+
}
282+
} catch (error) {
283+
console.error(error);
284+
res.status(500).json({ message: 'Internal Server Error' });
285+
}
286+
});
287+
288+
// Add Travel Details
289+
router.post('/add-travel-details', verifyIdToken, async (req: Request, res: Response) => {
290+
try {
291+
const userId = req.userId;
292+
const { eventId, cost, terms, itinerary_included, itinerary_excluded, rules, tags } = req.body;
293+
294+
if (!eventId) {
295+
res.status(400).json({ message: 'Missing required field: eventId' });
296+
return;
297+
}
298+
299+
const user = await getUser(userId);
300+
if (!user) {
301+
res.status(404).json({ message: 'User not found' });
302+
return;
303+
}
304+
305+
const { success, travelDetails, error } = await addTravelDetails(eventId, {
306+
cost,
307+
terms,
308+
itinerary_included,
309+
itinerary_excluded,
310+
rules,
311+
tags
312+
});
313+
314+
if (success) {
315+
res.status(200).json({ message: 'Travel details added successfully', travelDetails });
316+
} else {
317+
res.status(500).json({ message: error ?? 'Internal Server Error' });
318+
}
319+
} catch (error) {
320+
console.error(error);
321+
res.status(500).json({ message: 'Internal Server Error' });
322+
}
323+
});
324+
325+
// Add Anniversary Details
326+
router.post('/add-anniversary-details', verifyIdToken, async (req: Request, res: Response) => {
327+
try {
328+
const userId = req.userId;
329+
const { eventId, couple_names, anniversary_year, couple_image, hashtag } = req.body;
330+
331+
if (!eventId || !couple_names) {
332+
res.status(400).json({ message: 'Missing required fields: eventId, couple_names' });
333+
return;
334+
}
335+
336+
const user = await getUser(userId);
337+
if (!user) {
338+
res.status(404).json({ message: 'User not found' });
339+
return;
340+
}
341+
342+
const { success, anniversaryDetails, error } = await addAnniversaryDetails(eventId, {
343+
couple_names,
344+
anniversary_year,
345+
couple_image,
346+
hashtag
347+
});
348+
349+
if (success) {
350+
res.status(200).json({ message: 'Anniversary details added successfully', anniversaryDetails });
351+
} else {
352+
res.status(500).json({ message: error ?? 'Internal Server Error' });
353+
}
354+
} catch (error) {
355+
console.error(error);
356+
res.status(500).json({ message: 'Internal Server Error' });
357+
}
358+
});
359+
360+
// Delete Event
172361
router.delete('/:eventId', verifyIdToken, async (req: Request, res: Response) => {
173362
try {
174363
const userId = req.userId;

src/routes/onboardingRoutes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ router.post('/otp/send', async (req: Request, res: Response) => {
2727

2828
router.post('/otp/verify', async (req: Request, res: Response): Promise<void> => {
2929
const { phone, code } = req.body;
30+
if (!phone || !code) {
31+
res.status(400).json({ error: 'Phone number and code are required' });
32+
return;
33+
}
3034

3135
try {
3236
const result = await verifyOTP(phone, code);

0 commit comments

Comments
 (0)