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 44
44
"next-themes" : " ^0.3.0" ,
45
45
"pdf-lib" : " ^1.17.1" ,
46
46
"pdfjs-dist" : " 3.4.120" ,
47
+ "prettier" : " ^3.5.3" ,
48
+ "prettier-plugin-tailwindcss" : " ^0.6.11" ,
47
49
"raw-loader" : " ^4.0.2" ,
48
50
"react" : " ^18.3.1" ,
49
51
"react-dom" : " ^18.3.1" ,
55
57
"zod" : " ^3.24.2"
56
58
},
57
59
"devDependencies" : {
58
- "@types/node " : " 22.13.10 " ,
60
+ "@types/eslint " : " 8.56.12 " ,
59
61
"@types/react" : " ^18.3.18" ,
60
62
"@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" ,
63
65
"eslint" : " ^8.57.1" ,
64
66
"eslint-config-next" : " ^14.2.24" ,
65
67
"tailwindcss" : " ^3.4.17" ,
Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ async function setTagsFromCurrentLists(
257
257
) ;
258
258
const courses = data . map ( ( course : { name : string } ) => course . name ) ;
259
259
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!" ) ;
261
261
}
262
262
263
263
const newTags : ExamDetail = {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export async function GET(req: NextRequest) {
21
21
{ status : 400 } ,
22
22
) ;
23
23
}
24
- console . log ( ( await Paper . find ( ) ) . map ( ( paper ) => { paper . campus } ) )
24
+ console . log ( ( await Paper . find ( ) ) . map ( ( paper ) => paper . campus ) )
25
25
const papers : IPaper [ ] = await Paper . find ( {
26
26
subject : { $regex : new RegExp ( `${ escapedSubject } ` , "i" ) } ,
27
27
} ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { extractBracketContent } from "@/util/utils";
8
8
import axios , { type AxiosResponse } from "axios" ;
9
9
import { type Metadata } from "next" ;
10
10
import { redirect } from "next/navigation" ; // Import redirect
11
- import QR from "@/components/qr" ;
12
11
13
12
export async function generateMetadata ( {
14
13
params,
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import Dropzone from "react-dropzone";
12
12
import { createCanvas } from "canvas" ;
13
13
import { getDocument , GlobalWorkerOptions } from "pdfjs-dist" ;
14
14
import { PDFDocument } from "pdf-lib" ;
15
- import { ApiError } from "next/dist/server/api-utils" ;
16
15
async function pdfToImage ( file : File ) {
17
16
GlobalWorkerOptions . workerSrc =
18
17
"https://unpkg.com/pdfjs-dist@3.4.120/build/pdf.worker.min.js" ;
@@ -22,7 +21,7 @@ async function pdfToImage(file: File) {
22
21
// Get the first page
23
22
const page = pdfDoc . getPages ( ) [ 0 ] ;
24
23
if ( ! page ) {
25
- throw "First page not found" ;
24
+ throw Error ( "First page not found" ) ;
26
25
}
27
26
// Create a canvas to render the image
28
27
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({
34
34
35
35
return analysisResult [ 0 ] ?. examDetail ;
36
36
} else {
37
- throw "Error Creating the Image" ;
37
+ throw Error ( "Error Creating the Image" ) ;
38
38
}
39
39
}
40
40
// export async function pdfToImage(file: File) {
@@ -67,7 +67,8 @@ export default async function processAndAnalyze({
67
67
function parseExamDetail ( analysis : string ) : ExamDetail {
68
68
try {
69
69
// 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 ) ;
71
72
if ( jsonMatch ) {
72
73
const examDetail : ExamDetail = JSON . parse ( jsonMatch [ 0 ] ) as ExamDetail ;
73
74
if ( examDetail . semester ) {
Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ export function toSentenceCase(input: string): string {
14
14
}
15
15
16
16
export 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
19
20
}
20
21
21
22
export function extractWithoutBracketContent ( subject : string ) : string {
You can’t perform that action at this time.
0 commit comments