Skip to content

Commit 18d85f0

Browse files
year search fix and upload hand
1 parent c284561 commit 18d85f0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/app/api/ai-upload/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export async function POST(req: Request) {
5151
}
5252
}
5353
const tags = await processAndAnalyze({ imageURL });
54+
console.log(" tags:", tags);
55+
5456
const finalTags = await setTagsFromCurrentLists(tags);
5557
console.log("Final tags:", finalTags);
5658
const subject = finalTags["course-name"];
@@ -276,6 +278,7 @@ async function setTagsFromCurrentLists(
276278
if (semesterSearchResult) {
277279
newTags.semester = semesterSearchResult as SemesterType;
278280
}
281+
console.log(tags.year, years)
279282
const yearSearchResult = findMatch(years, tags.year);
280283
if (yearSearchResult) {
281284
newTags.year = yearSearchResult;
@@ -285,6 +288,11 @@ async function setTagsFromCurrentLists(
285288
}
286289
function findMatch<T>(arr: T[], value: string | undefined): T | undefined {
287290
if (!value) return undefined; // Handle undefined case
288-
const pattern = new RegExp(`[${value}]`, "i");
289-
return arr.find((item) => pattern.test(String(item)));
291+
const pattern = new RegExp(
292+
value
293+
.split("")
294+
.map((char) => `(?=.*${char})`)
295+
.join(""),
296+
"i"
297+
); return arr.find((item) => pattern.test(String(item)));
290298
}

src/app/upload/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const Page = () => {
169169
accept={{ "image/*": [], "application/pdf": [] }}
170170
>
171171
{({ getRootProps, getInputProps }) => (
172-
<section className="my-2 -mr-2 rounded-2xl border-2 border-dashed p-8 text-center">
172+
<section className="my-2 cursor-pointer -mr-2 rounded-2xl border-2 border-dashed p-8 text-center">
173173
<div {...getRootProps()}>
174174
<input {...getInputProps()} />
175175
<p>

0 commit comments

Comments
 (0)