File tree Expand file tree Collapse file tree 8 files changed +187
-161
lines changed Expand file tree Collapse file tree 8 files changed +187
-161
lines changed Original file line number Diff line number Diff line change 4444 "next-themes" : " ^0.3.0" ,
4545 "pdf-lib" : " ^1.17.1" ,
4646 "pdfjs-dist" : " 3.4.120" ,
47+ "prettier" : " ^3.5.3" ,
48+ "prettier-plugin-tailwindcss" : " ^0.6.11" ,
4749 "raw-loader" : " ^4.0.2" ,
4850 "react" : " ^18.3.1" ,
4951 "react-dom" : " ^18.3.1" ,
5557 "zod" : " ^3.24.2"
5658 },
5759 "devDependencies" : {
58- "@types/node " : " 22.13.10 " ,
60+ "@types/eslint " : " 8.56.12 " ,
5961 "@types/react" : " ^18.3.18" ,
6062 "@types/react-dom" : " ^18.3.5" ,
61- "@typescript-eslint/eslint-plugin" : " ^7.18 .0" ,
62- "@typescript-eslint/parser" : " ^7.18 .0" ,
63+ "@typescript-eslint/eslint-plugin" : " ^8.26 .0" ,
64+ "@typescript-eslint/parser" : " ^8.26 .0" ,
6365 "eslint" : " ^8.57.1" ,
6466 "eslint-config-next" : " ^14.2.24" ,
6567 "tailwindcss" : " ^3.4.17" ,
Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ async function setTagsFromCurrentLists(
257257 ) ;
258258 const courses = data . map ( ( course : { name : string } ) => course . name ) ;
259259 if ( ! courses [ 0 ] || ! slots [ 0 ] || ! exams [ 0 ] || ! semesters [ 0 ] || ! years [ 0 ] ) {
260- throw "Cannot fetch default value for courses/slot/exam/sem/year!" ;
260+ throw Error ( "Cannot fetch default value for courses/slot/exam/sem/year!" ) ;
261261 }
262262
263263 const newTags : ExamDetail = {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function GET(req: NextRequest) {
2121 { status : 400 } ,
2222 ) ;
2323 }
24- console . log ( ( await Paper . find ( ) ) . map ( ( paper ) => { paper . campus } ) )
24+ console . log ( ( await Paper . find ( ) ) . map ( ( paper ) => paper . campus ) )
2525 const papers : IPaper [ ] = await Paper . find ( {
2626 subject : { $regex : new RegExp ( `${ escapedSubject } ` , "i" ) } ,
2727 } ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { extractBracketContent } from "@/util/utils";
88import axios , { type AxiosResponse } from "axios" ;
99import { type Metadata } from "next" ;
1010import { redirect } from "next/navigation" ; // Import redirect
11- import QR from "@/components/qr" ;
1211
1312export async function generateMetadata ( {
1413 params,
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import Dropzone from "react-dropzone";
1212import { createCanvas } from "canvas" ;
1313import { getDocument , GlobalWorkerOptions } from "pdfjs-dist" ;
1414import { PDFDocument } from "pdf-lib" ;
15- import { ApiError } from "next/dist/server/api-utils" ;
1615async function pdfToImage ( file : File ) {
1716 GlobalWorkerOptions . workerSrc =
1817 "https://unpkg.com/[email protected] /build/pdf.worker.min.js" ; @@ -22,7 +21,7 @@ async function pdfToImage(file: File) {
2221 // Get the first page
2322 const page = pdfDoc . getPages ( ) [ 0 ] ;
2423 if ( ! page ) {
25- throw "First page not found" ;
24+ throw Error ( "First page not found" ) ;
2625 }
2726 // Create a canvas to render the image
2827 const canvas = createCanvas ( page . getWidth ( ) , page . getHeight ( ) ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export default async function processAndAnalyze({
3434
3535 return analysisResult [ 0 ] ?. examDetail ;
3636 } else {
37- throw "Error Creating the Image" ;
37+ throw Error ( "Error Creating the Image" ) ;
3838 }
3939}
4040// export async function pdfToImage(file: File) {
@@ -67,7 +67,8 @@ export default async function processAndAnalyze({
6767function parseExamDetail ( analysis : string ) : ExamDetail {
6868 try {
6969 // Try to find JSON in the response
70- const jsonMatch = analysis . match ( / \{ [ \s \S ] * \} / ) ;
70+ const jsonRegex = / \{ [ \s \S ] * \} / ;
71+ const jsonMatch = jsonRegex . exec ( analysis ) ;
7172 if ( jsonMatch ) {
7273 const examDetail : ExamDetail = JSON . parse ( jsonMatch [ 0 ] ) as ExamDetail ;
7374 if ( examDetail . semester ) {
Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ export function toSentenceCase(input: string): string {
1414}
1515
1616export function extractBracketContent ( subject : string ) : string | null {
17- const match = subject . match ( / \[ ( .* ?) \] / ) ;
18- return match ?. [ 1 ] ? match [ 1 ] : "BMAT102L" ; //MAKE SURE IT WORKS WHEN URL IS DONE FROM BACKEND
17+ const regex = / \[ ( .* ?) \] / ;
18+ const match = regex . exec ( subject ) ;
19+ return match ?. [ 1 ] ?? "BMAT102L" ; //MAKE SURE IT WORKS WHEN URL IS DONE FROM BACKEND
1920}
2021
2122export function extractWithoutBracketContent ( subject : string ) : string {
You can’t perform that action at this time.
0 commit comments