From c0df2b607fd5918e2b04ab4e04ab070dcc6ebef1 Mon Sep 17 00:00:00 2001 From: pruthviarj7714 Date: Thu, 8 Aug 2024 17:46:21 +0530 Subject: [PATCH] lint & format fix --- src/app/admin/page.tsx | 138 +++++++++++--------- src/app/api/admin/discordReset/get/route.ts | 72 ++++++---- src/app/api/admin/discordReset/route.ts | 72 ++++++---- src/app/error.tsx | 3 - tsconfig.json | 10 +- 5 files changed, 169 insertions(+), 126 deletions(-) diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 8136f7485..38cef2c1a 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -214,68 +214,86 @@ export default function Courses() { - + - Allow user another account in cohort 3 + Discord - - { - setEmail(e.target.value); - }} - > - { - setAdminPassword(e.target.value); - }} - > - - - - - - - Get users discord username in cohort 3 - - - { - setEmail(e.target.value); - }} - > - { - setAdminPassword(e.target.value); - }} - > - + + + + Allow user another account in cohort 3 + + + { + setEmail(e.target.value); + }} + > + { + setAdminPassword(e.target.value); + }} + > + + + + + + Get users discord username in cohort 3 + + + { + setEmail(e.target.value); + }} + > + { + setAdminPassword(e.target.value); + }} + > + + + diff --git a/src/app/api/admin/discordReset/get/route.ts b/src/app/api/admin/discordReset/get/route.ts index df4467f03..6f3f6a644 100644 --- a/src/app/api/admin/discordReset/get/route.ts +++ b/src/app/api/admin/discordReset/get/route.ts @@ -12,41 +12,55 @@ export async function POST(req: NextRequest) { if (!parseResult.success) { return NextResponse.json( - { error: parseResult.error.message }, + { error: parseResult.error.message, message: 'Invalid input data' }, { status: 400 }, ); } - const { adminPassword, email } = parseResult.data; + try { + const { adminPassword, email } = parseResult.data; - if (adminPassword !== process.env.ADMIN_SECRET) { - return NextResponse.json({}, { status: 401 }); - } + if (adminPassword !== process.env.ADMIN_SECRET) { + return NextResponse.json( + { + message: 'Invalid Admin Password', + }, + { status: 401 }, + ); + } - const user = await db.user.findFirst({ - where: { - email, - }, - }); + const user = await db.user.findFirst({ + where: { + email, + }, + }); - if (!user) { - return NextResponse.json({ msg: 'User not found' }, { status: 404 }); - } + if (!user) { + return NextResponse.json({ message: 'User not found' }, { status: 404 }); + } - const response = await db.discordConnectBulk.findMany({ - where: { - userId: user.id, - }, - select: { - discordId: true, - username: true, - }, - }); - - return NextResponse.json( - { data: response }, - { - status: 200, - }, - ); + const response = await db.discordConnectBulk.findMany({ + where: { + userId: user.id, + }, + select: { + discordId: true, + username: true, + }, + }); + + return NextResponse.json( + { data: response }, + { + status: 200, + }, + ); + } catch (error) { + return NextResponse.json( + { + message: 'Internal Server Error', + }, + { status: 500 }, + ); + } } diff --git a/src/app/api/admin/discordReset/route.ts b/src/app/api/admin/discordReset/route.ts index 8f0202be5..7e43e7288 100644 --- a/src/app/api/admin/discordReset/route.ts +++ b/src/app/api/admin/discordReset/route.ts @@ -12,41 +12,55 @@ export async function POST(req: NextRequest) { if (!parseResult.success) { return NextResponse.json( - { error: parseResult.error.message }, + { error: parseResult.error.message, message: 'Invalid Input data' }, { status: 400 }, ); } - const { adminPassword, email } = parseResult.data; + try { + const { adminPassword, email } = parseResult.data; - if (adminPassword !== process.env.ADMIN_SECRET) { - return NextResponse.json({}, { status: 401 }); - } + if (adminPassword !== process.env.ADMIN_SECRET) { + return NextResponse.json( + { + message: 'Invalid Admin Password', + }, + { status: 401 }, + ); + } - const user = await db.user.findFirst({ - where: { - email, - }, - }); + const user = await db.user.findFirst({ + where: { + email, + }, + }); - if (!user) { - return NextResponse.json({ msg: 'User not found' }, { status: 404 }); - } + if (!user) { + return NextResponse.json({ message: 'User not found' }, { status: 404 }); + } - const response = await db.discordConnectBulk.updateMany({ - where: { - userId: user.id, - cohortId: '3', - }, - data: { - cohortId: Math.random().toString(), - }, - }); - - return NextResponse.json( - { data: response }, - { - status: 200, - }, - ); + const response = await db.discordConnectBulk.updateMany({ + where: { + userId: user.id, + cohortId: '3', + }, + data: { + cohortId: Math.random().toString(), + }, + }); + + return NextResponse.json( + { data: response }, + { + status: 200, + }, + ); + } catch (error) { + return NextResponse.json( + { + message: 'Internal Server Error', + }, + { status: 500 }, + ); + } } diff --git a/src/app/error.tsx b/src/app/error.tsx index db6d36727..87bf2262c 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -1,16 +1,13 @@ 'use client'; -import { Button } from '@/components/ui/button'; import { InfoIcon } from 'lucide-react'; import Link from 'next/link'; import { useEffect } from 'react'; export default function ErrorPage({ error, - reset, }: { error: Error & { digest?: string }; - reset: () => void; }) { useEffect(() => { // Log the error to an error reporting service diff --git a/tsconfig.json b/tsconfig.json index 1f308869a..cec286f06 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,14 +16,14 @@ "incremental": true, "plugins": [ { - "name": "next" - } + "name": "next", + }, ], "paths": { "@/*": ["./src/*"], - "@public/*": ["./public/*"] - } + "@public/*": ["./public/*"], + }, }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules"], }