From c87a35e83c4afb48b2f6e8e973b6805717981fdf Mon Sep 17 00:00:00 2001 From: Garrett Ladley <92384606+garrettladley@users.noreply.github.com> Date: Sat, 27 Apr 2024 09:56:12 -0400 Subject: [PATCH 1/3] fix: unused variable (#675) --- frontend/dashboard/src/app/page.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/dashboard/src/app/page.tsx b/frontend/dashboard/src/app/page.tsx index 752a2004e..06e3a13ed 100644 --- a/frontend/dashboard/src/app/page.tsx +++ b/frontend/dashboard/src/app/page.tsx @@ -1,6 +1,4 @@ -import { useUsersQuery } from "@sac/lib"; - -import Image from "next/image"; +import Image from 'next/image'; export default function Home() { return ( From 3310db485f18b02c672959bbc673f151c27e42a4 Mon Sep 17 00:00:00 2001 From: Garrett Ladley <92384606+garrettladley@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:02:22 -0400 Subject: [PATCH 2/3] fix: removed ./package-lock.json (#677) --- package-lock.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index e8a17ac29..000000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "sac", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} From 74eb4ec0f597c7284ef81e0da380d5b366a13528 Mon Sep 17 00:00:00 2001 From: David Oduneye <44040421+DOOduneye@users.noreply.github.com> Date: Sat, 27 Apr 2024 07:07:45 -0700 Subject: [PATCH 3/3] remove: api + types in dashboard (#678) --- frontend/dashboard/src/api/api.ts | 38 --- frontend/dashboard/src/api/authApi.ts | 79 ----- frontend/dashboard/src/api/categoryApi.ts | 106 ------ frontend/dashboard/src/api/clubApi.ts | 308 ------------------ frontend/dashboard/src/api/contactApi.ts | 46 --- frontend/dashboard/src/api/eventApi.ts | 104 ------ frontend/dashboard/src/api/fileApi.ts | 57 ---- .../dashboard/src/api/pointOfContactApi.ts | 38 --- frontend/dashboard/src/api/tagApi.ts | 78 ----- frontend/dashboard/src/api/userApi.ts | 217 ------------ frontend/dashboard/src/types/auth.ts | 31 -- frontend/dashboard/src/types/category.ts | 22 -- frontend/dashboard/src/types/club.ts | 64 ---- frontend/dashboard/src/types/contact.ts | 33 -- frontend/dashboard/src/types/error.ts | 3 - frontend/dashboard/src/types/event.ts | 57 ---- frontend/dashboard/src/types/file.ts | 24 -- .../dashboard/src/types/pointOfContact.ts | 37 --- frontend/dashboard/src/types/root.ts | 14 - frontend/dashboard/src/types/tag.ts | 26 -- frontend/dashboard/src/types/user.ts | 184 ----------- frontend/dashboard/src/types/verification.ts | 38 --- frontend/lib/api/category.ts | 31 -- frontend/lib/api/club.ts | 52 --- frontend/lib/api/contact.ts | 27 -- frontend/lib/api/event.ts | 51 --- frontend/lib/api/tag.ts | 31 -- frontend/lib/api/user.ts | 66 ---- 28 files changed, 1862 deletions(-) delete mode 100644 frontend/dashboard/src/api/api.ts delete mode 100644 frontend/dashboard/src/api/authApi.ts delete mode 100644 frontend/dashboard/src/api/categoryApi.ts delete mode 100644 frontend/dashboard/src/api/clubApi.ts delete mode 100644 frontend/dashboard/src/api/contactApi.ts delete mode 100644 frontend/dashboard/src/api/eventApi.ts delete mode 100644 frontend/dashboard/src/api/fileApi.ts delete mode 100644 frontend/dashboard/src/api/pointOfContactApi.ts delete mode 100644 frontend/dashboard/src/api/tagApi.ts delete mode 100644 frontend/dashboard/src/api/userApi.ts delete mode 100644 frontend/dashboard/src/types/auth.ts delete mode 100644 frontend/dashboard/src/types/category.ts delete mode 100644 frontend/dashboard/src/types/club.ts delete mode 100644 frontend/dashboard/src/types/contact.ts delete mode 100644 frontend/dashboard/src/types/error.ts delete mode 100644 frontend/dashboard/src/types/event.ts delete mode 100644 frontend/dashboard/src/types/file.ts delete mode 100644 frontend/dashboard/src/types/pointOfContact.ts delete mode 100644 frontend/dashboard/src/types/root.ts delete mode 100644 frontend/dashboard/src/types/tag.ts delete mode 100644 frontend/dashboard/src/types/user.ts delete mode 100644 frontend/dashboard/src/types/verification.ts delete mode 100644 frontend/lib/api/category.ts delete mode 100644 frontend/lib/api/club.ts delete mode 100644 frontend/lib/api/contact.ts delete mode 100644 frontend/lib/api/event.ts delete mode 100644 frontend/lib/api/tag.ts delete mode 100644 frontend/lib/api/user.ts diff --git a/frontend/dashboard/src/api/api.ts b/frontend/dashboard/src/api/api.ts deleted file mode 100644 index 9b05bfef0..000000000 --- a/frontend/dashboard/src/api/api.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const API_BASE_URL = "http://127.0.0.1:8080/api/v1"; - -// BaseAPI for the entire application: -export const baseApi = createApi({ - baseQuery: fetchBaseQuery({ - baseUrl: API_BASE_URL, - credentials: "include", - }), - tagTypes: [ - "User", - "Tag", - "Category", - "Club", - "Contact", - "Event", - "PointOfContact", - "File", - "Follower", - "Member", - ], - endpoints: () => ({}), -}); - -// Add query params to a request: -export function handleQueryParams( - baseUrl: string, - queryParams?: Record, -): string { - const url = new URL(baseUrl); - if (queryParams) { - Object.entries(queryParams).forEach(([key, value]) => { - url.searchParams.append(key, value.toString()); - }); - } - return url.toString(); -} diff --git a/frontend/dashboard/src/api/authApi.ts b/frontend/dashboard/src/api/authApi.ts deleted file mode 100644 index e16799994..000000000 --- a/frontend/dashboard/src/api/authApi.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { baseApi } from "./api"; -import { LoginRequestBody, RefreshTokenRequestBody } from "../types/auth"; -import { User, userSchema } from "../types/user"; -import { - EmailRequestBody, - VerifyEmailRequestBody, - VerifyPasswordResetTokenRequestBody, -} from "../types/verification"; - -const AUTH_API_BASE_URL = "/auth"; - -const authApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - login: builder.mutation({ - query: (body) => ({ - url: `${AUTH_API_BASE_URL}/login`, - method: "POST", - body, - }), - transformResponse: (response: User) => { - return userSchema.parse(response); - }, - }), - logout: builder.mutation({ - query: () => ({ - url: `${AUTH_API_BASE_URL}/logout`, - method: "POST", - }), - }), - refresh: builder.mutation({ - query: (body) => ({ - url: "refresh", - method: "POST", - body, - }), - }), - forgotPassword: builder.mutation({ - query: (body) => ({ - url: `${AUTH_API_BASE_URL}/forgot-password`, - method: "POST", - body, - }), - }), - verifyPasswordResetToken: builder.mutation< - void, - VerifyPasswordResetTokenRequestBody - >({ - query: (body) => ({ - url: `${AUTH_API_BASE_URL}/verify-reset`, - method: "POST", - body, - }), - }), - sendCode: builder.mutation({ - query: (body) => ({ - url: `${AUTH_API_BASE_URL}/send-code`, - method: "POST", - body, - }), - }), - verifyEmail: builder.mutation({ - query: (body) => ({ - url: `${AUTH_API_BASE_URL}/verify-email`, - method: "POST", - body, - }), - }), - }), -}); - -export const { - useLoginMutation, - useLogoutMutation, - useRefreshMutation, - useForgotPasswordMutation, - useVerifyPasswordResetTokenMutation, - useSendCodeMutation, - useVerifyEmailMutation, -} = authApi; diff --git a/frontend/dashboard/src/api/categoryApi.ts b/frontend/dashboard/src/api/categoryApi.ts deleted file mode 100644 index c67892a43..000000000 --- a/frontend/dashboard/src/api/categoryApi.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { z } from "zod"; - -import { - Category, - categorySchema, - CreateCategoryRequestBody, -} from "../types/category"; -import { PaginationQueryParams } from "../types/root"; -import { Tag } from "../types/tag"; -import { baseApi, handleQueryParams } from "./api"; - -const CATEGORY_API_BASE_URL = "/categories"; - -const categoryApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - createCategory: builder.mutation({ - query: (body) => ({ - url: CATEGORY_API_BASE_URL, - method: "POST", - body, - }), - transformResponse: (response: Category) => { - return categorySchema.parse(response); - }, - invalidatesTags: ["Category"], - }), - categories: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${CATEGORY_API_BASE_URL}/`, queryParams), - method: "GET", - }), - transformResponse: (response: Category[]) => { - return z.array(categorySchema).parse(response); - }, - providesTags: (result, _, _arg) => - result - ? result.map((category) => ({ type: "Category", id: category.id })) - : ["Category"], - }), - category: builder.query({ - query: (id) => ({ - url: `${CATEGORY_API_BASE_URL}/${id}/`, - method: "GET", - }), - transformResponse: (response: Category) => { - return categorySchema.parse(response); - }, - providesTags: (result, _, id) => - result ? [{ type: "Category", id }] : [], - }), - deleteCategory: builder.mutation({ - query: (id) => ({ - url: `${CATEGORY_API_BASE_URL}/${id}/`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "Category", id }], - }), - updateCategory: builder.mutation< - Category, - { id: string; body: CreateCategoryRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${CATEGORY_API_BASE_URL}/${id}/`, - method: "PUT", - body, - }), - transformResponse: (response: Category) => { - return categorySchema.parse(response); - }, - invalidatesTags: (result, _, { id }) => - result ? [{ type: "Category", id }] : [], - }), - categoryTags: builder.query< - Tag[], - { id: string; queryParams?: PaginationQueryParams } - >({ - query: ({ id, queryParams }) => ({ - url: handleQueryParams( - `${CATEGORY_API_BASE_URL}/${id}/tags/`, - queryParams, - ), - method: "GET", - }), - providesTags: (result, _, _arg) => - result ? result.map((tag) => ({ type: "Tag", id: tag.id })) : ["Tag"], - }), - categoryTag: builder.query({ - query: ({ categoryID, tagID }) => ({ - url: `${CATEGORY_API_BASE_URL}/${categoryID}/tags/${tagID}/`, - method: "GET", - }), - providesTags: (result, _, { tagID }) => - result ? [{ type: "Tag", id: tagID }] : [], - }), - }), -}); - -export const { - useCreateCategoryMutation, - useCategoriesQuery, - useCategoryQuery, - useDeleteCategoryMutation, - useUpdateCategoryMutation, - useCategoryTagsQuery, - useCategoryTagQuery, -} = categoryApi; diff --git a/frontend/dashboard/src/api/clubApi.ts b/frontend/dashboard/src/api/clubApi.ts deleted file mode 100644 index 4e26121b2..000000000 --- a/frontend/dashboard/src/api/clubApi.ts +++ /dev/null @@ -1,308 +0,0 @@ -import { z } from "zod"; -import { - Club, - CreateClubRequestBody, - CreateClubTagsRequestBody, - UpdateClubRequestBody, - clubSchema, -} from "../types/club"; -import { baseApi, handleQueryParams } from "./api"; -import { - Contact, - CreateContactRequestBody, - contactSchema, -} from "../types/contact"; -import { Event, eventSchema } from "../types/event"; -import { User, userSchema } from "../types/user"; -import { PaginationQueryParams } from "../types/root"; -import { - PointOfContact, - UpdatePointOfContactRequestBody, - pointOfContactSchema, -} from "../types/pointOfContact"; -import { Tag, tagSchema } from "../types/tag"; - -export const CLUB_API_BASE_URL = "/clubs"; - -const clubApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - createClub: builder.mutation({ - query: (body) => ({ - url: `${CLUB_API_BASE_URL}/`, - method: "POST", - body, - }), - invalidatesTags: ["Club"], - transformResponse: (response: Club) => { - return clubSchema.parse(response); - }, - }), - clubs: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${CLUB_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((club) => ({ type: "Club", id: club.id })) - : ["Club"], - transformResponse: (response: Club) => { - return z.array(clubSchema).parse(response); - }, - }), - club: builder.query({ - query: (id) => ({ - url: `${CLUB_API_BASE_URL}/${id}/`, - method: "GET", - }), - providesTags: (result, _, id) => (result ? [{ type: "Club", id }] : []), - transformResponse: (response: Club) => { - return clubSchema.parse(response); - }, - }), - updateClub: builder.mutation< - Club, - { id: string; body: UpdateClubRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${CLUB_API_BASE_URL}/${id}/`, - method: "PATCH", - body, - }), - invalidatesTags: (result, _, { id }) => - result ? [{ type: "Club", id }] : [], - transformResponse: (response: Club) => { - return clubSchema.parse(response); - }, - }), - deleteClub: builder.mutation({ - query: (id) => ({ - url: `${CLUB_API_BASE_URL}/${id}/`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "Club", id }], - }), - clubContacts: builder.query({ - query: (id) => ({ - url: `${CLUB_API_BASE_URL}/${id}/contacts/`, - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((contact) => ({ type: "Contact", id: contact.id })) - : ["Contact"], - transformResponse: (response: Contact) => { - return z.array(contactSchema).parse(response); - }, - }), - createContact: builder.mutation< - Contact, - { id: string; body: CreateContactRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${CLUB_API_BASE_URL}/${id}/contacts/`, - method: "PUT", - body, - }), - invalidatesTags: ["Contact"], - transformResponse: (response: Contact) => { - return contactSchema.parse(response); - }, - }), - clubEvents: builder.query< - Event[], - { id: string; queryParams?: PaginationQueryParams } - >({ - query: ({ id, queryParams }) => ({ - url: handleQueryParams( - `${CLUB_API_BASE_URL}/${id}/events/`, - queryParams, - ), - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((event) => ({ type: "Event", id: event.id })) - : ["Event"], - transformResponse: (response) => { - return z.array(eventSchema).parse(response); - }, - }), - clubFollowers: builder.query< - User[], - { id: string; queryParams?: PaginationQueryParams } - >({ - query: ({ id, queryParams }) => ({ - url: handleQueryParams( - `${CLUB_API_BASE_URL}/${id}/followers/`, - queryParams, - ), - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((follower) => ({ type: "Follower", id: follower.id })) - : ["Follower"], - transformResponse: (response) => { - return z.array(userSchema).parse(response); - }, - }), - clubMembers: builder.query< - User[], - { id: string; queryParams?: PaginationQueryParams } - >({ - query: ({ id, queryParams }) => ({ - url: handleQueryParams( - `${CLUB_API_BASE_URL}/${id}/members/`, - queryParams, - ), - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((member) => ({ type: "User", id: member.id })) - : ["User"], - transformResponse: (response) => { - return z.array(userSchema).parse(response); - }, - }), - pointOfContacts: builder.query({ - query: (id) => ({ - url: `${CLUB_API_BASE_URL}/${id}/pocs/`, - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((poc) => ({ type: "PointOfContact", id: poc.id })) - : ["PointOfContact"], - transformResponse: (response) => { - return z.array(pointOfContactSchema).parse(response); - }, - }), - pointOfContact: builder.query< - PointOfContact, - { clubId: string; pocId: string } - >({ - query: ({ clubId, pocId }) => ({ - url: `${CLUB_API_BASE_URL}/${clubId}/pocs/${pocId}`, - method: "GET", - }), - providesTags: (result, _, { pocId }) => - result ? [{ type: "PointOfContact", id: pocId }] : [], - transformResponse: (response) => { - return pointOfContactSchema.parse(response); - }, - }), - createPointOfContact: builder.mutation< - PointOfContact, - { id: string; body: FormData } - >({ - query: ({ id, body }) => ({ - url: `${CLUB_API_BASE_URL}/${id}/pocs/`, - method: "POST", - body, - }), - invalidatesTags: ["PointOfContact"], - transformResponse: (response) => { - return pointOfContactSchema.parse(response); - }, - }), - updatePointOfContactPhoto: builder.mutation< - PointOfContact, - { clubId: string; pocId: string; body: FormData } - >({ - query: ({ clubId, pocId, body }) => ({ - url: `${CLUB_API_BASE_URL}/${clubId}/pocs/${pocId}/photo`, - method: "PATCH", - body, - }), - invalidatesTags: (result, _, { pocId }) => - result ? [{ type: "PointOfContact", id: pocId }] : [], - transformResponse: (response) => { - return pointOfContactSchema.parse(response); - }, - }), - updatePointOfContact: builder.mutation< - PointOfContact, - { clubId: string; pocId: string; body: UpdatePointOfContactRequestBody } - >({ - query: ({ clubId, pocId, body }) => ({ - url: `${CLUB_API_BASE_URL}/${clubId}/pocs/${pocId}`, - method: "PATCH", - body, - }), - invalidatesTags: (result, _, { pocId }) => - result ? [{ type: "PointOfContact", id: pocId }] : [], - transformResponse: (response) => { - return pointOfContactSchema.parse(response); - }, - }), - deletePointOfContact: builder.mutation< - void, - { clubId: string; pocId: string } - >({ - query: ({ clubId, pocId }) => ({ - url: `${CLUB_API_BASE_URL}/${clubId}/pocs/${pocId}`, - method: "DELETE", - }), - invalidatesTags: (_result, _, { pocId }) => [ - { type: "PointOfContact", id: pocId }, - ], - }), - createClubTags: builder.mutation< - Tag[], - { id: string; body: CreateClubTagsRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${CLUB_API_BASE_URL}/${id}/tags/`, - method: "POST", - body, - }), - invalidatesTags: (result, _, _arg) => - result ? result.map((tag) => ({ type: "Tag", id: tag.id })) : ["Tag"], - transformResponse: (response) => { - return z.array(tagSchema).parse(response); - }, - }), - clubTags: builder.query({ - query: (id) => ({ - url: `${CLUB_API_BASE_URL}/${id}/tags/`, - method: "GET", - }), - providesTags: (result, _, _arg) => - result ? result.map((tag) => ({ type: "Tag", id: tag.id })) : ["Tag"], - transformResponse: (response) => { - return z.array(tagSchema).parse(response); - }, - }), - deleteClubTag: builder.mutation({ - query: ({ clubId, tagId }) => ({ - url: `${CLUB_API_BASE_URL}/${clubId}/tags/${tagId}`, - method: "DELETE", - }), - invalidatesTags: (_result, _, { tagId }) => [{ type: "Tag", id: tagId }], - }), - }), -}); - -export const { - useCreateClubMutation, - useClubsQuery, - useClubQuery, - useUpdateClubMutation, - useDeleteClubMutation, - useClubContactsQuery, - useCreateContactMutation, - useClubEventsQuery, - useClubFollowersQuery, - useClubMembersQuery, - usePointOfContactsQuery, - usePointOfContactQuery, - useCreatePointOfContactMutation, - useUpdatePointOfContactPhotoMutation, - useUpdatePointOfContactMutation, - useDeletePointOfContactMutation, - useCreateClubTagsMutation, - useClubTagsQuery, - useDeleteClubTagMutation, -} = clubApi; diff --git a/frontend/dashboard/src/api/contactApi.ts b/frontend/dashboard/src/api/contactApi.ts deleted file mode 100644 index 6e26e71fa..000000000 --- a/frontend/dashboard/src/api/contactApi.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { z } from "zod"; - -import { Contact, contactSchema } from "../types/contact"; -import { PaginationQueryParams } from "../types/root"; -import { baseApi, handleQueryParams } from "./api"; - -const CONTACT_API_BASE_URL = "/contacts"; - -const contactApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - contact: builder.query({ - query: (id) => ({ - url: `${CONTACT_API_BASE_URL}/${id}`, - method: "GET", - }), - providesTags: (result, _, id) => - result ? [{ type: "Contact", id }] : [], - transformResponse: (response) => { - return contactSchema.parse(response); - }, - }), - contacts: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${CONTACT_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result) => - result - ? result.map(({ id }) => ({ type: "Contact", id })) - : ["Contact"], - transformResponse: (response) => { - return z.array(contactSchema).parse(response); - }, - }), - deleteContact: builder.mutation({ - query: (id) => ({ - url: `${CONTACT_API_BASE_URL}/${id}`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "Contact", id }], - }), - }), -}); - -export const { useContactQuery, useContactsQuery, useDeleteContactMutation } = - contactApi; diff --git a/frontend/dashboard/src/api/eventApi.ts b/frontend/dashboard/src/api/eventApi.ts deleted file mode 100644 index 05cc85aaf..000000000 --- a/frontend/dashboard/src/api/eventApi.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { z } from "zod"; -import { - CreateEventRequestBody, - Event, - UpdateEventRequestBody, - eventSchema, -} from "../types/event"; -import { baseApi, handleQueryParams } from "./api"; -import { Club, clubSchema } from "../types/club"; -import { PaginationQueryParams } from "../types/root"; -import { Tag } from "../types/tag"; - -const EVENT_API_BASE_URL = "/events"; - -const eventApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - events: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${EVENT_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result, _, _arg) => - result - ? result.map((event) => ({ type: "Event", id: event.id })) - : ["Event"], - transformResponse: (response) => { - return z.array(eventSchema).parse(response); - }, - }), - event: builder.query({ - query: (id) => ({ - url: `${EVENT_API_BASE_URL}/${id}/`, - method: "GET", - }), - providesTags: (result, _, id) => (result ? [{ type: "Event", id }] : []), - transformResponse: (response: Event) => { - return eventSchema.parse(response); - }, - }), - createEvent: builder.mutation({ - query: (body) => ({ - url: `${EVENT_API_BASE_URL}/`, - method: "POST", - body, - }), - invalidatesTags: ["Event"], - transformResponse: (response) => { - return eventSchema.parse(response); - }, - }), - updateEvent: builder.mutation< - Event, - { id: string; body: UpdateEventRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${EVENT_API_BASE_URL}/${id}`, - method: "PATCH", - body, - }), - invalidatesTags: (result, _, { id }) => - result ? [{ type: "Event", id }] : [], - transformResponse: (response) => { - return eventSchema.parse(response); - }, - }), - deleteEvent: builder.mutation({ - query: (id) => ({ - url: `${EVENT_API_BASE_URL}/${id}`, - method: "DELETE", - }), - invalidatesTags: (result, _, id) => - result ? [{ type: "Event", id }] : [], - }), - eventHosts: builder.query({ - query: (id) => ({ - url: `${EVENT_API_BASE_URL}/${id}/hosts`, - method: "GET", - }), - providesTags: (result, _, id) => - result ? [{ type: "Event", id }, "Club"] : ["Event"], - transformResponse: (response) => { - return z.array(clubSchema).parse(response); - }, - }), - eventTags: builder.query({ - query: (id) => ({ - url: `${EVENT_API_BASE_URL}/${id}/tags`, - method: "GET", - }), - providesTags: (result, _, _arg) => - result ? result.map((tag) => ({ type: "Tag", id: tag.id })) : ["Tag"], - }), - }), -}); - -export const { - useEventsQuery, - useEventQuery, - useCreateEventMutation, - useUpdateEventMutation, - useDeleteEventMutation, - useEventHostsQuery, - useEventTagsQuery, -} = eventApi; diff --git a/frontend/dashboard/src/api/fileApi.ts b/frontend/dashboard/src/api/fileApi.ts deleted file mode 100644 index 8ff917c22..000000000 --- a/frontend/dashboard/src/api/fileApi.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { z } from "zod"; -import { File, fileSchema } from "../types/file"; -import { PaginationQueryParams } from "../types/root"; -import { baseApi, handleQueryParams } from "./api"; - -const FILE_API_BASE_URL = "/files"; - -const fileApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - files: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${FILE_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result) => - result ? result.map(({ id }) => ({ type: "File", id })) : ["File"], - transformResponse: (response) => { - return z.array(fileSchema).parse(response); - }, - }), - file: builder.query({ - query: (id) => ({ - url: `${FILE_API_BASE_URL}/${id}`, - method: "GET", - }), - providesTags: (result, _, id) => (result ? [{ type: "File", id }] : []), - transformResponse: (response) => { - return fileSchema.parse(response); - }, - }), - createFile: builder.mutation({ - query: (body) => ({ - url: `${FILE_API_BASE_URL}/`, - method: "POST", - body, - }), - invalidatesTags: ["File"], - transformResponse: (response) => { - return fileSchema.parse(response); - }, - }), - deleteFile: builder.mutation({ - query: (id) => ({ - url: `${FILE_API_BASE_URL}/${id}`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "File", id }], - }), - }), -}); - -export const { - useFilesQuery, - useFileQuery, - useCreateFileMutation, - useDeleteFileMutation, -} = fileApi; diff --git a/frontend/dashboard/src/api/pointOfContactApi.ts b/frontend/dashboard/src/api/pointOfContactApi.ts deleted file mode 100644 index aa5df0ae5..000000000 --- a/frontend/dashboard/src/api/pointOfContactApi.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { z } from "zod"; -import { PointOfContact, pointOfContactSchema } from "../types/pointOfContact"; -import { PaginationQueryParams } from "../types/root"; -import { baseApi, handleQueryParams } from "./api"; - -const POC_API_BASE_URL = "/pocs"; - -const pointOfContactApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - pointOfContacts: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${POC_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result) => - result - ? result.map(({ id }) => ({ type: "PointOfContact", id })) - : ["PointOfContact"], - transformResponse: (response) => { - return z.array(pointOfContactSchema).parse(response); - }, - }), - pointOfContact: builder.query({ - query: (id) => ({ - url: `${POC_API_BASE_URL}/${id}`, - method: "GET", - }), - providesTags: (result, _, id) => - result ? [{ type: "PointOfContact", id }] : [], - transformResponse: (response) => { - return pointOfContactSchema.parse(response); - }, - }), - }), -}); - -export const { usePointOfContactsQuery, usePointOfContactQuery } = - pointOfContactApi; diff --git a/frontend/dashboard/src/api/tagApi.ts b/frontend/dashboard/src/api/tagApi.ts deleted file mode 100644 index 4b12dc58e..000000000 --- a/frontend/dashboard/src/api/tagApi.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { z } from "zod"; -import { PaginationQueryParams } from "../types/root"; -import { - CreateTagRequestBody, - Tag, - UpdateTagRequestBody, - tagSchema, -} from "../types/tag"; -import { baseApi, handleQueryParams } from "./api"; - -const TAG_API_BASE_URL = "/tags"; - -const tagApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - tags: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${TAG_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result) => - result ? result.map(({ id }) => ({ type: "Tag", id })) : ["Tag"], - transformResponse: (response) => { - return z.array(tagSchema).parse(response); - }, - }), - tag: builder.query({ - query: (id) => ({ - url: `${TAG_API_BASE_URL}/${id}/`, - method: "GET", - }), - providesTags: (result, _, id) => (result ? [{ type: "Tag", id }] : []), - transformResponse: (response) => { - return tagSchema.parse(response); - }, - }), - createTag: builder.mutation({ - query: (body) => ({ - url: `${TAG_API_BASE_URL}/`, - method: "POST", - body, - }), - invalidatesTags: ["Tag"], - transformResponse: (response) => { - return tagSchema.parse(response); - }, - }), - updateTag: builder.mutation< - Tag, - { id: string; body: UpdateTagRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${TAG_API_BASE_URL}/${id}/`, - method: "PATCH", - body, - }), - invalidatesTags: (result, _, { id }) => - result ? [{ type: "Tag", id }] : [], - transformResponse: (response) => { - return tagSchema.parse(response); - }, - }), - deleteTag: builder.mutation({ - query: (id) => ({ - url: `${TAG_API_BASE_URL}/${id}/`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "Tag", id }], - }), - }), -}); - -export const { - useTagsQuery, - useTagQuery, - useCreateTagMutation, - useUpdateTagMutation, - useDeleteTagMutation, -} = tagApi; diff --git a/frontend/dashboard/src/api/userApi.ts b/frontend/dashboard/src/api/userApi.ts deleted file mode 100644 index 23bb777e7..000000000 --- a/frontend/dashboard/src/api/userApi.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { z } from "zod"; -import { PaginationQueryParams } from "../types/root"; -import { - CreateUserRequestBody, - CreateUserTagsRequestBody, - UpdateUserRequestBody, - User, - userSchema, -} from "../types/user"; -import { baseApi, handleQueryParams } from "./api"; -import { UpdatePasswordRequestBody } from "../types/auth"; -import { Club, clubSchema } from "../types/club"; -import { Tag, tagSchema } from "../types/tag"; - -const USER_API_BASE_URL = "/users"; - -const userApi = baseApi.injectEndpoints({ - endpoints: (builder) => ({ - users: builder.query({ - query: (queryParams) => ({ - url: handleQueryParams(`${USER_API_BASE_URL}/`, queryParams), - method: "GET", - }), - providesTags: (result) => - result ? result.map(({ id }) => ({ type: "User", id })) : ["User"], - transformResponse: (response) => { - return z.array(userSchema).parse(response); - }, - }), - user: builder.query({ - query: (id) => ({ - url: `${USER_API_BASE_URL}/${id}/`, - method: "GET", - }), - providesTags: (result, _, id) => (result ? [{ type: "User", id }] : []), - transformResponse: (response) => { - return userSchema.parse(response); - }, - }), - currentUser: builder.query({ - query: () => ({ - url: `${USER_API_BASE_URL}/me`, - method: "GET", - }), - providesTags: (result) => - result ? [{ type: "User", id: result.id }] : [], - transformResponse: (response) => { - return userSchema.parse(response); - }, - }), - createUser: builder.mutation({ - query: (body) => ({ - url: `${USER_API_BASE_URL}/`, - method: "POST", - body, - }), - invalidatesTags: ["User"], - transformResponse: (response) => { - return userSchema.parse(response); - }, - }), - updateUser: builder.mutation< - User, - { id: string; body: UpdateUserRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${USER_API_BASE_URL}/${id}/`, - method: "PATCH", - body, - }), - invalidatesTags: (result, _, { id }) => - result ? [{ type: "User", id }] : [], - transformResponse: (response) => { - return userSchema.parse(response); - }, - }), - deleteUser: builder.mutation({ - query: (id) => ({ - url: `${USER_API_BASE_URL}/${id}/`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "User", id }], - }), - updatePassword: builder.mutation< - void, - { id: string; body: UpdatePasswordRequestBody } - >({ - query: ({ id, body }) => ({ - url: `${USER_API_BASE_URL}/${id}/password`, - method: "PATCH", - body, - }), - }), - userFollowing: builder.query({ - query: (id) => ({ - url: `${USER_API_BASE_URL}/${id}/follower/`, - method: "GET", - }), - providesTags: (result, _, id) => - result - ? [{ type: "Follower", id }, "Club"] - : [{ type: "Follower", id }], - transformResponse: (response) => { - return z.array(clubSchema).parse(response); - }, - }), - createUserFollowing: builder.mutation< - void, - { userId: string; clubId: string } - >({ - query: ({ userId, clubId }) => ({ - url: `${USER_API_BASE_URL}/${userId}/follower/${clubId}`, - method: "POST", - }), - invalidatesTags: (_result, _, { userId }) => [ - { type: "Follower", id: userId }, - ], - }), - deleteUserFollowing: builder.mutation< - void, - { userId: string; clubId: string } - >({ - query: ({ userId, clubId }) => ({ - url: `${USER_API_BASE_URL}/${userId}/follower/${clubId}`, - method: "DELETE", - }), - invalidatesTags: (_result, _, { userId }) => [ - { type: "Follower", id: userId }, - ], - }), - userMembership: builder.query({ - query: (id) => ({ - url: `${USER_API_BASE_URL}/${id}/member/`, - method: "GET", - }), - providesTags: (result, _, id) => - result ? [{ type: "Member", id }, "Club"] : [{ type: "Member", id }], - transformResponse: (response) => { - return z.array(clubSchema).parse(response); - }, - }), - createUserMembership: builder.mutation< - void, - { userId: string; clubId: string } - >({ - query: ({ userId, clubId }) => ({ - url: `${USER_API_BASE_URL}/${userId}/member/${clubId}`, - method: "POST", - }), - invalidatesTags: (_result, _, { userId }) => [ - { type: "Follower", id: userId }, - { type: "Member", id: userId }, - ], - }), - deleteUserMembership: builder.mutation< - void, - { userId: string; clubId: string } - >({ - query: ({ userId, clubId }) => ({ - url: `${USER_API_BASE_URL}/${userId}/member/${clubId}`, - method: "DELETE", - }), - invalidatesTags: (_result, _, { userId }) => [ - { type: "Member", id: userId }, - ], - }), - userTags: builder.query({ - query: () => ({ - url: `${USER_API_BASE_URL}/tags/`, - method: "GET", - }), - providesTags: (result) => - result ? result.map((tag) => ({ type: "Tag", id: tag.id })) : ["Tag"], - transformResponse: (response) => { - return z.array(tagSchema).parse(response); - }, - }), - createUserTags: builder.mutation({ - query: (body) => ({ - url: `${USER_API_BASE_URL}/tags/`, - method: "POST", - body, - }), - invalidatesTags: (result, _, _arg) => - result ? result.map((tag) => ({ type: "Tag", id: tag.id })) : ["Tag"], - transformResponse: (response) => { - return z.array(tagSchema).parse(response); - }, - }), - deleteUserTag: builder.mutation({ - query: (id) => ({ - url: `${USER_API_BASE_URL}/tags/${id}/`, - method: "DELETE", - }), - invalidatesTags: (_result, _, id) => [{ type: "Tag", id }], - }), - }), -}); - -export const { - useUsersQuery, - useUserQuery, - useCurrentUserQuery, - useCreateUserMutation, - useUpdateUserMutation, - useDeleteUserMutation, - useUpdatePasswordMutation, - useUserFollowingQuery, - useCreateUserFollowingMutation, - useDeleteUserFollowingMutation, - useUserMembershipQuery, - useCreateUserMembershipMutation, - useDeleteUserMembershipMutation, - useUserTagsQuery, - useCreateUserTagsMutation, - useDeleteUserTagMutation, -} = userApi; diff --git a/frontend/dashboard/src/types/auth.ts b/frontend/dashboard/src/types/auth.ts deleted file mode 100644 index e45d7af5f..000000000 --- a/frontend/dashboard/src/types/auth.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { z } from "zod"; - -// Schemas: -export const loginRequestBodySchema = z.object({ - email: z.string().email(), - password: z.string().min(8), -}); - -export const updatePasswordRequestBodySchema = z.object({ - old_password: z.string().min(8), - new_password: z.string().min(8), -}); - -export const refreshTokenRequestBodySchema = z.object({ - refresh_token: z.string(), -}); - -export const tokensSchema = z.object({ - access_token: z.string(), - refresh_token: z.string(), -}); - -// Types: -export type LoginRequestBody = z.infer; -export type UpdatePasswordRequestBody = z.infer< - typeof updatePasswordRequestBodySchema ->; -export type RefreshTokenRequestBody = z.infer< - typeof refreshTokenRequestBodySchema ->; -export type Tokens = z.infer; diff --git a/frontend/dashboard/src/types/category.ts b/frontend/dashboard/src/types/category.ts deleted file mode 100644 index 6577d5693..000000000 --- a/frontend/dashboard/src/types/category.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { z } from "zod"; - -import { rootModelSchema } from "./root"; -import { tagSchema } from "./tag"; - -// Schemas: -export const createCategoryRequestBodySchema = z.object({ - name: z.string().min(1), -}); - -export const categorySchemaIntermediate = z.object({ - name: z.string(), - tags: z.array(tagSchema), -}); - -export const categorySchema = categorySchemaIntermediate.merge(rootModelSchema); - -// Types: -export type CreateCategoryRequestBody = z.infer< - typeof createCategoryRequestBodySchema ->; -export type Category = z.infer; diff --git a/frontend/dashboard/src/types/club.ts b/frontend/dashboard/src/types/club.ts deleted file mode 100644 index 7b3c7f9a7..000000000 --- a/frontend/dashboard/src/types/club.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { z } from "zod"; -import { rootModelSchema } from "./root"; - -// Enums: -const recruitmentCycleEnum = z.enum(["fall", "spring", "fallSpring", "always"]); -const recruitmentTypeEnum = z.enum(["unrestricted", "tryout", "application"]); - -// Schemas: -export const createClubRequestBodySchema = z.object({ - user_id: z.string().uuid(), - name: z.string(), - preview: z.string(), - description: z.string(), - is_recruiting: z.boolean(), - recruitment_cycle: recruitmentCycleEnum, - recruitment_type: recruitmentTypeEnum, - application_link: z.string(), - logo: z.string().optional(), - weekly_time_committment: z.number().optional(), - one_word_to_describe_us: z.string().max(20).optional(), -}); - -export const updateClubRequestBodySchema = z.object({ - name: z.string().optional(), - preview: z.string().optional(), - description: z.string().optional(), - is_recruiting: z.boolean().optional(), - recruitment_cycle: recruitmentCycleEnum.optional(), - recruitment_type: recruitmentTypeEnum.optional(), - application_link: z.string().optional(), - logo: z.string().optional(), - weekly_time_committment: z.number().optional(), - one_word_to_describe_us: z.string().max(20).optional(), -}); - -export const createClubTagsRequestBodySchema = z.object({ - tags: z.array(z.string().uuid()), -}); - -const clubSchemaIntermediate = z.object({ - name: z.string().max(255), - preview: z.string().max(255), - description: z.string().max(255), - num_members: z.number(), - is_recruiting: z.boolean(), - recruitment_cycle: recruitmentCycleEnum, - recruitment_type: recruitmentTypeEnum, - application_link: z.string().max(255), - logo: z.string().max(255).optional(), - weekly_time_committment: z.number().optional(), - one_word_to_describe_us: z.string().max(20).optional(), -}); - -export const clubSchema = clubSchemaIntermediate.merge(rootModelSchema); - -// Types: -export type RecruitmentCycle = z.infer; -export type RecruitmentType = z.infer; -export type CreateClubRequestBody = z.infer; -export type UpdateClubRequestBody = z.infer; -export type CreateClubTagsRequestBody = z.infer< - typeof createClubTagsRequestBodySchema ->; -export type Club = z.infer; diff --git a/frontend/dashboard/src/types/contact.ts b/frontend/dashboard/src/types/contact.ts deleted file mode 100644 index 7ec56c109..000000000 --- a/frontend/dashboard/src/types/contact.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { z } from "zod"; - -import { rootModelSchema } from "./root"; - -// Enums: -const contactTypeEnum = z.enum([ - "facebook", - "instagram", - "x", - "linkedin", - "youtube", - "github", - "slack", - "discord", - "email", - "customSite", -]); - -// Schemas: -export const createContactRequestBodySchema = z.object({ - type: contactTypeEnum, - content: z.string().max(255), -}); - -export const contactSchema = - createContactRequestBodySchema.merge(rootModelSchema); - -// Types: -export type ContactType = z.infer; -export type CreateContactRequestBody = z.infer< - typeof createContactRequestBodySchema ->; -export type Contact = z.infer; diff --git a/frontend/dashboard/src/types/error.ts b/frontend/dashboard/src/types/error.ts deleted file mode 100644 index 6bfb33c7d..000000000 --- a/frontend/dashboard/src/types/error.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type ErrorResponse = { - error: string; -}; diff --git a/frontend/dashboard/src/types/event.ts b/frontend/dashboard/src/types/event.ts deleted file mode 100644 index 594a01c5d..000000000 --- a/frontend/dashboard/src/types/event.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { z } from "zod"; - -import { rootModelSchema } from "./root"; - -/** - * TODO: Re-Write After BE Fixes - */ - -// Enums: -const eventTypeEnum = z.enum(["open", "membersOnly"]); - -// Schemas: -const createEventRequestBodySchema = z.object({ - name: z.string(), - preview: z.string(), - content: z.string(), - start_time: z.date(), - end_time: z.date(), - location: z.string(), - event_type: eventTypeEnum, - is_recurring: z.boolean(), -}); - -const updateEventRequestBodySchema = z.object({ - name: z.string().optional(), - preview: z.string().optional(), - content: z.string().optional(), - start_time: z.date().optional(), - end_time: z.date().optional(), - location: z.string().optional(), - event_type: eventTypeEnum.optional(), - host: z.string().uuid().optional(), -}); - -const eventSchemaIntermediate = z.object({ - name: z.string().max(255), - preview: z.string().max(255), - content: z.string().max(255), - start_time: z.date(), - end_time: z.date(), - location: z.string().max(255), - meeting_link: z.string().max(255).optional(), - event_type: eventTypeEnum, - is_recurring: z.boolean(), - host: z.string().uuid(), -}); - -export const eventSchema = eventSchemaIntermediate.merge(rootModelSchema); - -// Types: -export type CreateEventRequestBody = z.infer< - typeof createEventRequestBodySchema ->; -export type UpdateEventRequestBody = z.infer< - typeof updateEventRequestBodySchema ->; -export type Event = z.infer; diff --git a/frontend/dashboard/src/types/file.ts b/frontend/dashboard/src/types/file.ts deleted file mode 100644 index b9ac4936d..000000000 --- a/frontend/dashboard/src/types/file.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { z } from "zod"; -import { rootModelSchema } from "./root"; - -// Schemas: -export const createFileRequestBodySchema = z.object({ - owner_id: z.string().uuid(), - owner_type: z.string().max(255), -}); - -const fileSchemaIntermediate = z.object({ - owner_id: z.string().uuid(), - owner_type: z.string().max(255), - file_name: z.string().max(255), - file_type: z.string().max(255), - file_size: z.number().min(1), - file_url: z.string().max(255), - object_key: z.string().max(255), -}); - -export const fileSchema = fileSchemaIntermediate.merge(rootModelSchema); - -// Types: -export type CreateFileRequestBody = z.infer; -export type File = z.infer; diff --git a/frontend/dashboard/src/types/pointOfContact.ts b/frontend/dashboard/src/types/pointOfContact.ts deleted file mode 100644 index 007b9df3e..000000000 --- a/frontend/dashboard/src/types/pointOfContact.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { z } from "zod"; -import { fileSchema } from "./file"; -import { rootModelSchema } from "./root"; - -// Schemas: -const createPointOfContactRequestBodySchema = z.object({ - name: z.string(), - email: z.string().email(), - position: z.string(), -}); - -const updatePointOfContactRequestBodySchema = z.object({ - name: z.string().optional(), - email: z.string().email().optional(), - position: z.string().optional(), -}); - -const pointOfContactSchemaIntermediate = z.object({ - name: z.string().max(255), - email: z.string().email(), - position: z.string().max(255), - photo_file: fileSchema, -}); - -export const pointOfContactSchema = - pointOfContactSchemaIntermediate.merge(rootModelSchema); - -// Types: -export type CreatePointOfContactRequestBody = z.infer< - typeof createPointOfContactRequestBodySchema ->; -export type UpdatePointOfContactRequestBody = z.infer< - typeof updatePointOfContactRequestBodySchema ->; - -// Types: -export type PointOfContact = z.infer; diff --git a/frontend/dashboard/src/types/root.ts b/frontend/dashboard/src/types/root.ts deleted file mode 100644 index 4b75525e3..000000000 --- a/frontend/dashboard/src/types/root.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { z } from "zod"; - -export const rootModelSchema = z.object({ - id: z.string().uuid(), - created_at: z.date(), - updated_at: z.date(), -}); - -const paginationQueryParams = z.object({ - page: z.number().int().positive().optional(), - limit: z.number().int().positive().optional(), -}); - -export type PaginationQueryParams = z.infer; diff --git a/frontend/dashboard/src/types/tag.ts b/frontend/dashboard/src/types/tag.ts deleted file mode 100644 index 4a350be13..000000000 --- a/frontend/dashboard/src/types/tag.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { z } from "zod"; - -import { rootModelSchema } from "./root"; - -// Schemas: -export const createTagRequestBodySchema = z.object({ - name: z.string(), - categoryID: z.string().uuid(), -}); - -export const updateTagRequestBodySchema = z.object({ - name: z.string().optional(), - categoryID: z.string().uuid().optional(), -}); - -export const tagSchemaIntermediate = z.object({ - name: z.string().max(255), - category_id: z.string().uuid(), -}); - -export const tagSchema = tagSchemaIntermediate.merge(rootModelSchema); - -// Types: -export type UpdateTagRequestBody = z.infer; -export type CreateTagRequestBody = z.infer; -export type Tag = z.infer; diff --git a/frontend/dashboard/src/types/user.ts b/frontend/dashboard/src/types/user.ts deleted file mode 100644 index b2e9b1572..000000000 --- a/frontend/dashboard/src/types/user.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { z } from "zod"; - -import { rootModelSchema } from "./root"; - -// Enums: -export const userRoleEnum = z.enum(["super", "student"]); - -export const collegeEnum = z.enum([ - "CAMD", - "DMSB", - "KCCS", - "CE", - "BCHS", - "SL", - "CPS", - "CS", - "CSSH", -]); - -export const majorEnum = z.enum([ - "africanaStudies", - "americanSignLanguage", - "americanSignLanguage-EnglishInterpreting", - "appliedPhysics", - "architecturalStudies", - "architecture", - "art:ArtVisualStudies", - "behavioralNeuroscience", - "biochemistry", - "bioengineering", - "biology", - "biomedicalPhysics", - "businessAdministration", - "businessAdministration:Accounting", - "businessAdministration:AccountingAndAdvisoryServices", - "businessAdministration:BrandManagement", - "businessAdministration:BusinessAnalytics", - "businessAdministration:CorporateInnovation", - "businessAdministration:EntrepreneurialStartups", - "businessAdministration:FamilyBusiness", - "businessAdministration:Finance", - "businessAdministration:Fintech", - "businessAdministration:HealthcareManagementAndConsulting", - "businessAdministration:Management", - "businessAdministration:ManagementInformationSystems", - "businessAdministration:Marketing", - "businessAdministration:MarketingAnalytics", - "businessAdministration:SocialInnovationAndEntrepreneurship", - "businessAdministration:SupplyChainManagement", - "cellAndMolecularBiology", - "chemicalEngineering", - "chemistry", - "civilEngineering", - "communicationStudies", - "computerEngineering", - "computerScience", - "computingAndLaw", - "criminologyAndCriminalJustice", - "culturalAnthropology", - "cybersecurity", - "dataScience", - "design", - "economics", - "electricalEngineering", - "english", - "environmentalAndSustainabilityStudies", - "environmentalEngineering", - "environmentalScience", - "environmentalStudies", - "gameArtAndAnimation", - "gameDesign", - "globalAsianStudies", - "healthScience", - "history", - "historyCultureAndLaw", - "humanServices", - "industrialEngineering", - "internationalAffairs", - "internationalBusiness", - "internationalBusiness:Accounting", - "internationalBusiness:AccountingAndAdvisoryServices", - "internationalBusiness:BrandManagement", - "internationalBusiness:BusinessAnalytics", - "internationalBusiness:CorporateInnovation", - "internationalBusiness:EntrepreneurialStartups", - "internationalBusiness:FamilyBusiness", - "internationalBusiness:Finance", - "internationalBusiness:Fintech", - "internationalBusiness:HealthcareManagementAndConsulting", - "internationalBusiness:Management", - "internationalBusiness:ManagementInformationSystems", - "internationalBusiness:Marketing", - "internationalBusiness:MarketingAnalytics", - "internationalBusiness:SocialInnovationAndEntrepreneurship", - "internationalBusiness:SupplyChainManagement", - "journalism", - "landscapeArchitecture", - "linguistics", - "marineBiology", - "mathematics", - "mechanicalEngineering", - "mediaAndScreenStudies", - "mediaArts", - "music", - "musicTechnology", - "nursing", - "pharmaceuticalSciences", - "pharmacy(PharmD)", - "philosophy", - "physics", - "politicalScience", - "politicsPhilosophyEconomics", - "psychology", - "publicHealth", - "publicRelations", - "religiousStudies", - "sociology", - "spanish", - "speechLanguagePathologyAndAudiology", - "theatre", -]); - -export const graduationCycleEnum = z.enum(["december", "may"]); - -export const yearEnum = z.enum(["1", "2", "3", "4", "5"]); - -// Schemas: -export const createUserRequestBodySchema = z.object({ - first_name: z.string().min(1), - last_name: z.string().min(1), - email: z.string().email(), - password: z.string().min(8), - major0: majorEnum.optional(), - major1: majorEnum.optional(), - major2: majorEnum.optional(), - college: collegeEnum, - graduation_cycle: graduationCycleEnum.optional(), - graduation_year: z.number().optional(), -}); - -export const updateUserRequestBodySchema = z.object({ - first_name: z.string().min(1).optional(), - last_name: z.string().min(1).optional(), - major0: majorEnum.optional(), - major1: majorEnum.optional(), - major2: majorEnum.optional(), - college: collegeEnum.optional(), - graduation_cycle: graduationCycleEnum.optional(), - graduation_year: z.number().optional(), -}); - -export const createUserTagsRequestBodySchema = z.object({ - tags: z.array(z.string().uuid()), -}); - -const userSchemaIntermediate = z.object({ - role: userRoleEnum, - first_name: z.string().min(1), - last_name: z.string().min(1), - email: z.string().email(), - major0: majorEnum.optional(), - major1: majorEnum.optional(), - major2: majorEnum.optional(), - college: collegeEnum.optional(), - graduation_cycle: graduationCycleEnum.optional(), - graduation_year: z.number().optional(), - is_verified: z.boolean(), -}); - -export const userSchema = userSchemaIntermediate.merge(rootModelSchema); - -// Types: -export type UserRole = z.infer; -export type College = z.infer; -export type Major = z.infer; -export type GraduationCycle = z.infer; -export type Year = z.infer; - -export type CreateUserRequestBody = z.infer; -export type UpdateUserRequestBody = z.infer; -export type CreateUserTagsRequestBody = z.infer< - typeof createUserTagsRequestBodySchema ->; -export type User = z.infer; diff --git a/frontend/dashboard/src/types/verification.ts b/frontend/dashboard/src/types/verification.ts deleted file mode 100644 index 8b4cd0880..000000000 --- a/frontend/dashboard/src/types/verification.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { z } from "zod"; - -// Enums: -const verificationTypeEnum = z.enum(["email_verification", "password_reset"]); - -// Schemas: -const emailRequestBodySchema = z.object({ - email: z.string().email(), -}); - -const verifyEmailRequestBodySchema = z.object({ - email: z.string().email(), - token: z.string().length(6), -}); - -const verifyPasswordResetTokenRequestBodySchema = z.object({ - token: z.string(), - new_password: z.string().min(8), - verify_new_password: z.string().min(8), -}); - -const verificationSchema = z.object({ - user_id: z.string().uuid(), - token: z.string(), - expires_at: z.date(), - type: verificationTypeEnum, -}); - -// Types: -export type VerificationType = z.infer; -export type EmailRequestBody = z.infer; -export type VerifyEmailRequestBody = z.infer< - typeof verifyEmailRequestBodySchema ->; -export type VerifyPasswordResetTokenRequestBody = z.infer< - typeof verifyPasswordResetTokenRequestBodySchema ->; -export type Verification = z.infer; diff --git a/frontend/lib/api/category.ts b/frontend/lib/api/category.ts deleted file mode 100644 index 86bfa592b..000000000 --- a/frontend/lib/api/category.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { z } from "zod"; - -import { API_BASE_URL } from "@/const"; -import { Category, categorySchema } from "@/types/category"; -import { uuid } from "@/types/uuid"; -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const categoriesApi = createApi({ - reducerPath: "categoriesApi", - baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), - tagTypes: ["Categories"], - endpoints: (builder) => ({ - categories: builder.query({ - query: () => "categories", - transformResponse: (rawResponse: unknown) => { - return z.array(categorySchema).parse(rawResponse); - }, - providesTags: [{ type: "Categories", id: "LIST" }], - }), - category: builder.query({ - query: (categoryID: uuid) => `categories/${categoryID}`, - transformResponse: (rawResponse: unknown) => { - return categorySchema.parse(rawResponse); - }, - providesTags: (result, _, categoryID) => - result ? [{ type: "Categories", id: categoryID }] : [], - }), - }), -}); - -export const { useCategoriesQuery, useCategoryQuery } = categoriesApi; diff --git a/frontend/lib/api/club.ts b/frontend/lib/api/club.ts deleted file mode 100644 index f6368028d..000000000 --- a/frontend/lib/api/club.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { API_BASE_URL } from "@/const"; -import { Club } from "@/types/club"; -import { Contact } from "@/types/contact"; -import { Tag } from "@/types/tag"; -import { uuid } from "@/types/uuid"; -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const clubsApi = createApi({ - reducerPath: "clubsApi", - baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), - tagTypes: ["Clubs"], - endpoints: (builder) => ({ - clubs: builder.query({ - query: () => "clubs", - // transformResponse: (rawResponse: unknown) => { - // return z.array(clubSchema).parse(rawResponse); - // }, - providesTags: [{ type: "Clubs", id: "LIST" }], - }), - club: builder.query({ - query: (clubID: uuid) => `clubs/${clubID}`, - // transformResponse: (rawResponse: unknown) => { - // return clubSchema.parse(rawResponse); - // }, - providesTags: (result, _, clubID) => - result ? [{ type: "Clubs", id: clubID }] : [], - }), - clubContacts: builder.query({ - query: (clubID: uuid) => `clubs/${clubID}/contacts`, - // transformResponse: (rawResponse: unknown) => { - // return z.array(contactSchema).parse(rawResponse); - // }, - providesTags: (result, _, clubID) => - result ? [{ type: "Clubs", id: clubID }] : [], - }), - clubTags: builder.query({ - query: (clubID: uuid) => `clubs/${clubID}/tags`, - // transformResponse: (rawResponse: unknown) => { - // return z.array(tagSchema).parse(rawResponse); - // }, - providesTags: (result, _, clubID) => - result ? [{ type: "Clubs", id: clubID }] : [], - }), - }), -}); - -export const { - useClubsQuery, - useClubQuery, - useClubContactsQuery, - useClubTagsQuery, -} = clubsApi; diff --git a/frontend/lib/api/contact.ts b/frontend/lib/api/contact.ts deleted file mode 100644 index 9db031cd7..000000000 --- a/frontend/lib/api/contact.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { z } from "zod"; - -import { API_BASE_URL } from "@/const"; -import { Contact, contactSchema } from "@/types/contact"; -import { uuid } from "@/types/uuid"; -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const contactsApi = createApi({ - reducerPath: "contactApi", - baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), - endpoints: (builder) => ({ - contacts: builder.query({ - query: () => "contacts", - transformResponse: (rawResponse: unknown) => { - return z.array(contactSchema).parse(rawResponse); - }, - }), - contact: builder.query({ - query: (contactID: uuid) => `contacts/${contactID}`, - transformResponse: (rawResponse: unknown) => { - return contactSchema.parse(rawResponse); - }, - }), - }), -}); - -export const { useContactsQuery } = contactsApi; diff --git a/frontend/lib/api/event.ts b/frontend/lib/api/event.ts deleted file mode 100644 index 7105cce15..000000000 --- a/frontend/lib/api/event.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { API_BASE_URL } from "@/const"; -import { Club } from "@/types/club"; -import { Event } from "@/types/event"; -import { uuid } from "@/types/uuid"; -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const eventsApi = createApi({ - reducerPath: "eventsApi", - baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), - tagTypes: ["Events"], - endpoints: (builder) => ({ - events: builder.query({ - query: () => "events", - // transformResponse: (rawResponse: unknown) => { - // return z.array(eventSchema).parse(rawResponse); - // }, - providesTags: [{ type: "Events", id: "LIST" }], - }), - event: builder.query({ - query: (eventID: uuid) => `events/${eventID}`, - // transformResponse: (rawResponse: unknown) => { - // return eventSchema.parse(rawResponse); - // }, - providesTags: (result, _, eventID) => - result ? [{ type: "Events", id: eventID }] : [], - }), - eventTags: builder.query({ - query: (eventID: uuid) => `events/${eventID}/tags`, - // transformResponse: (rawResponse: unknown) => { - // return z.array(clubSchema).parse(rawResponse); - // }, - providesTags: (result, _, eventID) => - result ? [{ type: "Events", id: eventID }] : [], - }), - eventHosts: builder.query({ - query: (eventID: uuid) => `events/${eventID}/hosts`, - // transformResponse: (rawResponse: unknown) => { - // return z.array(clubSchema).parse(rawResponse); - // }, - providesTags: (result, _, eventID) => - result ? [{ type: "Events", id: eventID }] : [], - }), - }), -}); - -export const { - useEventsQuery, - useEventQuery, - useEventTagsQuery, - useEventHostsQuery, -} = eventsApi; diff --git a/frontend/lib/api/tag.ts b/frontend/lib/api/tag.ts deleted file mode 100644 index e6da1c3b5..000000000 --- a/frontend/lib/api/tag.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { z } from "zod"; - -import { API_BASE_URL } from "@/const"; -import { Tag, tagSchema } from "@/types/tag"; -import { uuid } from "@/types/uuid"; -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const tagsApi = createApi({ - reducerPath: "tagsApi", - baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), - tagTypes: ["Tags"], - endpoints: (builder) => ({ - tags: builder.query({ - query: () => "tags", - transformResponse: (rawResponse: unknown) => { - return z.array(tagSchema).parse(rawResponse); - }, - providesTags: [{ type: "Tags", id: "LIST" }], - }), - tag: builder.query({ - query: (tagID: uuid) => `tags/${tagID}`, - transformResponse: (rawResponse: unknown) => { - return tagSchema.parse(rawResponse); - }, - providesTags: (result, _, tagID) => - result ? [{ type: "Tags", id: tagID }] : [], - }), - }), -}); - -export const { useTagsQuery, useTagQuery } = tagsApi; diff --git a/frontend/lib/api/user.ts b/frontend/lib/api/user.ts deleted file mode 100644 index bf7ead91e..000000000 --- a/frontend/lib/api/user.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { z } from "zod"; - -import { API_BASE_URL } from "@/const"; -import { Club, clubSchema } from "@/types/club"; -import { User, userSchema } from "@/types/user"; -import { uuid } from "@/types/uuid"; -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; - -export const usersApi = createApi({ - reducerPath: "usersApi", - baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), - tagTypes: ["Users"], - endpoints: (builder) => ({ - users: builder.query({ - query: () => "users", - transformResponse: (rawResponse: unknown) => { - return z.array(userSchema).parse(rawResponse); - }, - providesTags: [{ type: "Users", id: "LIST" }], - }), - user: builder.query({ - query: (userID: uuid) => `users/${userID}`, - transformResponse: (rawResponse: unknown) => { - return userSchema.parse(rawResponse); - }, - providesTags: (result, _, userID) => - result ? [{ type: "Users", id: userID }] : [], - }), - userFollowing: builder.query({ - query: (userID: uuid) => `users/${userID}/follower`, - transformResponse: (rawResponse: unknown) => { - return z.array(clubSchema).parse(rawResponse); - }, - providesTags: (result, _, userID) => - result ? [{ type: "Users", id: userID }] : [], - }), - createUserClubFollowing: builder.mutation< - void, - { userID: uuid; clubID: uuid } - >({ - query: ({ userID, clubID }) => ({ - url: `users/${userID}/follower/${clubID}`, - method: "POST", - }), - invalidatesTags: ["Users"], - }), - deleteUserClubFollowing: builder.mutation< - void, - { userID: uuid; clubID: uuid } - >({ - query: ({ userID, clubID }) => ({ - url: `users/${userID}/follower/${clubID}`, - method: "DELETE", - }), - invalidatesTags: ["Users"], - }), - }), -}); - -export const { - useUsersQuery, - useUserQuery, - useUserFollowingQuery, - useCreateUserClubFollowingMutation, - useDeleteUserClubFollowingMutation, -} = usersApi;