Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RouteWrapper {
* @param params route parameters containing the GameSessionSchedule ID
* @returns OK code and the game session schedule data
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand Down Expand Up @@ -43,7 +43,7 @@ class RouteWrapper {
* @param params Route parameters containing the GameSessionSchedule ID.
* @returns The updated {@link GameSessionSchedule} document, otherwise an appropriate error response.
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const parsedBody = UpdateGameSessionScheduleRequestSchema.parse(await req.json())
Expand Down Expand Up @@ -81,7 +81,7 @@ class RouteWrapper {
* @param params Route parameters containing the GameSessionSchedule ID
* @returns No content status code
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async DELETE(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GameSessionSchedulesRouteWrapper {
* @param req The request object containing the request body.
* @returns All {@link GameSessionSchedule} documents, otherwise an appropriate error response.
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async GET(req: NextRequest) {
try {
const { searchParams } = new URL(req.url)
Expand Down Expand Up @@ -55,7 +55,7 @@ class GameSessionSchedulesRouteWrapper {
* @param req The request object containing the request body.
* @returns The created {@link GameSessionSchedule} document, otherwise an appropriate error response.
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async POST(req: NextRequest) {
try {
const parsedBody = CreateGameSessionScheduleRequestSchema.parse(await req.json())
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/app/api/admin/game-sessions/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GameSessionRouteWrapper {
* @param params route parameters containing the GameSession ID
* @returns No content status code
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async DELETE(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand All @@ -41,7 +41,7 @@ class GameSessionRouteWrapper {
* @param req The request object containing the request body
* @returns The updated {@link gameSession} document
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/app/api/admin/semesters/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SemesterRouteWrapper {
* @param req The request object containing the request body
* @returns No content status code
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async DELETE(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand All @@ -37,7 +37,7 @@ class SemesterRouteWrapper {
* @param params The route parameters containing the Semester ID
* @returns The updated {@link Semester} document
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/app/api/admin/semesters/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SemesterRouteWrapper {
* @param req The request object containing the request body
* @returns The created {@link Semester} document.
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async POST(req: NextRequest) {
try {
const parsedBody = CreateSemesterRequestSchema.parse(await req.json())
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/app/api/admin/users/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("/api/admin/users/[id]", async () => {
expect(res.status).toBe(StatusCodes.OK)
const json = await res.json()
expect(json.data.id).toBe(ADMIN_USER_UID)
expect(json.data.role).toBe("admin")
expect(json.data.role).toBe("Admin")
expect(consoleErrorSpy).not.toHaveBeenCalled()
})

Expand All @@ -92,7 +92,7 @@ describe("/api/admin/users/[id]", async () => {
expect(res.status).toBe(StatusCodes.OK)
const json = await res.json()
expect(json.data.id).toBe(CASUAL_USER_UID)
expect(json.data.role).toBe("casual")
expect(json.data.role).toBe("Casual")
expect(consoleErrorSpy).not.toHaveBeenCalled()
})

Expand All @@ -104,7 +104,7 @@ describe("/api/admin/users/[id]", async () => {
expect(res.status).toBe(StatusCodes.OK)
const json = await res.json()
expect(json.data.id).toBe(MEMBER_USER_UID)
expect(json.data.role).toBe("member")
expect(json.data.role).toBe("Member")
expect(consoleErrorSpy).not.toHaveBeenCalled()
})

Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/app/api/admin/users/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UserRouteWrapper {
* @param params The route parameters containing the user ID
* @returns The user data if found, otherwise appropriate error response
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand All @@ -41,7 +41,7 @@ class UserRouteWrapper {
* @param params The route parameters containing the User ID
* @returns The updated User document
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand Down Expand Up @@ -74,7 +74,7 @@ class UserRouteWrapper {
* @param params The route parameters containing the user ID
* @returns No content response if successful, otherwise appropriate error response
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async DELETE(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id } = await params
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/app/api/admin/users/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UsersRouteWrapper {
* @param req The request object containing query parameters for pagination
* @returns Paginated user data with proper metadata
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async GET(req: NextRequest) {
try {
const { searchParams } = new URL(req.url)
Expand Down Expand Up @@ -45,7 +45,7 @@ class UsersRouteWrapper {
* @param req The request object containing the request body
* @returns The created {@link User} document.
*/
@Security("jwt", ["admin"])
@Security("jwt", ["ADMIN"])
static async POST(req: NextRequest) {
try {
const parsedBody = CreateUserRequestSchema.parse(await req.json())
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/app/api/auth/google/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const GET = async (req: NextRequest) => {
user = await userService.createUser({
firstName: given_name,
lastName: family_name,
role: MembershipType.casual,
role: MembershipType.CASUAL,
email,
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/app/api/auth/register/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const POST = async (req: NextRequest) => {
}
}

const user = await userDataService.createUser({ ...parsedBody, role: "casual" })
const user = await userDataService.createUser({ ...parsedBody, role: "Casual" })
const hash = await StandardSecurity.hashPassword(parsedBody.password)
await authDataService.createAuth({
email: parsedBody.email,
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/data-layer/collections/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const User: CollectionConfig = {
type: "select",
required: true,
options: Object.values(MembershipType),
defaultValue: MembershipType.casual,
defaultValue: MembershipType.CASUAL,
admin: {
description: "The role of the user",
},
Expand Down
8 changes: 4 additions & 4 deletions packages/shared/src/mocks/User.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const casualUserMock: User = {
firstName: "straight",
lastName: "zhao",
email: "straight.zhao@casual.com",
role: MembershipType.casual,
role: MembershipType.CASUAL,
remainingSessions: 4,
updatedAt: new Date(2025, 0, 1).toISOString(),
createdAt: new Date(2025, 0, 1).toISOString(),
Expand All @@ -21,7 +21,7 @@ export const memberUserMock: User = {
firstName: "straight",
lastName: "zhao",
email: "straight.zhao@member.com",
role: MembershipType.member,
role: MembershipType.MEMBER,
remainingSessions: 5,
updatedAt: new Date(2025, 0, 1).toISOString(),
createdAt: new Date(2025, 0, 1).toISOString(),
Expand All @@ -32,7 +32,7 @@ export const adminUserMock: User = {
firstName: "straight",
lastName: "zhao",
email: "straight.zhao@admin.com",
role: MembershipType.admin,
role: MembershipType.ADMIN,
remainingSessions: 6,
updatedAt: new Date(2025, 0, 1).toISOString(),
createdAt: new Date(2025, 0, 1).toISOString(),
Expand All @@ -42,7 +42,7 @@ export const userCreateMock: CreateUserData = {
firstName: "straight",
lastName: "zhao",
email: "straight.zhao@example.com",
role: MembershipType.casual,
role: MembershipType.CASUAL,
remainingSessions: 7,
image: null,
}
2 changes: 1 addition & 1 deletion packages/shared/src/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export interface User {
/**
* The role of the user
*/
role: 'member' | 'casual' | 'admin';
role: 'Member' | 'Casual' | 'Admin';
/**
* The phone number of the user
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/schemas/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const UserSchema = z.object({
lastName: z.string().nullable().optional(),
email: z.string().email(),
// Payload generates a hard coded role type, the `satisfies` operator is used to ensure the type matches
role: z.enum(["admin", "member", "casual"]),
role: z.enum(["Admin", "Member", "Casual"]),
remainingSessions: z.number().nullable().optional(),
image: z.union([z.string(), MediaSchema]).nullable().optional(),
updatedAt: z.string(),
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/types/enums.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum MembershipType {
member = "member",
casual = "casual",
admin = "admin",
MEMBER = "Member",
CASUAL = "Casual",
ADMIN = "Admin",
}

export enum Weekday {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const mockData = [
id: "1",
name: "Alice Smith",
email: "alice@example.com",
role: "admin",
role: "Admin",
remaining: "10",
joined: "2021-01-01",
university: "University of Auckland",
Expand All @@ -33,7 +33,7 @@ const mockData = [
id: "2",
name: "Bob Smith",
email: "bob@example.com",
role: "casual",
role: "Casual",
remaining: "10",
joined: "2021-01-01",
university: "Auckland University of Technology",
Expand All @@ -43,7 +43,7 @@ const mockData = [
id: "3",
name: "Charlie Smith",
email: "charlie@example.com",
role: "member",
role: "Member",
remaining: "10",
joined: "2021-01-01",
university: "Massey University",
Expand All @@ -53,7 +53,7 @@ const mockData = [
id: "4",
name: "David Smith",
email: "david@example.com",
role: "casual",
role: "Casual",
remaining: "10",
joined: "2021-01-01",
university: "University of Auckland",
Expand All @@ -63,7 +63,7 @@ const mockData = [
id: "5",
name: "Eve Smith",
email: "eve@example.com",
role: "member",
role: "Member",
remaining: "10",
joined: "2021-01-01",
university: "Auckland University of Technology",
Expand All @@ -73,7 +73,7 @@ const mockData = [
id: "6",
name: "Frank Smith",
email: "frank@example.com",
role: "casual",
role: "Casual",
remaining: "10",
joined: "2021-01-01",
university: "Massey University",
Expand All @@ -83,7 +83,7 @@ const mockData = [
id: "7",
name: "Grace Smith",
email: "grace@example.com",
role: "member",
role: "Member",
remaining: "10",
joined: "2021-01-01",
university: "University of Auckland",
Expand All @@ -93,7 +93,7 @@ const mockData = [
id: "8",
name: "Hank Smith",
email: "hank@example.com",
role: "casual",
role: "Casual",
remaining: "10",
joined: "2021-01-01",
university: "Auckland University of Technology",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const mockData = [
id: "1",
name: "Alice Smith",
email: "alice@example.com",
role: "member",
role: "Member",
remaining: "10",
university: "University of Auckland",
joined: "2021-01-01",
Expand All @@ -17,7 +17,7 @@ const mockData = [
id: "2",
name: "Bob Smith",
email: "bob@example.com",
role: "member",
role: "Member",
remaining: "10",
university: "University of Auckland",
joined: "2021-01-01",
Expand All @@ -27,7 +27,7 @@ const mockData = [
id: "3",
name: "Charlie Smith",
email: "charlie@example.com",
role: "member",
role: "Member",
remaining: "10",
university: "University of Auckland",
joined: "2021-01-01",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const Default: Story = {}
export const Casual: Story = {
parameters: {
query: {
"booking-confirmed-popup-value": MembershipType.casual,
"booking-confirmed-popup-value": MembershipType.CASUAL,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("<BookingConfirmedPopup />", () => {
wrapper: withNuqsTestingAdapter({
searchParams: {
"booking-confirmed-popup": "open",
"booking-confirmed-popup-value": MembershipType.casual,
"booking-confirmed-popup-value": MembershipType.CASUAL,
},
}),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const BookingConfirmedPopup: FC<BookingConfirmedPopupProps> = ({
title,
message,
additionalMessage,
initialValue = MembershipType.member,
initialValue = MembershipType.MEMBER,
linkText = "View Booking",
...props
}) => {
Expand All @@ -68,7 +68,7 @@ export const BookingConfirmedPopup: FC<BookingConfirmedPopupProps> = ({
</ModalHeader>
<ModalBody alignItems="center" textAlign="center">
<Text>{message}</Text>
{value === MembershipType.casual && additionalMessage && <Text>{additionalMessage}</Text>}
{value === MembershipType.CASUAL && additionalMessage && <Text>{additionalMessage}</Text>}
</ModalBody>
<ModalFooter alignItems="center" justifyContent="center">
<Button as={Link} colorScheme="primary" href="/booking">
Expand Down
Loading
Loading