movie-web/src/views/SearchView.tsx

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-02-10 22:27:57 +01:00
import { WatchedMediaCard } from "components/media/WatchedMediaCard";
import { SearchBarInput } from "components/SearchBar";
import { MWMedia, MWMediaType, SearchProviders } from "scrapers";
2022-02-07 23:22:35 +01:00
import { useState } from "react";
2022-02-10 23:45:17 +01:00
import { ThinContainer } from "components/layout/ThinContainer";
import { SectionHeading } from "components/layout/SectionHeading";
import { Icons } from "components/Icon";
2022-02-07 23:22:35 +01:00
export function SearchView() {
const [results, setResults] = useState<MWMedia[]>([]);
const [search, setSearch] = useState("");
async function runSearch() {
2022-02-10 23:45:17 +01:00
const results = await SearchProviders({
type: MWMediaType.MOVIE,
searchQuery: search,
});
2022-02-07 23:22:35 +01:00
setResults(results);
}
return (
2022-02-10 23:45:17 +01:00
<ThinContainer>
<div className="mt-36 text-center space-y-16">
<div className="space-y-4">
<p className="font-bold text-bink">
Because watching legally is boring
</p>
<h1 className="text-4xl font-bold">
What movie do you want to watch?
</h1>
</div>
<SearchBarInput
onChange={setSearch}
value={search}
onClick={runSearch}
placeholder="What movie do you want to watch?"
/>
</div>
<SectionHeading title="Yoink" icon={Icons.SEARCH}>
{results.map((v) => (
<WatchedMediaCard media={v} />
))}
</SectionHeading>
</ThinContainer>
);
2022-02-07 23:22:35 +01:00
}