Skip to content

Commit

Permalink
Merge branch 'master' into 772-frontend-create-component-to-render-al…
Browse files Browse the repository at this point in the history
…l-events
  • Loading branch information
choden-dev authored Oct 19, 2024
2 parents 749bd3c + d17d321 commit 7056984
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
4 changes: 3 additions & 1 deletion client/src/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { MembershipPaymentStore } from "@/store/MembershipPayment"
import queryClient from "@/services/QueryClient"
import { BOOKING_AVAILABLITY_KEY } from "@/services/Booking/BookingQueries"
import { MEMBERSHIP_CLIENT_SECRET_KEY } from "@/services/Payment/PaymentQueries"
import { getStorage } from "firebase/storage"

const firebaseConfig: FirebaseOptions = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
Expand All @@ -31,6 +32,7 @@ const firebaseConfig: FirebaseOptions = {
const app = initializeApp(firebaseConfig)
const auth = getAuth(app)
const db = getFirestore(app)
const storage = getStorage(app)
let analytics: Analytics | null = null

isSupported().then((yes) => {
Expand Down Expand Up @@ -80,4 +82,4 @@ export const fireAnalytics = (
}
}

export { auth, db, analytics }
export { auth, db, analytics, storage }
6 changes: 2 additions & 4 deletions client/src/services/Storage/StorageService.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { storage } from "@/firebase"
import {
getDownloadURL,
ref as storageRef,
uploadBytes,
getStorage
uploadBytes
} from "firebase/storage"

const storage = getStorage()

// https://stackoverflow.com/a/19842865
const uid = () => {
return Date.now().toString(36) + Math.random().toString(36).substr(2)
Expand Down
10 changes: 9 additions & 1 deletion server/src/middleware/tests/AdminController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,14 +832,22 @@ describe("AdminController endpoint tests", () => {
})
it("should let admins edit an event", async () => {
const newEvent = await eventService.createEvent(event1)
const newDate = dateToFirestoreTimeStamp(new Date())
const res = await request
.patch("/admin/events/" + newEvent.id)
.set("Authorization", `Bearer ${adminToken}`)
.send({ title: "Cool event!", location: "UoA" } as Partial<Event>)
.send({
title: "Cool event!",
location: "UoA",
physical_start_date: newDate
} as Partial<Event>)
expect(res.status).toEqual(200)
const fetchedEvent = await eventService.getEventById(newEvent.id)
expect(fetchedEvent.title).toEqual("Cool event!")
expect(fetchedEvent.location).toEqual("UoA")
expect(
removeUnderscoresFromTimestamp(fetchedEvent.physical_start_date)
).toEqual(newDate)
})
})
})
35 changes: 34 additions & 1 deletion server/src/service-layer/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,41 @@ export class AdminController extends Controller {
this.setStatus(404)
}
try {
eventService.updateEvent(id, requestBody)
const {
sign_up_start_date,
sign_up_end_date,
physical_start_date,
physical_end_date
} = requestBody
eventService.updateEvent(id, {
...requestBody,
...(sign_up_start_date && {
sign_up_start_date: new Timestamp(
sign_up_start_date.seconds,
sign_up_start_date.nanoseconds
)
}),
...(sign_up_end_date && {
sign_up_end_date: new Timestamp(
sign_up_end_date.seconds,
sign_up_end_date.nanoseconds
)
}),
...(physical_start_date && {
physical_start_date: new Timestamp(
physical_start_date.seconds,
physical_start_date.nanoseconds
)
}),
...(physical_end_date && {
physical_end_date: new Timestamp(
physical_end_date.seconds,
physical_end_date.nanoseconds
)
})
})
} catch (e) {
console.error(e)
this.setStatus(500)
}
this.setStatus(200)
Expand Down

0 comments on commit 7056984

Please sign in to comment.