mirror of
https://github.com/barthuijgen/factorio-sites.git
synced 2024-11-21 18:16:33 +02:00
Merge pull request #274 from barthuijgen/develop
Remove fbe data dependency
This commit is contained in:
commit
b67d873546
@ -1,42 +0,0 @@
|
||||
import { MultiSelect } from "react-multi-select-component";
|
||||
import { useFbeData } from "../hooks/fbe.hook";
|
||||
import styled from "@emotion/styled";
|
||||
|
||||
const MultiSelectStyled = styled(MultiSelect)`
|
||||
color: black;
|
||||
`;
|
||||
|
||||
interface Tag {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface TagsSelectProps {
|
||||
value: string[];
|
||||
onChange: (tags: string[]) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const TagsSelect: React.FC<TagsSelectProps> = ({ value, onChange, className }) => {
|
||||
const data = useFbeData();
|
||||
|
||||
if (!data) return null;
|
||||
|
||||
const TAGS = Object.keys(data.entities)
|
||||
.filter((key) => !key.startsWith("factorio-logo") && !key.startsWith("crash-site"))
|
||||
.map((key) => {
|
||||
const item = data.entities[key];
|
||||
return { value: item.name, label: item.name.replace(/[_-]/g, " ") };
|
||||
});
|
||||
|
||||
return (
|
||||
<MultiSelectStyled
|
||||
className={className}
|
||||
options={TAGS}
|
||||
value={value.map((value) => ({ value, label: value.replace(/[_-]/g, " ") }))}
|
||||
onChange={(tags: Tag[]) => onChange(tags.map((tag) => tag.value))}
|
||||
labelledBy="Select"
|
||||
hasSelectAll={false}
|
||||
/>
|
||||
);
|
||||
};
|
@ -13,7 +13,6 @@ import { useRouterQueryToHref } from "../hooks/query.hook";
|
||||
import { BlueprintTile } from "../components/BlueprintTile";
|
||||
import { Select } from "../components/Select";
|
||||
import { queryValueAsArray } from "../utils/query.utils";
|
||||
import { useFbeData } from "../hooks/fbe.hook";
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
@ -96,7 +95,6 @@ export const Index: NextPage<IndexProps> = ({
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [blueprints, setBlueprints] = useState<BlueprintPageWithUserFavorite[]>([]);
|
||||
const routerQueryToHref = useRouterQueryToHref();
|
||||
const data = useFbeData();
|
||||
const searchOptions =
|
||||
useFetch<{ entities: string[]; items: string[]; recipes: string[] }>("/api/searchoptions");
|
||||
|
||||
@ -108,8 +106,6 @@ export const Index: NextPage<IndexProps> = ({
|
||||
setBlueprints(blueprintsProp);
|
||||
}, [blueprintsProp]);
|
||||
|
||||
if (!data) return null;
|
||||
|
||||
const entityOptions = searchOptions.data?.entities || [];
|
||||
const itemOptions = searchOptions.data?.items || [];
|
||||
const recipeOptions = searchOptions.data?.recipes || [];
|
||||
|
Loading…
Reference in New Issue
Block a user