File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ export async function POST(req: Request) {
51
51
}
52
52
}
53
53
const tags = await processAndAnalyze ( { imageURL } ) ;
54
+ console . log ( " tags:" , tags ) ;
55
+
54
56
const finalTags = await setTagsFromCurrentLists ( tags ) ;
55
57
console . log ( "Final tags:" , finalTags ) ;
56
58
const subject = finalTags [ "course-name" ] ;
@@ -276,6 +278,7 @@ async function setTagsFromCurrentLists(
276
278
if ( semesterSearchResult ) {
277
279
newTags . semester = semesterSearchResult as SemesterType ;
278
280
}
281
+ console . log ( tags . year , years )
279
282
const yearSearchResult = findMatch ( years , tags . year ) ;
280
283
if ( yearSearchResult ) {
281
284
newTags . year = yearSearchResult ;
@@ -285,6 +288,11 @@ async function setTagsFromCurrentLists(
285
288
}
286
289
function findMatch < T > ( arr : T [ ] , value : string | undefined ) : T | undefined {
287
290
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 ) ) ) ;
290
298
}
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ const Page = () => {
169
169
accept = { { "image/*" : [ ] , "application/pdf" : [ ] } }
170
170
>
171
171
{ ( { 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" >
173
173
< div { ...getRootProps ( ) } >
174
174
< input { ...getInputProps ( ) } />
175
175
< p >
You can’t perform that action at this time.
0 commit comments