Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eventSignup endpoint and new getAllReservations EventService method. #771

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
62 changes: 62 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.

106 changes: 106 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
Loading