From 674959dbadba850707d1f527ad7f05e435f8be33 Mon Sep 17 00:00:00 2001 From: Ethan Bickel Date: Thu, 3 Oct 2024 13:40:44 -0500 Subject: [PATCH 1/7] move prettier config to modules and add typing --- .prettierrc.js | 9 --------- .prettierrc.mjs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) delete mode 100644 .prettierrc.js create mode 100644 .prettierrc.mjs 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; From c3a1532e7cb98f3a2e2685aec085aa177239ef3e Mon Sep 17 00:00:00 2001 From: Ethan Bickel Date: Thu, 3 Oct 2024 14:41:23 -0500 Subject: [PATCH 2/7] fix formatting check --- .github/workflows/prettierCheck.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml index e642ea75..09538a2f 100644 --- a/.github/workflows/prettierCheck.yml +++ b/.github/workflows/prettierCheck.yml @@ -16,9 +16,11 @@ jobs: npm i --no-save prettier prettier-plugin-tailwindcss mv package.json.bak package.json - name: Run prettier + id: prettier + continue-on-error: true run: | - files=`npx prettier . -l` || st=$? && st=$? - echo status=`echo $st`>>"$GITHUB_ENV" - echo files=`echo $files`>> "$GITHUB_ENV" + echo "files=${npx prettier . -l}">> "$GITHUB_ENV" - name: generate errors/summary run: .github/workflows/generateCheck.sh + env: + status: ${{ success() && 0 || 1 }} From 2b3468a1c91c3fd8443df9ab275bc25ad693d40d Mon Sep 17 00:00:00 2001 From: Ethan Bickel Date: Thu, 3 Oct 2024 14:46:50 -0500 Subject: [PATCH 3/7] fix status check --- .github/workflows/prettierCheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml index 09538a2f..d875a5e8 100644 --- a/.github/workflows/prettierCheck.yml +++ b/.github/workflows/prettierCheck.yml @@ -23,4 +23,4 @@ jobs: - name: generate errors/summary run: .github/workflows/generateCheck.sh env: - status: ${{ success() && 0 || 1 }} + status: ${{ steps.prettier.outcome == 'success' && 0 || 1 }} From 37b81f7e0835535d1db297d61cbd73dd20516585 Mon Sep 17 00:00:00 2001 From: Ethan Bickel Date: Thu, 3 Oct 2024 14:50:17 -0500 Subject: [PATCH 4/7] fix substitution --- .github/workflows/prettierCheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml index d875a5e8..11982147 100644 --- a/.github/workflows/prettierCheck.yml +++ b/.github/workflows/prettierCheck.yml @@ -19,7 +19,7 @@ jobs: id: prettier continue-on-error: true run: | - echo "files=${npx prettier . -l}">> "$GITHUB_ENV" + echo files=`npx prettier . -l` >> "$GITHUB_ENV" - name: generate errors/summary run: .github/workflows/generateCheck.sh env: From 4b1b9837b620b3cb55997b2bc37e63a840b78f09 Mon Sep 17 00:00:00 2001 From: Ethan Bickel Date: Thu, 3 Oct 2024 15:08:44 -0500 Subject: [PATCH 5/7] simplify install --- .github/workflows/prettierCheck.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml index 11982147..ea76a9ad 100644 --- a/.github/workflows/prettierCheck.yml +++ b/.github/workflows/prettierCheck.yml @@ -11,15 +11,11 @@ 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 id: prettier continue-on-error: true - run: | - echo files=`npx prettier . -l` >> "$GITHUB_ENV" + run: echo files=`npx prettier . -l` >> "$GITHUB_ENV" - name: generate errors/summary run: .github/workflows/generateCheck.sh env: From 8fdeb9d79a2f5ac9b1f33edf6d844f4aa5965a1b Mon Sep 17 00:00:00 2001 From: Ethan Bickel Date: Thu, 3 Oct 2024 15:14:02 -0500 Subject: [PATCH 6/7] formatting fixes --- .../[clubId]/create/CreateEventForm.tsx | 331 ++++++++++-------- .../[clubId]/create/EventCardPreview.tsx | 110 +++--- src/app/manage/[clubId]/create/TimeSelect.tsx | 177 ++++++---- src/app/manage/[clubId]/create/page.tsx | 1 - src/server/api/routers/event.ts | 7 +- src/utils/formSchemas.ts | 2 +- 6 files changed, 366 insertions(+), 262 deletions(-) diff --git a/src/app/manage/[clubId]/create/CreateEventForm.tsx b/src/app/manage/[clubId]/create/CreateEventForm.tsx index fb3fbf0e..bd09638c 100644 --- a/src/app/manage/[clubId]/create/CreateEventForm.tsx +++ b/src/app/manage/[clubId]/create/CreateEventForm.tsx @@ -1,142 +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, - 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({ - 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: (data) => { if (data) { - router.push(`/event/${data}`); - } }, - onError: () => { - setLoading(false); - } - }) + 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 && !loading) { - setLoading(true); - 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

-
-