Skip to content

Commit 03c63ad

Browse files
committed
cleaning up the UI, adding title, description, and thumbnail for video metadata
1 parent 406a565 commit 03c63ad

File tree

15 files changed

+726
-75
lines changed

15 files changed

+726
-75
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ dist
77

88
.vscode
99
.env
10-
.env.*
10+
.env.*
11+
12+
.credentials

app/next.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
/** @type {import('next').NextConfig} */
2-
const nextConfig = {}
2+
const nextConfig = {
3+
images: {
4+
remotePatterns: [
5+
{
6+
protocol: 'https',
7+
hostname: 'i.ytimg.com',
8+
},
9+
],
10+
},
11+
};
312

4-
module.exports = nextConfig
13+
module.exports = nextConfig;

app/src/app/page.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
"use client";
1+
'use client';
22

3+
import { useState } from 'react';
34
import QuestionForm from '@/components/QuestionForm';
5+
import VideoList, { type VideoDocument } from '@/components/VideoList';
6+
7+
const SEARCH_API = `http://localhost:3001/api/videos/search`;
48

59
export default function Home() {
10+
const [videos, setVideos] = useState<VideoDocument[]>([]);
11+
12+
const handleSearch = async (question: string) => {
13+
// Replace with your API call
14+
const response = await fetch(`${SEARCH_API}?question=${question}`);
15+
const data: { results: VideoDocument[] } = await response.json();
16+
setVideos(data.results);
17+
};
18+
619
return (
720
<main className="flex min-h-screen flex-col items-center justify-between p-24">
8-
<QuestionForm onSubmit={(question) => {
9-
console.log(question);
10-
}} />
21+
<div className="container mx-auto p-4">
22+
<QuestionForm onSubmit={handleSearch} />
23+
<VideoList videos={videos} />
24+
</div>
1125
</main>
1226
);
1327
}

app/src/components/QuestionForm.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ export default function QuestionForm({ onSubmit }: QuestionFormProps) {
1717
/* and other goodies */
1818
}) => (
1919
<Form>
20-
<Field as="textarea" name="question" />
21-
<button type="submit" disabled={isSubmitting}>
22-
Submit
23-
</button>
20+
<Field as="input" name="question" className="w-full p-4 border rounded shadow-lg focus:outline-none focus:ring-2 focus:ring-indigo-600" />
2421
</Form>
2522
)}
2623
</Formik>

app/src/components/VideoList.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import Image from 'next/image';
2+
3+
export interface VideoDocument {
4+
pageContent: string;
5+
metadata: {
6+
id: string;
7+
link: string;
8+
title: string;
9+
description: string;
10+
thumbnail: string;
11+
};
12+
}
13+
14+
const VideoList = ({ videos }: { videos: VideoDocument[] }) => {
15+
return (
16+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mt-8">
17+
{videos.map(({ metadata }) => (
18+
<div
19+
key={metadata.id}
20+
className="max-w-sm rounded overflow-hidden shadow-lg">
21+
<div className="w-full">
22+
<Image
23+
src={metadata.thumbnail}
24+
alt={metadata.title}
25+
layout="responsive"
26+
width={1280}
27+
height={720}
28+
/>
29+
</div>
30+
<div className="px-6 py-4">
31+
<a
32+
href={metadata.link}
33+
target="_blank"
34+
rel="noopener noreferrer"
35+
className="font-bold text-xl mb-2 hover:text-indigo-600">
36+
{metadata.title}
37+
</a>
38+
</div>
39+
</div>
40+
))}
41+
</div>
42+
);
43+
};
44+
45+
export default VideoList;

0 commit comments

Comments
 (0)