Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting check #227

Merged
merged 20 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/generateCheck.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions .github/workflows/prettierCheck.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/server/db/migrations/*
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 14 additions & 7 deletions src/app/event/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -52,7 +56,10 @@ export default async function EventsPage({ params }: Params) {
</section>
<section className="flex md:float-right md:my-auto">
{session && (
<RegisterButton eventId={event.id} isRegistered={isRegistered} />
<RegisterButton
eventId={event.id}
isRegistered={isRegistered}
/>
)}
</section>
</div>
Expand Down
16 changes: 8 additions & 8 deletions src/app/events/eventView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const EventView = ({ events, params }: Props) => {

return (
<div className="w-full px-6">
<div className="md:pr-7.5 flex flex-col pt-4 sm:flex-row sm:pb-12">
<div className="flex flex-col pt-4 sm:flex-row sm:pb-12 md:pr-7.5">
<h1 className="text-left text-2xl font-bold text-[#4D5E80]">Events</h1>
<div className="relative z-0 hidden flex-row gap-x-16 md:ml-auto md:flex">
<Link
className={`z-20 flex flex-row items-center gap-x-4 ${
view === 'list'
? ' -mr-7.5 px-7.5 rounded-full bg-white py-2.5'
? ' -mr-7.5 rounded-full bg-white px-7.5 py-2.5'
: ''
}`}
href={{
Expand All @@ -34,12 +34,12 @@ const EventView = ({ events, params }: Props) => {
<div className="h-7.5 w-7.5">
<ListIcon />
</div>
<p className="text-blue-primary text-sm font-bold">List view</p>
<p className="text-sm font-bold text-blue-primary">List view</p>
</Link>
<Link
className={`z-20 flex flex-row items-center gap-x-4 ${
view == 'grid'
? '-ml-7.5 px-7.5 rounded-full bg-white py-2.5'
? '-ml-7.5 rounded-full bg-white px-7.5 py-2.5'
: 'mr-7.5'
}`}
href={{
Expand All @@ -53,18 +53,18 @@ const EventView = ({ events, params }: Props) => {
<div className="h-7.5 w-7.5">
<GridIcon />
</div>
<p className="text-blue-primary text-sm font-bold">Grid view</p>
<p className="text-sm font-bold text-blue-primary">Grid view</p>
</Link>
</div>
</div>
<div className="sm:space-x-7.5 container flex w-full flex-col overflow-x-clip sm:flex-row">
<div className="container flex w-full flex-col overflow-x-clip sm:flex-row sm:space-x-7.5">
<EventSidebar />
<div
data-view={view}
className={
view === 'list'
? 'space-y-7.5 group flex flex-col pt-10 sm:justify-start'
: 'gap-y-7.5 group flex flex-wrap justify-center gap-x-10 pt-10 sm:justify-start'
? 'group flex flex-col space-y-7.5 pt-10 sm:justify-start'
: 'group flex flex-wrap justify-center gap-x-10 gap-y-7.5 pt-10 sm:justify-start'
}
>
{events.map((event) => {
Expand Down
1 change: 0 additions & 1 deletion src/app/feedback/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,3 @@ const Form = () => {
};

export default Form;

1 change: 0 additions & 1 deletion src/app/feedback/FormPopUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ const FormPopUp: React.FC<formPopUpProps> = ({ onClose, isOpen }) => {
};

export default FormPopUp;

9 changes: 3 additions & 6 deletions src/app/feedback/page.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -16,15 +15,13 @@ export const metadata: Metadata = {
},
};


const Feedback = () => {

return (
<main className="h-full md:pl-72 ">
<Header />

<div className="flex h-full w-full flex-row mb-20 " >
<section className='bg-white m-auto justift-center items-center text-center py-6 px-10 shadow-lg rounded-lg mt-3'>
<div className="mb-20 flex h-full w-full flex-row ">
<section className="justift-center m-auto mt-3 items-center rounded-lg bg-white px-10 py-6 text-center shadow-lg">
<Form />
</section>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/EventLikeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const EventLikeButton = ({ eventId, liked }: buttonProps) => {
}}
>
{liked ? (
<CheckIcon fill = "fill-slate-800"/>
<CheckIcon fill="fill-slate-800" />
) : (
<PlusIcon fill = "fill-slate-800"/>
<PlusIcon fill="fill-slate-800" />
)}
</button>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/RegisterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ const RegisterButton: FC<RegisterButtonProps> = ({ eventId, isRegistered }) => {
};

export default RegisterButton;

4 changes: 2 additions & 2 deletions src/components/admin/OrgTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex justify-center">
Expand Down
12 changes: 6 additions & 6 deletions src/server/api/routers/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SQL<unknown> | undefined> = [];
Expand Down
38 changes: 19 additions & 19 deletions src/server/api/routers/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
} )
})
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;
});
}),
});
24 changes: 12 additions & 12 deletions src/server/db/schema/forms.ts
Original file line number Diff line number Diff line change
@@ -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(),
})
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(),
});
2 changes: 1 addition & 1 deletion src/utils/formSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export const feedbackFormSchema = z.object({
dislikes: z.string().default(''),
features: z.string().default(''),
submit_on: z.date().default(new Date()),
})
});