diff --git a/.github/workflows/generateCheck.sh b/.github/workflows/generateCheck.sh new file mode 100755 index 00000000..0f98e9cb --- /dev/null +++ b/.github/workflows/generateCheck.sh @@ -0,0 +1,14 @@ +if [ $status == 0 ]; 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 +fi diff --git a/.github/workflows/prettierCheck.yml b/.github/workflows/prettierCheck.yml new file mode 100644 index 00000000..e642ea75 --- /dev/null +++ b/.github/workflows/prettierCheck.yml @@ -0,0 +1,24 @@ +name: Formatting Check +run-name: Running formatting check +on: [push] +jobs: + check-formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + 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 + - name: Run prettier + run: | + files=`npx prettier . -l` || st=$? && st=$? + echo status=`echo $st`>>"$GITHUB_ENV" + echo files=`echo $files`>> "$GITHUB_ENV" + - name: generate errors/summary + run: .github/workflows/generateCheck.sh diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..01f86141 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +src/server/db/migrations/* diff --git a/package-lock.json b/package-lock.json index 2a5f0c36..708e29ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ "jest": "^29.7.0", "lint-staged": "^12.4.0", "postcss": "^8.4.27", - "prettier": "^3.0.0", + "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.1", "tailwindcss": "^3.3.3", "ts-jest": "^29.1.1", @@ -9823,9 +9823,9 @@ } }, "node_modules/prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" diff --git a/package.json b/package.json index e6fb51ae..3deca13e 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "jest": "^29.7.0", "lint-staged": "^12.4.0", "postcss": "^8.4.27", - "prettier": "^3.0.0", + "prettier": "^3.2.5", "prettier-plugin-tailwindcss": "^0.5.1", "tailwindcss": "^3.3.3", "ts-jest": "^29.1.1", diff --git a/src/app/event/[id]/page.tsx b/src/app/event/[id]/page.tsx index cdaf902c..405c6452 100644 --- a/src/app/event/[id]/page.tsx +++ b/src/app/event/[id]/page.tsx @@ -23,12 +23,16 @@ export default async function EventsPage({ params }: Params) { const { club, ...event } = res; - const isRegistered = (session && await db.query.userMetadataToEvents.findFirst({ - where: (userMetadataToEvents) => and( - eq(userMetadataToEvents.eventId, event.id), - eq(userMetadataToEvents.userId, session.user.id) - ) - }) !== undefined) || false; + const isRegistered = + (session && + (await db.query.userMetadataToEvents.findFirst({ + where: (userMetadataToEvents) => + and( + eq(userMetadataToEvents.eventId, event.id), + eq(userMetadataToEvents.userId, session.user.id), + ), + })) !== undefined) || + false; const clubDescription = ['Club', 'Location', 'Multi-Day']; const clubDetails = [club.name, event.location, 'No']; @@ -52,7 +56,10 @@ export default async function EventsPage({ params }: Params) {
{session && ( - + )}
diff --git a/src/app/events/eventView.tsx b/src/app/events/eventView.tsx index 86d97c5a..dfaed368 100644 --- a/src/app/events/eventView.tsx +++ b/src/app/events/eventView.tsx @@ -14,13 +14,13 @@ const EventView = ({ events, params }: Props) => { return (
-
+

Events

{
-

List view

+

List view

{
-

Grid view

+

Grid view

-
+
{events.map((event) => { diff --git a/src/app/feedback/Form.tsx b/src/app/feedback/Form.tsx index 9dc02c4f..65f075c6 100644 --- a/src/app/feedback/Form.tsx +++ b/src/app/feedback/Form.tsx @@ -126,4 +126,3 @@ const Form = () => { }; export default Form; - diff --git a/src/app/feedback/FormPopUp.tsx b/src/app/feedback/FormPopUp.tsx index 44040b46..6b882ac8 100644 --- a/src/app/feedback/FormPopUp.tsx +++ b/src/app/feedback/FormPopUp.tsx @@ -43,4 +43,3 @@ const FormPopUp: React.FC = ({ onClose, isOpen }) => { }; export default FormPopUp; - diff --git a/src/app/feedback/page.tsx b/src/app/feedback/page.tsx index 62a9e111..38feaa5d 100644 --- a/src/app/feedback/page.tsx +++ b/src/app/feedback/page.tsx @@ -1,8 +1,7 @@ import React from 'react'; import Header from '@src/components/BaseHeader'; import { type Metadata } from 'next'; -import Form from '@src/app/feedback/Form'; - +import Form from '@src/app/feedback/Form'; export const metadata: Metadata = { title: 'Feedback - Jupiter', @@ -16,15 +15,13 @@ export const metadata: Metadata = { }, }; - const Feedback = () => { - return (
-
-
+
+
diff --git a/src/components/EventLikeButton.tsx b/src/components/EventLikeButton.tsx index 5edd118b..59588782 100644 --- a/src/components/EventLikeButton.tsx +++ b/src/components/EventLikeButton.tsx @@ -29,9 +29,9 @@ const EventLikeButton = ({ eventId, liked }: buttonProps) => { }} > {liked ? ( - + ) : ( - + )} ); diff --git a/src/components/RegisterButton.tsx b/src/components/RegisterButton.tsx index 905cafb0..58b9b5fb 100644 --- a/src/components/RegisterButton.tsx +++ b/src/components/RegisterButton.tsx @@ -38,4 +38,3 @@ const RegisterButton: FC = ({ eventId, isRegistered }) => { }; export default RegisterButton; - diff --git a/src/components/admin/OrgTable.tsx b/src/components/admin/OrgTable.tsx index 2998727c..c94fd9e7 100644 --- a/src/components/admin/OrgTable.tsx +++ b/src/components/admin/OrgTable.tsx @@ -92,8 +92,8 @@ export default function OrgTable({ clubs }: { clubs: Club[] }) { approved === 'pending' ? 'bg-yellow-500' : approved === 'approved' - ? 'bg-green-500' - : 'bg-red-500'; + ? 'bg-green-500' + : 'bg-red-500'; return (
diff --git a/src/server/api/routers/event.ts b/src/server/api/routers/event.ts index 6f14cca3..9ce25f09 100644 --- a/src/server/api/routers/event.ts +++ b/src/server/api/routers/event.ts @@ -114,16 +114,16 @@ export const eventRouter = createTRPCRouter({ input.startTime.type === 'now' ? new Date() : input.startTime.type === 'distance' - ? add(new Date(), input.startTime.options) - : input.startTime.options.from ?? new Date(); + ? add(new Date(), input.startTime.options) + : input.startTime.options.from ?? new Date(); const endTime = input.startTime.type === 'distance' ? new Date() : input.startTime.type === 'range' - ? input.startTime.options.to - ? add(input.startTime.options.to, { days: 1 }) - : add(startTime, { days: 1 }) - : undefined; + ? input.startTime.options.to + ? add(input.startTime.options.to, { days: 1 }) + : add(startTime, { days: 1 }) + : undefined; const events = await ctx.db.query.events.findMany({ where: (event) => { const whereElements: Array | undefined> = []; diff --git a/src/server/api/routers/form.ts b/src/server/api/routers/form.ts index 457f6d5d..af42934d 100644 --- a/src/server/api/routers/form.ts +++ b/src/server/api/routers/form.ts @@ -2,24 +2,24 @@ import { createTRPCRouter, publicProcedure } from '../trpc'; import { forms } from '@src/server/db/schema/forms'; import { feedbackFormSchema } from '@src/utils/formSchemas'; - export const formRouter = createTRPCRouter({ - sendForm: publicProcedure. - input(feedbackFormSchema). - mutation( async ( {input, ctx}) => { - const { rating, likes, dislikes, features, submit_on } = input; + sendForm: publicProcedure + .input(feedbackFormSchema) + .mutation(async ({ input, ctx }) => { + const { rating, likes, dislikes, features, submit_on } = input; - await ctx.db - .insert(forms) - .values({ - rating: rating, - likes : likes, - dislikes: dislikes, - features: features, - submit_on: submit_on, - }).catch ((e) => { - console.error(e); - throw e; - }) - } ) - }) \ No newline at end of file + await ctx.db + .insert(forms) + .values({ + rating: rating, + likes: likes, + dislikes: dislikes, + features: features, + submit_on: submit_on, + }) + .catch((e) => { + console.error(e); + throw e; + }); + }), +}); diff --git a/src/server/db/schema/forms.ts b/src/server/db/schema/forms.ts index dd5fd9da..cdfd092c 100644 --- a/src/server/db/schema/forms.ts +++ b/src/server/db/schema/forms.ts @@ -1,13 +1,13 @@ -import { sql } from "drizzle-orm"; -import { pgTable, text, timestamp, integer } from "drizzle-orm/pg-core" +import { sql } from 'drizzle-orm'; +import { pgTable, text, timestamp, integer } from 'drizzle-orm/pg-core'; -export const forms = pgTable("feedback_form", { - id: text("id") - .default(sql`nanoid(20)`) - .primaryKey(), - rating: integer('rating').notNull(), - likes: text('likes').default(''), - dislikes: text('dislikes').default(''), - features: text('features').default(''), - submit_on: timestamp('submit_on', { withTimezone: true }).notNull(), -}) \ No newline at end of file +export const forms = pgTable('feedback_form', { + id: text('id') + .default(sql`nanoid(20)`) + .primaryKey(), + rating: integer('rating').notNull(), + likes: text('likes').default(''), + dislikes: text('dislikes').default(''), + features: text('features').default(''), + submit_on: timestamp('submit_on', { withTimezone: true }).notNull(), +}); diff --git a/src/utils/formSchemas.ts b/src/utils/formSchemas.ts index c58c9a0b..7c008671 100644 --- a/src/utils/formSchemas.ts +++ b/src/utils/formSchemas.ts @@ -48,4 +48,4 @@ export const feedbackFormSchema = z.object({ dislikes: z.string().default(''), features: z.string().default(''), submit_on: z.date().default(new Date()), -}) \ No newline at end of file +});