From 5354f899163fd00cda560828cf0368102b8c852b Mon Sep 17 00:00:00 2001 From: Christian Walker <76548772+christianhelp@users.noreply.github.com> Date: Sun, 11 Aug 2024 22:52:07 -0400 Subject: [PATCH 1/5] Fix registration blocking bug (#87) --- .../components/registration/RegisterForm.tsx | 19 ++++++++++--------- .../web/src/validators/shared/RegisterForm.ts | 1 + packages/config/hackkit.config.ts | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/registration/RegisterForm.tsx b/apps/web/src/components/registration/RegisterForm.tsx index 2c17e657..072dc3b2 100644 --- a/apps/web/src/components/registration/RegisterForm.tsx +++ b/apps/web/src/components/registration/RegisterForm.tsx @@ -94,6 +94,10 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { }, }); + const { isSubmitSuccessful, isSubmitted, errors } = form.formState; + + const hasErrors = !isSubmitSuccessful && isSubmitted; + const [uploadedFile, setUploadedFile] = useState(null); const [skills, setSkills] = useState([]); const [isLoading, setIsLoading] = useState(false); @@ -110,7 +114,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { async function onSubmit(data: z.infer) { setIsLoading(true); - console.log("Submision Clicked"); if (!userId || !isLoaded) { setIsLoading(false); return alert( @@ -179,10 +182,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { ); } if (acceptedFiles.length > 0) { - console.log( - `Got accepted file! The length of the array is ${acceptedFiles.length}.`, - ); - console.log(acceptedFiles[0]); setUploadedFile(acceptedFiles[0]); } }, @@ -552,10 +551,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { onSelect={( value, ) => { - console.log( - "value changed to: ", - value, - ); form.setValue( "university", value, @@ -1212,6 +1207,12 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { /> + {hasErrors && ( +

+ Something doesn't look right. Please check your + inputs. +

+ )} diff --git a/apps/web/src/validators/shared/RegisterForm.ts b/apps/web/src/validators/shared/RegisterForm.ts index d6afb01a..ba46b28f 100644 --- a/apps/web/src/validators/shared/RegisterForm.ts +++ b/apps/web/src/validators/shared/RegisterForm.ts @@ -80,6 +80,7 @@ export const RegisterFormValidator = z.object({ z.literal("Sophomore", defaultPrettyError), z.literal("Junior", defaultPrettyError), z.literal("Senior", defaultPrettyError), + z.literal("Recent Grad", defaultPrettyError), z.literal("Other", defaultPrettyError), ]), hackathonsAttended: z diff --git a/packages/config/hackkit.config.ts b/packages/config/hackkit.config.ts index 3480540d..2301f708 100644 --- a/packages/config/hackkit.config.ts +++ b/packages/config/hackkit.config.ts @@ -592,6 +592,8 @@ export const schools = [ ] as const; export const majors = [ + "Computer Science", + "Cyber Security", "Accounting", "Accounting Technician", "Actuarial Science", @@ -625,13 +627,11 @@ export const majors = [ "Computer & Information Sciences, General", "Computer Engineering", "Computer Networking/Telecommunications", - "Computer Science", "Computer Software & Media Applications", "Computer System Administration", "Construction Engineering/Management", "Creative Writing", "Criminology", - "Cyber Security", "Data Management Technology", "Dental Assisting", "Design & Visual Communications, General", From 24c93eba3115f71194a71b46bab01800c37d0c0a Mon Sep 17 00:00:00 2001 From: joshuasilva414 Date: Sun, 8 Sep 2024 22:39:06 -0500 Subject: [PATCH 2/5] add mobile navbar profile button --- apps/web/src/app/dash/layout.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/web/src/app/dash/layout.tsx b/apps/web/src/app/dash/layout.tsx index 0e69da7e..428d7a29 100644 --- a/apps/web/src/app/dash/layout.tsx +++ b/apps/web/src/app/dash/layout.tsx @@ -45,12 +45,15 @@ export default async function DashLayout({ children }: DashLayoutProps) {
- {c.hackathonName + + {c.hackathonName + +

Dashboard

@@ -81,7 +84,9 @@ export default async function DashLayout({ children }: DashLayoutProps) {
-
+
+ +
{Object.entries(c.dashPaths.dash).map(([name, path]) => ( From 129c195c5569f4388a5293d49950dd0d74e55296 Mon Sep 17 00:00:00 2001 From: Christian Walker <76548772+christianhelp@users.noreply.github.com> Date: Wed, 11 Sep 2024 00:02:57 -0500 Subject: [PATCH 3/5] 48 times of event do not display correct times (#99) --- apps/web/src/app/admin/events/new/page.tsx | 2 +- apps/web/src/app/admin/events/page.tsx | 13 ++- .../src/app/api/admin/events/create/route.ts | 6 +- apps/web/src/app/dash/schedule/page.tsx | 24 ++--- apps/web/src/app/schedule/[id]/page.tsx | 4 +- .../admin/EventDetails.tsx} | 22 ++-- .../events => events/admin}/NewEventForm.tsx | 102 +++++++++++------- .../events => events/shared}/EventColumns.tsx | 43 +------- .../shared}/EventDataTable.tsx | 5 +- .../components/registration/RegisterForm.tsx | 4 +- apps/web/src/components/schedule/Day.tsx | 82 +++++--------- .../web/src/components/schedule/EventItem.tsx | 59 ++++++++++ .../components/schedule/UserScheduleView.tsx | 17 +++ apps/web/src/components/shared/Loading.tsx | 10 +- .../components/shared/ThreeCirclesLoader.tsx | 16 +++ apps/web/src/lib/constants/index.ts | 2 + apps/web/src/lib/types/events.ts | 20 ++++ apps/web/src/lib/types/index.ts | 1 + apps/web/src/lib/utils/client/shared.ts | 3 + apps/web/src/validators/event.ts | 19 ++++ apps/web/src/validators/shared/newEvent.ts | 4 - packages/config/hackkit.config.ts | 26 +++-- packages/db/functions/events.ts | 26 +++++ packages/db/functions/index.ts | 1 + packages/db/schema.ts | 4 + 25 files changed, 322 insertions(+), 193 deletions(-) rename apps/web/src/components/{schedule/EventFull.tsx => events/admin/EventDetails.tsx} (72%) rename apps/web/src/components/{admin/events => events/admin}/NewEventForm.tsx (70%) rename apps/web/src/components/{admin/events => events/shared}/EventColumns.tsx (61%) rename apps/web/src/components/{admin/events => events/shared}/EventDataTable.tsx (93%) create mode 100644 apps/web/src/components/schedule/EventItem.tsx create mode 100644 apps/web/src/components/schedule/UserScheduleView.tsx create mode 100644 apps/web/src/components/shared/ThreeCirclesLoader.tsx create mode 100644 apps/web/src/lib/constants/index.ts create mode 100644 apps/web/src/lib/types/events.ts create mode 100644 apps/web/src/lib/types/index.ts create mode 100644 apps/web/src/lib/utils/client/shared.ts create mode 100644 apps/web/src/validators/event.ts delete mode 100644 apps/web/src/validators/shared/newEvent.ts create mode 100644 packages/db/functions/events.ts create mode 100644 packages/db/functions/index.ts diff --git a/apps/web/src/app/admin/events/new/page.tsx b/apps/web/src/app/admin/events/new/page.tsx index 6a11aa99..0050480d 100644 --- a/apps/web/src/app/admin/events/new/page.tsx +++ b/apps/web/src/app/admin/events/new/page.tsx @@ -1,4 +1,4 @@ -import NewEventForm from "@/components/admin/events/NewEventForm"; +import NewEventForm from "@/components/events/admin/NewEventForm"; export default function Page() { const defaultDate = new Date(); diff --git a/apps/web/src/app/admin/events/page.tsx b/apps/web/src/app/admin/events/page.tsx index 2a9d0ae1..980d2fcf 100644 --- a/apps/web/src/app/admin/events/page.tsx +++ b/apps/web/src/app/admin/events/page.tsx @@ -1,12 +1,11 @@ -import { db } from "db"; -import { DataTable } from "@/components/admin/events/EventDataTable"; -import { columns } from "@/components/admin/events/EventColumns"; +import { EventDataTable } from "@/components/events/shared/EventDataTable"; +import { columns } from "@/components/events/shared/EventColumns"; import { Button } from "@/components/shadcn/ui/button"; import { PlusCircle } from "lucide-react"; import Link from "next/link"; - +import { getAllEvents } from "db/functions"; export default async function Page() { - const events = await db.query.events.findMany(); + const events = await getAllEvents(); return (
@@ -17,7 +16,7 @@ export default async function Page() { Events

- {events.length} Event{events.length != 1 ? "s" : ""} + {events.length} Event{events.length != 1 && "s"}

@@ -30,7 +29,7 @@ export default async function Page() { - + ); } diff --git a/apps/web/src/app/api/admin/events/create/route.ts b/apps/web/src/app/api/admin/events/create/route.ts index 9ca5ec1e..67152cda 100644 --- a/apps/web/src/app/api/admin/events/create/route.ts +++ b/apps/web/src/app/api/admin/events/create/route.ts @@ -2,13 +2,14 @@ import { auth } from "@clerk/nextjs"; import { eq } from "db/drizzle"; import { db } from "db"; import { users, events } from "db/schema"; -import { newEventValidator } from "@/validators/shared/newEvent"; +import { newEventFormSchema } from "@/validators/event"; import { BasicRedirValidator } from "@/validators/shared/basicRedir"; import { NextResponse } from "next/server"; import { z } from "zod"; import superjson from "superjson"; import c from "config"; +// Make this a server action export async function POST(req: Request) { const { userId } = auth(); @@ -25,9 +26,8 @@ export async function POST(req: Request) { return new Response("Unauthorized", { status: 401 }); } - // console.log(await req.json()); const body = superjson.parse(await req.text()); - const parsedBody = newEventValidator.safeParse(body); + const parsedBody = newEventFormSchema.safeParse(body); if (!parsedBody.success) { return new Response("Malformed request body.", { status: 400 }); diff --git a/apps/web/src/app/dash/schedule/page.tsx b/apps/web/src/app/dash/schedule/page.tsx index 3650b296..1d9b20fc 100644 --- a/apps/web/src/app/dash/schedule/page.tsx +++ b/apps/web/src/app/dash/schedule/page.tsx @@ -1,21 +1,11 @@ -import c from "config"; -import Day from "@/components/schedule/Day"; -import { db } from "db"; -import { format, compareAsc } from "date-fns"; -import { type ReactNode } from "react"; -import { formatInTimeZone } from "date-fns-tz"; -import { redirect } from "next/navigation"; - -export default async function Page() { - const events = await db.query.events.findMany(); - +import { Suspense } from "react"; +import UserScheduleView from "@/components/schedule/UserScheduleView"; +import Loading from "@/components/shared/Loading"; +export default function Page() { return ( -
-

- Bug with Scheduling was found. Fix Coming soon! -

-

- Christian

-
+ }> + + ); } diff --git a/apps/web/src/app/schedule/[id]/page.tsx b/apps/web/src/app/schedule/[id]/page.tsx index dc45b9c6..c5c1ad74 100644 --- a/apps/web/src/app/schedule/[id]/page.tsx +++ b/apps/web/src/app/schedule/[id]/page.tsx @@ -2,7 +2,7 @@ import { db } from "db"; import { eq } from "db/drizzle"; import { events } from "db/schema"; import FullScreenMessage from "@/components/shared/FullScreenMessage"; -import EventFull from "@/components/schedule/EventFull"; +import EventDetails from "@/components/events/admin/EventDetails"; import Navbar from "@/components/shared/Navbar"; export default async function Page({ params }: { params: { id: string } }) { @@ -33,7 +33,7 @@ export default async function Page({ params }: { params: { id: string } }) { return ( <> - + ); } diff --git a/apps/web/src/components/schedule/EventFull.tsx b/apps/web/src/components/events/admin/EventDetails.tsx similarity index 72% rename from apps/web/src/components/schedule/EventFull.tsx rename to apps/web/src/components/events/admin/EventDetails.tsx index 922fcded..298d7a17 100644 --- a/apps/web/src/components/schedule/EventFull.tsx +++ b/apps/web/src/components/events/admin/EventDetails.tsx @@ -1,15 +1,17 @@ -import { events } from "db/schema"; -import { InferModel } from "db/drizzle"; import c from "config"; import { Badge } from "@/components/shadcn/ui/badge"; import Balancer from "react-wrap-balancer"; import { formatInTimeZone } from "date-fns-tz"; +import { getClientTimeZone } from "@/lib/utils/client/shared"; +import { EventType } from "@/lib/types/events"; +import { headers } from "next/headers"; +import { VERCEL_IP_TIMEZONE_HEADER_KEY } from "@/lib/constants"; + +export default function EventDetails({ event }: { event: EventType }) { + const userTimeZoneHeaderKey = headers().get(VERCEL_IP_TIMEZONE_HEADER_KEY); + + const userTimeZone = getClientTimeZone(userTimeZoneHeaderKey); -export default function EventFull({ - event, -}: { - event: InferModel; -}) { return (

{`${formatInTimeZone( event.startTime, - c.hackathonTimezone, + userTimeZone, "EEEE MMMM do", )}, ${formatInTimeZone( event.startTime, - c.hackathonTimezone, + userTimeZone, "h:mm a", - )} - ${formatInTimeZone(event.endTime, c.hackathonTimezone, "h:mm a")}`}

+ )} - ${formatInTimeZone(event.endTime, userTimeZone, "h:mm a")}`}

diff --git a/apps/web/src/components/admin/events/NewEventForm.tsx b/apps/web/src/components/events/admin/NewEventForm.tsx similarity index 70% rename from apps/web/src/components/admin/events/NewEventForm.tsx rename to apps/web/src/components/events/admin/NewEventForm.tsx index e20a7bed..d43ea847 100644 --- a/apps/web/src/components/admin/events/NewEventForm.tsx +++ b/apps/web/src/components/events/admin/NewEventForm.tsx @@ -25,45 +25,43 @@ import { Textarea } from "@/components/shadcn/ui/textarea"; import c from "config"; import { DateTimePicker } from "@/components/shadcn/ui/date-time-picker/date-time-picker"; import { parseAbsolute, getLocalTimeZone } from "@internationalized/date"; -import { newEventValidator } from "@/validators/shared/newEvent"; import { zpostSafe } from "@/lib/utils/client/zfetch"; import { BasicRedirValidator } from "@/validators/shared/basicRedir"; import { useState } from "react"; -import { Shell } from "lucide-react"; +import { LoaderPinwheel } from "lucide-react"; import { useRouter } from "next/navigation"; - -interface NewEventFormProps { - defaultDate: Date; -} - -const formSchema = newEventValidator.merge( - z.object({ - type: z.enum(Object.keys(c.eventTypes) as any), - }), -); +import { ONE_HOUR_IN_MILLISECONDS } from "@/lib/constants"; +import { NewEventFormProps } from "@/lib/types/events"; +import { newEventFormSchema } from "@/validators/event"; +import { useAction } from "next-safe-action/hook"; +import { eventType } from "@/lib/utils/shared/types"; +import { useEffect } from "react"; +import { ThreeCircles } from "react-loader-spinner"; export default function NewEventForm({ defaultDate }: NewEventFormProps) { const [loading, setLoading] = useState(false); const router = useRouter(); - const form = useForm>({ - resolver: zodResolver(formSchema), + const userLocalTimeZone = getLocalTimeZone(); + + const form = useForm>({ + resolver: zodResolver(newEventFormSchema), defaultValues: { title: "", description: "", type: "" as any, host: "", startTime: defaultDate, - endTime: defaultDate, + endTime: new Date(defaultDate.getTime() + ONE_HOUR_IN_MILLISECONDS), }, }); - async function onSubmit(values: z.infer) { + async function onSubmit(values: z.infer) { setLoading(true); const res = await zpostSafe({ url: "/api/admin/events/create", body: values, superReq: true, - vReq: formSchema, + vReq: newEventFormSchema, vRes: BasicRedirValidator, }); setLoading(false); @@ -91,8 +89,7 @@ export default function NewEventForm({ defaultDate }: NewEventFormProps) { - Generally its best to keep this short and - consise + Keep title short and concise @@ -105,10 +102,7 @@ export default function NewEventForm({ defaultDate }: NewEventFormProps) { Description -