1
0
mirror of https://github.com/barthuijgen/factorio-sites.git synced 2024-11-24 08:52:36 +02:00

Merge pull request #274 from barthuijgen/develop

Remove fbe data dependency
This commit is contained in:
Bart 2021-12-13 13:53:52 +01:00 committed by GitHub
commit b67d873546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 46 deletions

View File

@ -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}
/>
);
};

View File

@ -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 || [];