Skip to content

Commit 21a56cf

Browse files
fix:build errors
1 parent 0eefebc commit 21a56cf

File tree

7 files changed

+11
-14
lines changed

7 files changed

+11
-14
lines changed

src/app/api/upload/route.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function POST(req: Request) {
5656
);
5757
}
5858
} else {
59-
[public_id_cloudinary, finalUrl] = await uploadPDFFile(files[0] as File, uploadPreset);
59+
[public_id_cloudinary, finalUrl] = await uploadPDFFile(files[0]!, uploadPreset);
6060
}
6161
const thumbnailResponse = cloudinary.v2.image(finalUrl!, {
6262
format: "jpg",
@@ -99,17 +99,15 @@ async function uploadPDFFile(file: File | ArrayBuffer, uploadPreset: string) {
9999
}
100100
else // for images that are pdf
101101
{
102-
bytes = file as ArrayBuffer;
102+
bytes = file;
103103
}
104104
return uploadFile(bytes, uploadPreset, "application/pdf")
105105
}
106106
async function uploadFile(bytes: ArrayBuffer, uploadPreset: string, fileType: string) {
107107
try {
108108
const buffer = Buffer.from(bytes);
109109
const dataUrl = `data:${fileType};base64,${buffer.toString("base64")}`;
110-
111-
const uploadResult: CloudinaryUploadResult =
112-
await cloudinary.v2.uploader.unsigned_upload(dataUrl, uploadPreset);
110+
const uploadResult = await cloudinary.v2.uploader.unsigned_upload(dataUrl, uploadPreset) as CloudinaryUploadResult;
113111
return [uploadResult.public_id, uploadResult.secure_url ];
114112
} catch (e) {
115113
throw (e);

src/components/CatalogueContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ const CatalogueContent = () => {
111111
setLoading(true);
112112

113113
try {
114-
const papersResponse = await axios.get("/api/papers", {
114+
const papersResponse = await axios.get<{ papers: Paper[], filters: Filters }>("/api/papers", {
115115
params: { subject },
116116
});
117117
const papersData: Paper[] = papersResponse.data.papers;
118-
const filters: Filters = papersResponse.data;
118+
const filters: Filters = papersResponse.data.filters;
119119

120120
setFilterOptions(filters);
121121

src/components/StoredPapers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function StoredPapers() {
1313
async function fetchPapers() {
1414
try {
1515
const response = await axios.get("/api/selected-papers");
16-
setDisplayPapers(response.data);
16+
setDisplayPapers(response.data as Paper[]);
1717
} catch (error) {
1818
setDisplayPapers(papers);
1919
console.error("Failed to fetch papers:", error);

src/components/searchbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function SearchBar() {
2020
if (text.length > 1) {
2121
setLoading(true);
2222
try {
23-
const searchResponse = await axios.get("/api/search", {
23+
const searchResponse = await axios.get<{ subjects: { subject: string }[] }>("/api/search", {
2424
params: { text },
2525
});
2626

@@ -51,7 +51,7 @@ function SearchBar() {
5151
if (text.length <= 1) {
5252
setSuggestions([]);
5353
}
54-
debouncedSearch(text);
54+
void debouncedSearch(text);
5555
};
5656

5757
const handleSelectSuggestion = async (suggestion: string) => {

src/components/ui/command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Command = React.forwardRef<
2323
))
2424
Command.displayName = CommandPrimitive.displayName
2525

26-
interface CommandDialogProps extends DialogProps {}
26+
type CommandDialogProps = DialogProps
2727

2828
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
2929
return (

src/components/ui/input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as React from "react"
22

33
import { cn } from "@/lib/utils"
44

5-
export interface InputProps
6-
extends React.InputHTMLAttributes<HTMLInputElement> {}
5+
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>
76

87
const Input = React.forwardRef<HTMLInputElement, InputProps>(
98
({ className, type, ...props }, ref) => {

src/util/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function toSentenceCase(input: string): string {
1515

1616
export function extractBracketContent(subject: string): string | null {
1717
const match = subject.match(/\[(.*?)\]/);
18-
return match && match[1] ? match[1] : "BMAT102L"; //MAKE SURE IT WORKS WHEN URL IS DONE FROM BACKEND
18+
return match?.[1] ? match[1] : "BMAT102L"; //MAKE SURE IT WORKS WHEN URL IS DONE FROM BACKEND
1919
}
2020

2121
export function extractWithoutBracketContent(subject: string): string {

0 commit comments

Comments
 (0)