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-13 18:49:03 +01:00
|
|
|
import { Loading } from "components/layout/Loading";
|
|
|
|
import { Tagline } from "components/Text/Tagline";
|
|
|
|
import { Title } from "components/Text/Title";
|
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">
|
2022-02-13 18:49:03 +01:00
|
|
|
<Tagline>Because watching legally is boring</Tagline>
|
|
|
|
<Title>What movie do you want to watch?</Title>
|
2022-02-10 23:45:17 +01:00
|
|
|
</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>
|
2022-02-13 18:49:03 +01:00
|
|
|
<Loading />
|
2022-02-10 23:45:17 +01:00
|
|
|
</ThinContainer>
|
|
|
|
);
|
2022-02-07 23:22:35 +01:00
|
|
|
}
|