Unused varibles and methods removal,

Change the way error handling works so I dont have explicit any type.
This commit is contained in:
Hieuhuy Pham 2025-01-24 13:39:11 -05:00
parent f192e51f3c
commit 406963f6bf
3 changed files with 13 additions and 6 deletions

View File

@ -28,11 +28,12 @@ export async function POST(request: Request) {
} }
return NextResponse.json({data: data}, {status: response.status}); return NextResponse.json({data: data}, {status: response.status});
} catch (error: any) { } catch (error) {
NextResponse.json({message: 'Going to server error', error: error.message})
}
} catch (error: any) {
console.error('Error handling request:', error); console.error('Error handling request:', error);
return NextResponse.json({ message: 'Internal Server Error', error: error.message }, { status: 500 }); NextResponse.json({message: 'Going to server error'}, {status: 500});
}
} catch (error) {
console.error('Error handling request:', error);
return NextResponse.json({ message: 'Internal Server Error'}, { status: 500 });
} }
} }

View File

@ -17,7 +17,13 @@ const ReportButton: React.FC<ReportButtonProps> = ({ bookId, chapterId }) => {
// Implement report submission here // Implement report submission here
event.preventDefault() event.preventDefault()
const response = await createReport(errorType,details,bookId,chapterId) const response = await createReport(errorType,details,bookId,chapterId)
response.status === 201 ? alert('Report submitted successfully') : alert('Failed to submit report') //Linting be linting
if (response.status === 201){
alert('Report submitted successfully')
}
else{
alert('Failed to submit report')
}
setErrorType('') setErrorType('')
setDetails('') setDetails('')
setIsOpen(false) setIsOpen(false)

View File

@ -1,5 +1,5 @@
import { addDays, subDays } from "date-fns"; import { addDays, subDays } from "date-fns";
import { Book, Chapter, Editor, Announcement, Glossary, Report } from "./types"; import { Book, Chapter, Editor, Announcement, Glossary } from "./types";
const API_URL = process.env.NEXT_PUBLIC_API_URL as string; const API_URL = process.env.NEXT_PUBLIC_API_URL as string;
const API_TOKEN = process.env.STRAPI_API_TOKEN as string; const API_TOKEN = process.env.STRAPI_API_TOKEN as string;