added error boundary, fixed selection and layout

This commit is contained in:
2023-06-03 19:52:15 +02:00
parent 4114ccb678
commit bd49129273
8 changed files with 157 additions and 86 deletions
+9 -9
View File
@@ -4,24 +4,24 @@ import { SelectWrapper } from '../App.style';
import { Category } from '../Types';
type Props = {
category: number;
categoryID: number;
categoryList: Array<Category>;
setCategory: (category: number) => void;
setCategoryID: (categoryID: number) => void;
};
const SelectCategory = ({ category, categoryList, setCategory }: Props) => {
const SelectCategory = ({ categoryID, categoryList, setCategoryID }: Props) => {
return (
<SelectWrapper
value={category}
value={categoryID}
onChange={(e: React.ChangeEvent<{ value: unknown }>) => {
e.preventDefault();
setCategory(e.target.value as number);
setCategoryID(e.target.value as number);
}}
>
<option value={1}>Any Category</option>
{categoryList.map((cat) => (
<option value={cat.id} key={cat.id}>
{cat.name}
<option value={1}>Random Category</option>
{categoryList.map((category) => (
<option value={category.id} key={category.id}>
{category.name.replace(/Entertainment: |Science: /g, '')}
</option>
))}
</SelectWrapper>