Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes #24

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.1.5",
"@react-aria/interactions": "^3.22.5",
"@supabase/supabase-js": "^2.47.8",
"emailjs-com": "^3.2.0",
"native-base": "^3.4.0",
"react": "^18.3.1",
Expand Down
69 changes: 52 additions & 17 deletions src/components/CategoryMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Box, Text, Pressable, Image, ScrollView, VStack, HStack } from "native-base";
import {
Box,
Text,
Pressable,
Image,
ScrollView,
VStack,
HStack,
} from "native-base";
import { useState } from "react";
import { categories } from "../data/categories";

Expand All @@ -14,17 +22,26 @@ interface CategoryMenuProps {
onSelectItem: (item: ClothingItem) => void;
}

export default function CategoryMenu({ categories, onSelectItem }: CategoryMenuProps) {
export default function CategoryMenu({
categories,
onSelectItem,
}: CategoryMenuProps) {
const [selectedCategory, setSelectedCategory] = useState(categories[0].name);
const [selectedSubcategory, setSelectedSubcategory] = useState(categories[0].subcategories[0].name);
const [selectedSubcategory, setSelectedSubcategory] = useState(
categories[0].subcategories[0].name
);

const currentCategory = categories.find(cat => cat.name === selectedCategory);
const currentSubcategory = currentCategory?.subcategories.find(sub => sub.name === selectedSubcategory);
const currentCategory = categories.find(
(cat) => cat.name === selectedCategory
);
const currentSubcategory = currentCategory?.subcategories.find(
(sub) => sub.name === selectedSubcategory
);

return (
<VStack
space={2}
bg="primary.200"
<VStack
space={2}
bg="primary.200"
borderColor="primary.100"
borderWidth={1}
borderRadius="md"
Expand All @@ -43,15 +60,23 @@ export default function CategoryMenu({ categories, onSelectItem }: CategoryMenuP
}}
>
<Box
bg={selectedCategory === category.name ? "primary.100" : "primary.200"}
bg={
selectedCategory === category.name
? "primary.100"
: "primary.200"
}
px={3}
py={1}
borderRadius="md"
borderWidth={1}
borderColor="primary.100"
>
<Text
color={selectedCategory === category.name ? "primary.200" : "primary.100"}
color={
selectedCategory === category.name
? "primary.200"
: "primary.100"
}
fontWeight="medium"
fontSize="sm"
>
Expand All @@ -75,15 +100,23 @@ export default function CategoryMenu({ categories, onSelectItem }: CategoryMenuP
onPress={() => setSelectedSubcategory(subcategory.name)}
>
<Box
bg={selectedSubcategory === subcategory.name ? "primary.100" : "primary.200"}
bg={
selectedSubcategory === subcategory.name
? "primary.100"
: "primary.200"
}
px={3}
py={1}
borderRadius="md"
borderWidth={1}
borderColor="primary.100"
>
<Text
color={selectedSubcategory === subcategory.name ? "primary.200" : "primary.100"}
color={
selectedSubcategory === subcategory.name
? "primary.200"
: "primary.100"
}
fontWeight="medium"
fontSize="sm"
>
Expand All @@ -108,11 +141,13 @@ export default function CategoryMenu({ categories, onSelectItem }: CategoryMenuP
{currentSubcategory?.items.map((item, index) => (
<Pressable
key={index}
onPress={() => onSelectItem({
...item,
category: selectedCategory,
subcategory: selectedSubcategory
})}
onPress={() =>
onSelectItem({
...item,
category: selectedCategory,
subcategory: selectedSubcategory,
})
}
>
<Box
m={1}
Expand Down
2 changes: 1 addition & 1 deletion src/components/popUpGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PopUpGallery: React.FC<PopUpGalleryProps> = ({
{galleryLinks && galleryLinks.length > 0 ? (
<FlatList
data={galleryLinks}
keyExtractor={(item, index) => index.toString()}
keyExtractor={(index) => index.toString()}
renderItem={({ item }) => (
<Image source={{ uri: item }} style={styles.image} />
)}
Expand Down