Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
choden-dev committed Sep 16, 2024
2 parents e6a628c + 958a353 commit 18abca1
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 29 deletions.
7 changes: 5 additions & 2 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.

4 changes: 4 additions & 0 deletions server/src/data-layer/models/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ export interface EventReservation {
* @example true
*/
is_member: boolean
/**
* This is the timestamp of when the reservation was made
*/
timestamp: Timestamp
}

export interface Event {
Expand Down
24 changes: 14 additions & 10 deletions server/src/data-layer/services/EventService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@ import { Timestamp } from "firebase-admin/firestore"

const eventService = new EventService()

const startDate = dateToFirestoreTimeStamp(new Date(2024, 1, 1))
const endDate = dateToFirestoreTimeStamp(new Date(2024, 1, 2))
const startDate = new Date(2024, 1, 1)
const endDate = new Date(2024, 1, 2)
const startTimestamp = dateToFirestoreTimeStamp(startDate)
const endTimestamp = dateToFirestoreTimeStamp(endDate)

const laterStartDate = dateToFirestoreTimeStamp(new Date(2024, 2, 2))

const event1: Event = {
title: "UASC new event",
description: "Grand opening of the website.",
location: "Virtual pizza event",
physical_start_date: startDate,
start_date: startDate,
end_date: endDate
physical_start_date: startTimestamp,
start_date: startTimestamp,
end_date: endTimestamp
}
const event2: Event = {
title: "Snowboard racing",
description: "Race and see who's the fastest!",
location: "Snowsport club",
physical_start_date: startDate,
start_date: startDate,
end_date: endDate
physical_start_date: startTimestamp,
start_date: startTimestamp,
end_date: endTimestamp
}
const now = new Date(Date.now())
const futureEvent: Event = {
Expand All @@ -46,13 +48,15 @@ const reservation1: EventReservation = {
first_name: "John",
last_name: "Appleseed",
email: "[email protected]",
is_member: true
is_member: true,
timestamp: Timestamp.fromDate(startDate)
}
const reservation2: EventReservation = {
first_name: "Jane",
last_name: "Pearseed",
email: "[email protected]",
is_member: false
is_member: false,
timestamp: Timestamp.fromDate(startDate)
}

describe("EventService integration tests", () => {
Expand Down
19 changes: 9 additions & 10 deletions server/src/middleware/__generated__/routes.ts

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

10 changes: 7 additions & 3 deletions server/src/middleware/__generated__/swagger.json

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

7 changes: 5 additions & 2 deletions server/src/middleware/tests/EventController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const event2: Event = {
start_date: startDate,
end_date: endDate
}
const reservation1: EventReservation = {
const reservation1: Omit<EventReservation, "timestamp"> = {
first_name: "John",
last_name: "Doe",
email: "[email protected]",
Expand Down Expand Up @@ -88,7 +88,10 @@ describe("EventController endpoint tests", () => {

it("should return 400 if already signed up to event", async () => {
const event = await eventService.createEvent(event1)
await eventService.addReservation(event.id, reservation1)
await eventService.addReservation(event.id, {
...reservation1,
timestamp: Timestamp.now()
})
const res = await request.post("/events/signup").send({
event_id: event.id,
reservation: reservation1
Expand Down
6 changes: 5 additions & 1 deletion server/src/service-layer/controllers/EventController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SuccessResponse
} from "tsoa"
import express from "express"
import { Timestamp } from "firebase-admin/firestore"

@Route("events")
export class EventController extends Controller {
Expand Down Expand Up @@ -56,7 +57,10 @@ export class EventController extends Controller {
}
// Sign up the user
try {
await eventService.addReservation(event_id, reservation)
await eventService.addReservation(event_id, {
...reservation,
timestamp: Timestamp.now()
})
this.setStatus(200)
return {
message: "Successfully signed up for event.",
Expand Down
2 changes: 1 addition & 1 deletion server/src/service-layer/request-models/EventRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EventReservation, Event } from "data-layer/models/firebase"

export interface EventSignupBody {
event_id: string
reservation: EventReservation
reservation: Omit<EventReservation, "timestamp">
}

export interface CreateEventBody {
Expand Down

0 comments on commit 18abca1

Please sign in to comment.