forked from miurla/morphic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
video-search-section.tsx
35 lines (32 loc) · 1.06 KB
/
video-search-section.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use client'
import { DefaultSkeleton } from './default-skeleton'
import { Section } from './section'
import type { SerperSearchResults } from '@/lib/types'
import { StreamableValue, useStreamableValue } from 'ai/rsc'
import { VideoSearchResults } from './video-search-results'
import { ToolBadge } from './tool-badge'
export type VideoSearchSectionProps = {
result?: StreamableValue<string>
}
export function VideoSearchSection({ result }: VideoSearchSectionProps) {
const [data, error, pending] = useStreamableValue(result)
const searchResults: SerperSearchResults = data ? JSON.parse(data) : undefined
return (
<div>
{!pending && data ? (
<>
<Section size="sm" className="pt-2 pb-0">
<ToolBadge tool="search">{`${searchResults.searchParameters.q}`}</ToolBadge>
</Section>
<Section title="Videos">
<VideoSearchResults results={searchResults} />
</Section>
</>
) : (
<Section className="pt-2 pb-0">
<DefaultSkeleton />
</Section>
)}
</div>
)
}