Skip to content

Commit

Permalink
feat: Remove movie and series categories
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-oki committed Oct 21, 2024
1 parent 2894d5e commit 41328d8
Showing 1 changed file with 10 additions and 45 deletions.
55 changes: 10 additions & 45 deletions frontend/src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Select,
Text,
} from "@mantine/core";
import { ComboboxItemGroup } from "@mantine/core/lib/components/Combobox/Combobox.types";
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useServerSearch } from "@/apis/hooks";
Expand Down Expand Up @@ -68,25 +67,16 @@ const optionsFilter: OptionsFilter = ({ options, search }) => {
const lowercaseSearch = search.toLowerCase();
const trimmedSearch = search.trim();

(options as ComboboxItemGroup[]).map((c) => {
return {
group: c.group,
items: c.items.filter((option) => {
const o = option as ComboboxItem;

return (
o.label.toLowerCase().includes(lowercaseSearch) ||
o.label
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.includes(trimmedSearch)
);
}),
};
return (options as ComboboxItem[]).filter((option) => {
return (
option.label.toLowerCase().includes(lowercaseSearch) ||
option.label
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.includes(trimmedSearch)
);
});

return options;
};

const Search: FunctionComponent = () => {
Expand All @@ -95,31 +85,6 @@ const Search: FunctionComponent = () => {

const results = useSearch(query);

const groups = [
{
group: "Series",
items: results
.filter((r) => r.type === "show")
.map((r) => {
return {
label: r.label,
value: r.value,
};
}),
},
{
group: "Movies",
items: results
.filter((r) => r.type === "movie")
.map((r) => {
return {
label: r.label,
value: r.value,
};
}),
},
];

return (
<Select
placeholder="Search"
Expand All @@ -130,7 +95,7 @@ const Search: FunctionComponent = () => {
searchable
scrollAreaProps={{ type: "auto" }}
maxDropdownHeight={400}
data={groups}
data={results}
value={query}
onSearchChange={(a) => {
setQuery(a);
Expand Down

0 comments on commit 41328d8

Please sign in to comment.