33import { useState } from 'react' ;
44import QuestionForm from '@/components/QuestionForm' ;
55import VideoList , { type VideoDocument } from '@/components/VideoList' ;
6+ import Modal from '@/components/Modal' ;
7+ import UploadButton from '@/components/UploadButton' ;
8+ import VideoForm from '@/components/VideoForm' ;
69
710export default function Home ( ) {
811 const [ videos , setVideos ] = useState < VideoDocument [ ] > ( [ ] ) ;
12+ const [ showModal , setShowModal ] = useState ( false ) ;
13+
14+ const handleSubmit = async ( videos : string [ ] ) => {
15+ // API call with the videos URLs
16+
17+ await fetch ( `/api/upload` , {
18+ method : 'POST' ,
19+ body : JSON . stringify ( { videos } ) ,
20+ } ) ;
21+
22+ setShowModal ( false ) ;
23+ } ;
924
1025 const handleSearch = async ( question : string ) => {
1126 // Replace with your API call
@@ -15,14 +30,29 @@ export default function Home() {
1530 } ;
1631
1732 return (
18- < main className = "flex min-h-screen flex-col items-center justify-between p-24" >
19- < div className = "container mx-auto p-4" >
20- < h1 className = "text-3xl md:text-4xl font-bold text-center text-indigo-600 my-8" >
21- Search for videos... semantically!
22- </ h1 >
23- < QuestionForm onSubmit = { handleSearch } />
24- < VideoList videos = { videos } />
25- </ div >
26- </ main >
33+ < >
34+ < main className = "flex min-h-screen flex-col items-center justify-between p-24" >
35+ < div className = "container mx-auto p-4" >
36+ < h1 className = "text-3xl md:text-4xl font-bold text-center text-indigo-600 my-8" >
37+ Search for videos... semantically!
38+ </ h1 >
39+ < QuestionForm onSubmit = { handleSearch } />
40+ < VideoList videos = { videos } />
41+ </ div >
42+ </ main >
43+
44+ < Modal
45+ show = { showModal }
46+ onClose = { ( ) => {
47+ setShowModal ( false ) ;
48+ } } >
49+ < VideoForm onSubmit = { handleSubmit } />
50+ </ Modal >
51+ < UploadButton
52+ onClick = { ( ) => {
53+ setShowModal ( true ) ;
54+ } }
55+ />
56+ </ >
2757 ) ;
2858}
0 commit comments