diff --git a/.github/workflows/generateCheck.sh b/.github/workflows/generateCheck.sh index 0f98e9cb..8d1ba0b0 100755 --- a/.github/workflows/generateCheck.sh +++ b/.github/workflows/generateCheck.sh @@ -1,14 +1,14 @@ -if [ $status == 0 ]; then - echo "## Formatting Check passed 🥳" >>$GITHUB_STEP_SUMMARY - echo "All files are formatted correctly" >>$GITHUB_STEP_SUMMARY - exit 0 +if [ $status == 'success' ]; then + echo "## Formatting Check passed 🥳" >>$GITHUB_STEP_SUMMARY + echo "All files are formatted correctly" >>$GITHUB_STEP_SUMMARY + exit 0 else - echo "## Formatting Check Failed 😅" >>$GITHUB_STEP_SUMMARY - echo "Please run prettier using \`npx prettier . --write\` in order to format your code" >>$GITHUB_STEP_SUMMARY - echo "### Files with bad formatting:" >>$GITHUB_STEP_SUMMARY - for file in $files; do - echo "- $file" >>$GITHUB_STEP_SUMMARY - echo "::error file=$file::$file not formatted correctly" - done - exit 1 + echo "## Formatting Check Failed 😅" >>$GITHUB_STEP_SUMMARY + echo "Please run prettier using \`npx prettier . --write\` in order to format your code" >>$GITHUB_STEP_SUMMARY + echo "### Files with bad formatting:" >>$GITHUB_STEP_SUMMARY + for file in $files; do + echo "- $file" >>$GITHUB_STEP_SUMMARY + echo "::error file=$file::$file not formatted correctly" + done + exit 1 fi diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml index e642ea75..7ebc8f6b 100644 --- a/.github/workflows/prettierCheck.yml +++ b/.github/workflows/prettierCheck.yml @@ -11,14 +11,12 @@ jobs: node-version: 18 cache: 'npm' - name: Run npm install - run: | - mv package.json package.json.bak - npm i --no-save prettier prettier-plugin-tailwindcss - mv package.json.bak package.json + run: npm ci - name: Run prettier - run: | - files=`npx prettier . -l` || st=$? && st=$? - echo status=`echo $st`>>"$GITHUB_ENV" - echo files=`echo $files`>> "$GITHUB_ENV" + id: prettier + continue-on-error: true + run: echo files=`npx prettier . -l` >> "$GITHUB_ENV" - name: generate errors/summary run: .github/workflows/generateCheck.sh + env: + status: ${{ steps.prettier.outcome }} diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 08a34d3b..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - printWidth: 80, - semi: true, - singleQuote: true, - tabWidth: 2, - trailingComma: 'all', - useTabs: false, - plugins: ['prettier-plugin-tailwindcss'], -}; diff --git a/.prettierrc.mjs b/.prettierrc.mjs new file mode 100644 index 00000000..b7128a21 --- /dev/null +++ b/.prettierrc.mjs @@ -0,0 +1,16 @@ +/** + * @see https://prettier.io/docs/en/configuration.html + * @type {import("prettier").Config} + */ +const config = { + printWidth: 80, + semi: true, + singleQuote: true, + tabWidth: 2, + trailingComma: 'all', + useTabs: false, + bracketSameLine: false, + plugins: ['prettier-plugin-tailwindcss'], +}; + +export default config; diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx index 44259a53..2a0e1b80 100644 --- a/src/app/about/page.tsx +++ b/src/app/about/page.tsx @@ -1,4 +1,4 @@ -import Header from '@src/components/BaseHeader'; +import Header from '@src/components/header/BaseHeader'; import type { Metadata } from 'next'; export const metadata: Metadata = { diff --git a/src/app/admin/carousel/add/page.tsx b/src/app/admin/carousel/add/page.tsx index f609d74c..3da1d6ea 100644 --- a/src/app/admin/carousel/add/page.tsx +++ b/src/app/admin/carousel/add/page.tsx @@ -1,12 +1,12 @@ -import AddOrg from '@src/components/admin/AddOrg'; +import AddClub from '@src/components/admin/AddClub'; export default function Page() { return (

- Add Orgs to Carousel + Add Clubs to Carousel

- +
); } diff --git a/src/app/admin/orgs/[id]/page.tsx b/src/app/admin/clubs/[id]/page.tsx similarity index 72% rename from src/app/admin/orgs/[id]/page.tsx rename to src/app/admin/clubs/[id]/page.tsx index f6bba3fc..06626949 100644 --- a/src/app/admin/orgs/[id]/page.tsx +++ b/src/app/admin/clubs/[id]/page.tsx @@ -1,5 +1,5 @@ -import ApprovedOrg from '@src/components/admin/ApprovedOrg'; -import OtherOrgStatus from '@src/components/admin/OtherOrgStatus'; +import ApprovedClub from '@src/components/admin/ApprovedClub'; +import OtherClubStatus from '@src/components/admin/OtherClubStatus'; import { db } from '@src/server/db'; import { eq } from 'drizzle-orm'; import { notFound } from 'next/navigation'; @@ -16,9 +16,9 @@ export default async function Page({ params: { id } }: Props) {

{org.name}

{org.approved === 'approved' ? ( - + ) : ( - + )}
); diff --git a/src/app/admin/orgs/page.tsx b/src/app/admin/clubs/page.tsx similarity index 51% rename from src/app/admin/orgs/page.tsx rename to src/app/admin/clubs/page.tsx index d2fc79b8..c6558454 100644 --- a/src/app/admin/orgs/page.tsx +++ b/src/app/admin/clubs/page.tsx @@ -1,11 +1,11 @@ -import OrgTable from '@src/components/admin/OrgTable'; +import ClubTable from '@src/components/admin/ClubTable'; import { api } from '@src/trpc/server'; export default async function Page() { - const clubs = await api.admin.allOrgs(); + const clubs = await api.admin.allClubs(); return (
- +
); } diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index ba693fa0..372a0741 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -8,10 +8,10 @@ export default function Page() {
- Manage Orgs + Manage Clubs { +const ClubPage = async ({ params }: { params: { id: string } }) => { const club = await api.club.getDirectoryInfo({ id: params.id }); if (!club) return ; @@ -16,15 +16,15 @@ const OrganizationPage = async ({ params }: { params: { id: string } }) => {
- - - + + +
); }; -export default OrganizationPage; +export default ClubPage; export async function generateMetadata({ params, diff --git a/src/components/CreateContactSelector.tsx b/src/app/directory/create/CreateContactSelector.tsx similarity index 99% rename from src/components/CreateContactSelector.tsx rename to src/app/directory/create/CreateContactSelector.tsx index cfd09ed7..2d0735c5 100644 --- a/src/components/CreateContactSelector.tsx +++ b/src/app/directory/create/CreateContactSelector.tsx @@ -16,7 +16,7 @@ import { Website, Youtube, type logoProps, -} from './ContactIcons'; +} from '@src/icons/ContactIcons'; import { type Control, type UseFormRegister, diff --git a/src/components/OfficerSelector.tsx b/src/app/directory/create/OfficerSelector.tsx similarity index 97% rename from src/components/OfficerSelector.tsx rename to src/app/directory/create/OfficerSelector.tsx index 230828fa..05c07ef5 100644 --- a/src/components/OfficerSelector.tsx +++ b/src/app/directory/create/OfficerSelector.tsx @@ -7,7 +7,7 @@ import { type FieldErrors, } from 'react-hook-form'; import { type z } from 'zod'; -import { UserSearchBar } from './SearchBar'; +import { UserSearchBar } from '@src/components/searchBar/UserSearchBar'; type OfficerSelectorProps = { control: Control>; diff --git a/src/app/directory/create/createForm.tsx b/src/app/directory/create/createForm.tsx index b9342196..e9c89543 100644 --- a/src/app/directory/create/createForm.tsx +++ b/src/app/directory/create/createForm.tsx @@ -1,8 +1,8 @@ 'use client'; /* eslint-disable @typescript-eslint/no-misused-promises */ import { zodResolver } from '@hookform/resolvers/zod'; -import ContactSelector from '@src/components/CreateContactSelector'; -import OfficerSelector from '@src/components/OfficerSelector'; +import ContactSelector from '@src/app/directory/create/CreateContactSelector'; +import OfficerSelector from '@src/app/directory/create/OfficerSelector'; import { api } from '@src/trpc/react'; import { createClubSchema } from '@src/utils/formSchemas'; import { useRouter } from 'next/navigation'; diff --git a/src/app/directory/create/page.tsx b/src/app/directory/create/page.tsx index da5b2791..819bc121 100644 --- a/src/app/directory/create/page.tsx +++ b/src/app/directory/create/page.tsx @@ -1,4 +1,4 @@ -import Header from '@src/components/BaseHeader'; +import Header from '@src/components/header/BaseHeader'; import CreateClubForm from './createForm'; import { getServerAuthSession } from '@src/server/auth'; import { redirect } from 'next/navigation'; diff --git a/src/components/RegisterButton.tsx b/src/app/event/[id]/RegisterButton.tsx similarity index 100% rename from src/components/RegisterButton.tsx rename to src/app/event/[id]/RegisterButton.tsx diff --git a/src/app/event/[id]/page.tsx b/src/app/event/[id]/page.tsx index 405c6452..9943eb68 100644 --- a/src/app/event/[id]/page.tsx +++ b/src/app/event/[id]/page.tsx @@ -1,4 +1,4 @@ -import { EventHeader } from '@src/components/BaseHeader'; +import { EventHeader } from '@src/components/header/BaseHeader'; import { db } from '@src/server/db'; import { and, eq } from 'drizzle-orm'; import { type Metadata } from 'next'; @@ -8,7 +8,7 @@ import Image from 'next/image'; import CountdownTimer from './CountdownTimer'; import Link from 'next/link'; import { getServerAuthSession } from '@src/server/auth'; -import RegisterButton from '@src/components/RegisterButton'; +import RegisterButton from '@src/app/event/[id]/RegisterButton'; type Params = { params: { id: string } }; diff --git a/src/app/events/page.tsx b/src/app/events/page.tsx index 8036676e..79bc45dd 100644 --- a/src/app/events/page.tsx +++ b/src/app/events/page.tsx @@ -1,4 +1,4 @@ -import { EventHeader } from '@src/components/BaseHeader'; +import { EventHeader } from '@src/components/header/BaseHeader'; import { api } from '@src/trpc/server'; import EventView from './eventView'; import { type Metadata } from 'next'; diff --git a/src/app/feedback/page.tsx b/src/app/feedback/page.tsx index 38feaa5d..069ed2f9 100644 --- a/src/app/feedback/page.tsx +++ b/src/app/feedback/page.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Header from '@src/components/BaseHeader'; +import Header from '@src/components/header/BaseHeader'; import { type Metadata } from 'next'; import Form from '@src/app/feedback/Form'; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 504ac436..4a14d4fb 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -4,7 +4,7 @@ import { Inter } from 'next/font/google'; import { headers } from 'next/headers'; import { TRPCReactProvider } from '@src/trpc/react'; -import Sidebar from '@src/components/Sidebar'; +import Sidebar from '@src/components/nav/Sidebar'; import { type Metadata } from 'next'; import { Analytics } from '@vercel/analytics/react'; diff --git a/src/app/manage/[clubId]/(dashboard)/layout.tsx b/src/app/manage/[clubId]/(dashboard)/layout.tsx index 6879ec2b..478e2375 100644 --- a/src/app/manage/[clubId]/(dashboard)/layout.tsx +++ b/src/app/manage/[clubId]/(dashboard)/layout.tsx @@ -1,5 +1,5 @@ -import Header from '@src/components/BaseHeader'; -import BackButton from '@src/components/BlueBackButton'; +import Header from '@src/components/header/BaseHeader'; +import { BlueBackButton } from '@src/components/backButton'; import { getServerAuthSession } from '@src/server/auth'; import { api } from '@src/trpc/server'; import { signInRoute } from '@src/utils/redirect'; @@ -30,7 +30,7 @@ const Layout = async ({
- +

{club.name}

diff --git a/src/app/manage/[clubId]/create/CreateEventForm.tsx b/src/app/manage/[clubId]/create/CreateEventForm.tsx index 70168b22..bd09638c 100644 --- a/src/app/manage/[clubId]/create/CreateEventForm.tsx +++ b/src/app/manage/[clubId]/create/CreateEventForm.tsx @@ -1,130 +1,199 @@ -'use client' +'use client'; -import { useEffect, useState } from "react"; -import { type SelectClub } from "@src/server/db/models"; -import { createEventSchema } from "@src/utils/formSchemas"; -import { useForm } from "react-hook-form"; -import { api } from "@src/trpc/react"; -import { type z } from "zod"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useRouter } from "next/navigation"; -import { UploadIcon } from "@src/icons/Icons"; -import EventCardPreview from "./EventCardPreview"; -import TimeSelect from "./TimeSelect"; -import { type RouterOutputs } from "@src/trpc/shared"; +import { useEffect, useState } from 'react'; +import { type SelectClub } from '@src/server/db/models'; +import { createEventSchema } from '@src/utils/formSchemas'; +import { useForm } from 'react-hook-form'; +import { api } from '@src/trpc/react'; +import { type z } from 'zod'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { useRouter } from 'next/navigation'; +import { UploadIcon } from '@src/icons/Icons'; +import EventCardPreview from './EventCardPreview'; +import TimeSelect from './TimeSelect'; +import { type RouterOutputs } from '@src/trpc/shared'; -const CreateEventForm = ({ clubId, officerClubs }: { clubId: string, officerClubs: SelectClub[]}) => { - const { - register, - handleSubmit, - watch, - setValue, - getValues, - } = useForm>({ - resolver: zodResolver(createEventSchema), - defaultValues: { - clubId: clubId, - }, - mode: "onSubmit", - }); - const router = useRouter(); - const [watchDescription, watchStartTime] = watch(['description', 'startTime']); - const [eventPreview, setEventPreview] = useState({ - name: "", - clubId, - description: "", - location: "", - liked: false, - id: "", - startTime: new Date(Date.now()), - endTime: new Date(Date.now()), - club: officerClubs.filter((v) => v.id == clubId)[0]!, - }); - useEffect(() => { - const subscription = watch((data, info) => { - const { name, clubId, description, location, startTime, endTime } = data; - const club = officerClubs.find((val) => val.id == data.clubId); - if (club) { - setEventPreview({ - name: name || "", - clubId: clubId || "", - description: description || "", - location: location || "", - liked: false, - id: "", - startTime: startTime?.toString() === "" || startTime == undefined ? new Date(Date.now()) : new Date(startTime), - endTime: endTime?.toString() === "" || endTime?.toString() == "Invalid Date" || !endTime ? new Date(Date.now()) : new Date(endTime), - club, - }); - } - if (info.name == "clubId") { - router.replace(`/manage/${data.clubId}/create`); - } - }); - return () => subscription.unsubscribe(); - }, [router, watch, officerClubs]); +const CreateEventForm = ({ + clubId, + officerClubs, +}: { + clubId: string; + officerClubs: SelectClub[]; +}) => { + const { register, handleSubmit, watch, setValue, getValues, control } = + useForm>({ + resolver: zodResolver(createEventSchema), + defaultValues: { + clubId: clubId, + }, + mode: 'onSubmit', + }); + const router = useRouter(); + const [watchDescription, watchStartTime] = watch([ + 'description', + 'startTime', + ]); + const [loading, setLoading] = useState(false); + const [eventPreview, setEventPreview] = useState< + RouterOutputs['event']['findByFilters']['events'][number] + >({ + name: '', + clubId, + description: '', + location: '', + liked: false, + id: '', + startTime: new Date(Date.now()), + endTime: new Date(Date.now()), + club: officerClubs.filter((v) => v.id == clubId)[0]!, + }); + useEffect(() => { + const subscription = watch((data, info) => { + const { name, clubId, description, location, startTime, endTime } = data; + const club = officerClubs.find((val) => val.id == data.clubId); + if (club) { + setEventPreview({ + name: name || '', + clubId: clubId || '', + description: description || '', + location: location || '', + liked: false, + id: '', + startTime: + startTime?.toString() === '' || startTime === undefined + ? new Date(Date.now()) + : new Date(startTime), + endTime: + endTime?.toString() === '' || + endTime?.toString() === 'Invalid Date' || + !endTime + ? new Date(Date.now()) + : new Date(endTime), + club, + }); + } + if (info.name == 'clubId') { + router.replace(`/manage/${data.clubId}/create`); + } + }); + return () => subscription.unsubscribe(); + }, [router, watch, officerClubs]); - const createMutation = api.event.create.useMutation({ - onSuccess: () => { location.reload(); } - }) + const createMutation = api.event.create.useMutation({ + onSuccess: (data) => { + if (data) { + router.push(`/event/${data}`); + } + }, + onError: () => { + setLoading(false); + }, + }); - const onSubmit = handleSubmit((data: z.infer) => { - if (!createMutation.isPending) { - createMutation.mutate(data); - } - }); + const onSubmit = handleSubmit((data: z.infer) => { + if (!createMutation.isPending && !loading) { + setLoading(true); + createMutation.mutate(data); + } + }); - return (
void onSubmit(e)} className="w-full flex flex-row flex-wrap justify-start gap-10 overflow-x-clip text-[#4D5E80] pb-4"> -
-
- Create Club Event for -
- -
-
-
-

Event Picture

-

Drag or choose file to upload

-
- -

JPEG, PNG, or SVG

-
-
-
-

Event Details

-
- - -
-
- - -
-
-
- -

{watchDescription && watchDescription.length} of 1000 Characters used

-
-