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

chore: update packages + migrate to prisma 5 #145

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"]
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/PR-CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- run: npm install prettier
- run: npm run format:check
1,828 changes: 991 additions & 837 deletions package-lock.json

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,61 @@
},
"dependencies": {
"@formkit/auto-animate": "^1.0.0-beta.5",
"@fullcalendar/bootstrap5": "^6.0.2",
"@fullcalendar/core": "^6.0.2",
"@fullcalendar/daygrid": "^6.0.2",
"@fullcalendar/react": "^6.0.2",
"@fullcalendar/timegrid": "^6.0.2",
"@next-auth/prisma-adapter": "^1.0.4",
"@fullcalendar/bootstrap5": "^6.1.9",
"@fullcalendar/core": "^6.1.9",
"@fullcalendar/daygrid": "^6.1.9",
"@fullcalendar/react": "^6.1.9",
"@fullcalendar/timegrid": "^6.1.9",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^4.8.0",
"@sendgrid/mail": "^7.7.0",
"@syncfusion/ej2-react-schedule": "^20.4.43",
"@tanstack/react-query": "^4.35.7",
"@trpc/client": "^10.38.5",
"@trpc/next": "^10.38.5",
"@trpc/react-query": "^10.38.5",
"@trpc/server": "^10.38.5",
"@typeform/embed-react": "^2.1.0",
"@zxing/browser": "^0.1.1",
"bootstrap": "^5.2.3",
"bootstrap-icons": "^1.10.3",
"clsx": "^1.2.1",
"daisyui": "^2.46.1",
"devextreme": "22.2.3",
"devextreme-react": "22.2.3",
"@syncfusion/ej2-react-schedule": "^23.1.40",
"@tanstack/react-query": "^5.4.3",
"@trpc/client": "^10.43.1",
"@trpc/next": "^10.43.1",
"@trpc/react-query": "^10.43.1",
"@trpc/server": "^10.43.1",
"@typeform/embed-react": "^3.8.0",
"@zxing/browser": "^0.1.4",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.1",
"clsx": "^2.0.0",
"daisyui": "^3.9.4",
"devextreme": "23.1.6",
"devextreme-react": "23.1.6",
"fork-react-qr-reader": "^3.0.1-beta-1",
"ical-js-parser": "^0.6.12",
"ical-js-parser": "^0.7.4",
"ical.js": "^1.5.0",
"next": "^13.4.16",
"next-auth": "^4.15.1",
"next": "^13.5.6",
"next-auth": "^4.24.4",
"next-themes": "^0.2.1",
"papaparse": "^5.3.2",
"planby": "^1.1.2",
"papaparse": "^5.4.1",
"planby": "^1.1.4",
"prisma-generate": "^0.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.7.1",
"react-qr-code": "^2.0.11",
"react-icons": "^4.11.0",
"react-qr-code": "^2.0.12",
"react-qr-reader": "^3.0.0-beta-1",
"react-timelines": "^2.6.1",
"superjson": "^1.10.0",
"zod": "^3.18.0"
"superjson": "^2.2.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "18.0.0",
"@types/react": "18.0.14",
"@types/react-dom": "18.0.5",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"autoprefixer": "^10.4.8",
"eslint": "8.22.0",
"eslint-config-next": "^13.4.16",
"postcss": "^8.4.16",
"prettier": "^2.8.2",
"prettier-plugin-tailwindcss": "^0.1.13",
"@types/node": "20.8.10",
"@types/react": "18.2.34",
"@types/react-dom": "18.2.14",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"autoprefixer": "^10.4.16",
"eslint": "8.53.0",
"eslint-config-next": "^13.5.6",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.6",
"prisma": "^4.8.0",
"tailwindcss": "^3.1.8",
"typescript": "4.7.4"
"tailwindcss": "^3.3.5",
"typescript": "5.2.2"
},
"ct3aMetadata": {
"initVersion": "5.8.0"
Expand Down
14 changes: 7 additions & 7 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ generator client {
}

datasource db {
provider = "postgresql"
provider = "cockroachdb"
// NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
Expand All @@ -21,16 +21,16 @@ model Account {
type String
provider String
providerAccountId String
refresh_token String? @db.Text
refresh_token String? //@db.Text
refresh_token_expires_in Int?
access_token String? @db.Text
access_token String? //@db.Text
expires_at Int?
ext_expires_in Int?
oauth_token_secret String? @db.Text
oauth_token String? @db.Text
oauth_token_secret String? //@db.Text
oauth_token String? //@db.Text
token_type String?
scope String?
id_token String? @db.Text
id_token String? //@db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

Comment on lines 21 to 36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refresh_token, access_token, oauth_token_secret, oauth_token, and id_token fields in the Account model have been commented out. If these fields are not used, consider removing them entirely. If they are needed in the future, they can be added back. Leaving commented-out code can lead to confusion and clutter.

Expand All @@ -53,7 +53,7 @@ model User {
image String?
accounts Account[]
sessions Session[]
typeform_response_id String? @db.Text
typeform_response_id String? //@db.Text
role Role[] @default([HACKER])
hacker Review[] @relation("hacker")
reviewer Review[] @relation("reviewer")
Comment on lines 53 to 59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typeform_response_id field in the User model has been commented out. Similar to the previous comment, consider removing this field if it's not used. If it's needed in the future, it can be added back.

Expand Down
6 changes: 3 additions & 3 deletions src/components/Applicant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const Applicant = ({
setAlreadyReviewed(
applicant.reviews.length > 2 ||
applicant.reviews.some(
(review) => review.reviewer.id === session.data?.user?.id
)
(review) => review.reviewer.id === session.data?.user?.id,
),
);
}, [applicant.reviews, session.data?.user?.id]);

Expand Down Expand Up @@ -97,7 +97,7 @@ const Applicant = ({
<button
className={clsx(
"w-full rounded px-4 py-2 text-white",
"bg-primary"
"bg-primary",
)}
onClick={async (e) => {
e.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/components/QrScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const QRScannerScanOnce: React.FC<QRScannerScanOnceProps> = ({ callback }) => {
// you can use the controls to stop() the scan or switchTorch() if available
const result = await codeReader.decodeOnceFromVideoDevice(
selectedDeviceId,
parent!.current!
parent!.current!,
);
console.log("Scanned", result);

Expand Down
2 changes: 1 addition & 1 deletion src/components/QrScanner2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const QRScanner: React.FC<QRScannerProps> = ({
// bad wait condition
lastFired = new Date(Date.now());
}
}
},
);
// const result = await codeReader.decodeOnceFromVideoDevice(
// selectedDeviceId,
Expand Down
6 changes: 3 additions & 3 deletions src/components/RBACWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const rbac = (
session: Session | null,
roles: string[],
redirect = "/dashboard",
inObj: GetServerSidePropsResult<Record<string, unknown>>
inObj: GetServerSidePropsResult<Record<string, unknown>>,
): GetServerSidePropsResult<Record<string, unknown>> => {
if (!session) {
return {
Expand All @@ -15,8 +15,8 @@ export const rbac = (
},
};
}
const authorized = roles.some((r: string) =>
session?.user?.role?.includes(r)
const authorized = roles.some(
(r: string) => session?.user?.role?.includes(r),
);
if (!authorized) {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/env/client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const _clientEnv = clientSchema.safeParse(clientEnv);

export const formatErrors = (
/** @type {import('zod').ZodFormattedError<Map<string,string>,string>} */
errors
errors,
) =>
Object.entries(errors)
.map(([name, value]) => {
Expand All @@ -17,7 +17,7 @@ export const formatErrors = (
if (_clientEnv.success === false) {
console.error(
"❌ Invalid environment variables:\n",
...formatErrors(_clientEnv.error.format())
...formatErrors(_clientEnv.error.format()),
);
throw new Error("Invalid environment variables");
}
Expand Down
2 changes: 1 addition & 1 deletion src/env/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const _serverEnv = serverSchema.safeParse(process.env);
if (_serverEnv.success === false) {
console.error(
"❌ Invalid environment variables:\n",
...formatErrors(_serverEnv.error.format())
...formatErrors(_serverEnv.error.format()),
);
throw new Error("Invalid environment variables");
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
await getServerAuthSession(context),
["ADMIN"],
undefined,
output
output,
);
return output;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/cal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
const Cal = async (req: NextApiRequest, res: NextApiResponse) => {
try {
const resProxy = await fetch(
"https://calendar.google.com/calendar/ical/19061ded5963d8f3264d85463d16c008cd8212cccef06ab47901dbc9ea26d2b6%40group.calendar.google.com/private-24dac76dead730471c7f89cc3e949566/basic.ics"
"https://calendar.google.com/calendar/ical/19061ded5963d8f3264d85463d16c008cd8212cccef06ab47901dbc9ea26d2b6%40group.calendar.google.com/private-24dac76dead730471c7f89cc3e949566/basic.ics",
);
// console.log(res.status);
res.status(200).send(resProxy.body);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/resumes/[...path].ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const resume = async (req: NextApiRequest, res: NextApiResponse) => {
};
const resp = await fetch(
`https://api.typeform.com/forms/${jpath}`,
options
options,
);

res.setHeader("Content-type", resp.headers.get("content-type") || " ");
Expand Down
2 changes: 1 addition & 1 deletion src/pages/apply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Apply: NextPage = () => {
};

export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/checkin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const Checkin: NextPage = () => {

// copied from dashboard.tsx
export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ const Dashboard: NextPage = () => {
};

export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);

Expand Down
10 changes: 5 additions & 5 deletions src/pages/grade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const GradingPortal: NextPage = () => {
undefined,
{
enabled: togglePriotity,
}
},
);
const appQuery = trpc.reviewer.getApplications.useQuery(undefined, {
enabled: !togglePriotity,
Expand All @@ -44,7 +44,7 @@ const GradingPortal: NextPage = () => {
.filter((score) => !Number.isNaN(score)) || [];
const sum = scores.reduce(
(a: number, b: number) => (!Number.isNaN(b) ? a + b : a),
0
0,
);
const avg = sum / scores.length || 0;
setMean(avg);
Expand Down Expand Up @@ -94,7 +94,7 @@ const GradingPortal: NextPage = () => {
// count how many applications have been reviewed
// an application is considered reviewed if it has 3 or more reviews
data?.data.filter(
(application) => application.reviews.length >= 3
(application) => application.reviews.length >= 3,
).length
}{" "}
/ {data?.data.length} Applications Reviewed <br />
Expand Down Expand Up @@ -126,7 +126,7 @@ const GradingPortal: NextPage = () => {
applicant={application}
index={index + 1}
/>
)
),
)
: null}
</tbody>
Expand Down Expand Up @@ -167,7 +167,7 @@ const GradingPortal: NextPage = () => {
};

export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);
// If the user is not an ADMIN or REVIEWER, kick them back to the dashboard
Expand Down
2 changes: 1 addition & 1 deletion src/pages/me.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const Me: NextPage = () => {
};

export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/roles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
await getServerAuthSession(context),
["ADMIN"],
undefined,
output
output,
);
return output;
}
Expand Down
Loading
Loading