Skip to content

Commit

Permalink
Add eventSignup endpoint and new getAllReservations EventService method.
Browse files Browse the repository at this point in the history
Created new eventSignup endpoint and their controller.

Takes in a EventSignupBody and returns an EventSignupResponse.

Created EventService `getAllReservations` method and test.
  • Loading branch information
jeffplays2005 committed Sep 1, 2024
1 parent 22a93cd commit a6f80d3
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 6 deletions.
46 changes: 46 additions & 0 deletions client/src/models/__generated__/schema.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions server/src/data-layer/services/EventService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ describe("EventService integration tests", () => {

await eventService.deleteEvent(newEvent.id)

const fetchedReservation1 = await eventService.getReservation(
const fetchedReservation1 = await eventService.getReservationById(
newEvent.id,
newReservation1.id
)
expect(fetchedReservation1).toBe(undefined)
const fetchedReservation2 = await eventService.getReservation(
const fetchedReservation2 = await eventService.getReservationById(
newEvent.id,
newReservation2.id
)
Expand All @@ -134,12 +134,12 @@ describe("EventService integration tests", () => {
)

await eventService.deleteEvent(newEvent.id)
const fetchedReservation3 = await eventService.getReservation(
const fetchedReservation3 = await eventService.getReservationById(
newEvent2.id,
newReservation3.id
)
expect(fetchedReservation3).toEqual(reservation1)
const fetchedReservation4 = await eventService.getReservation(
const fetchedReservation4 = await eventService.getReservationById(
newEvent2.id,
newReservation4.id
)
Expand Down Expand Up @@ -171,13 +171,23 @@ describe("EventService integration tests", () => {
newEvent.id,
reservation1
)
const fetchedReservation = await eventService.getReservation(
const fetchedReservation = await eventService.getReservationById(
newEvent.id,
reservation.id
)
expect(fetchedReservation).toEqual(reservation1)
})

it("Should get all event reservations", async () => {
const newEvent = await eventService.createEvent(event1)
await eventService.addReservation(newEvent.id, reservation1)
await eventService.addReservation(newEvent.id, reservation2)
const reservations = await eventService.getAllReservations(newEvent.id)
expect(reservations.length).toBe(2)
expect(reservations).toContainEqual(reservation1)
expect(reservations).toContainEqual(reservation2)
})

it("Should be able to update an event reservation", async () => {
const newEvent = await eventService.createEvent(event1)

Expand Down
12 changes: 11 additions & 1 deletion server/src/data-layer/services/EventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,24 @@ class EventService {
* @param reservationId the ID of the reservation document
* @returns the reservation document
*/
public async getReservation(eventId: string, reservationId: string) {
public async getReservationById(eventId: string, reservationId: string) {
const result = await FirestoreSubcollections.reservations(eventId)
.doc(reservationId)
.get()

return result.data()
}

/**
* Gets all reservations for an event.
* @param eventId the ID of the event document
* @returns an array of all the event reservation documents
*/
public async getAllReservations(eventId: string) {
const result = await FirestoreSubcollections.reservations(eventId).get()
return result.docs.map((doc) => doc.data())
}

/**
* Updates an existing reservation document by ID with new EventReservation data.
*
Expand Down
63 changes: 63 additions & 0 deletions server/src/middleware/__generated__/routes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions server/src/middleware/__generated__/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a6f80d3

Please sign in to comment.