diff --git a/app/main/index.js b/app/main/index.js index 9e3ff207fd10df50d66336571f39046bd869b44e..b0c5c9667d9f46f3f0d248e05752ecf977b411ae 100644 --- a/app/main/index.js +++ b/app/main/index.js @@ -19,11 +19,13 @@ export default function Home() { const [favoriteLocations, setFavoriteLocations] = useState([]) const [foodTags, setFoodTags] = useState([]) const [gardenTags, setGardenTags] = useState([]) + const [clothesTags, setClothesTags] = useState([]) const [mainTags, setMainTags] = useState([]) const [activeOrder, setActiveOrder] = useState(null) const [loading, setLoading] = useState(true) const navigation = useNavigation() + // On pos change useEffect(() => { // Clear the stack if (navigation.canGoBack()) { @@ -33,11 +35,13 @@ export default function Home() { }); } + // Fetch data fetchLocations() fetchFavoriteLocations() fetchTagsFoodTags() fetchTagsGardenTags() fetchTagsMainTags() + fetchTagsClothesTags() fetchActiveOrder() }, [position]) @@ -214,6 +218,27 @@ export default function Home() { setGardenTags(data) } + // Fetch clothes and textile tags + async function fetchTagsClothesTags() { + let { data, error } = await supabase + .rpc('get_distinct_categories_of_closest_sales_locations_by_main_tag_', { + _lat: position.latitude, + _lng: position.longitude, + _max_distance: 10000, // 10 km + tag_name: 'Klær og tekstil' + }) + + if (error) { + console.log("Error fetching food tags:") + console.error(error) + Alert.alert('Error', 'Kunne ikke hente tags') + return + } + + //console.log(data) + setClothesTags(data) + } + // Fetch main tags async function fetchTagsMainTags() { let { data, error } = await supabase @@ -290,6 +315,12 @@ export default function Home() { <TagsCarousell tags={gardenTags} position={position} /> </> )} + {clothesTags.length > 0 && ( + <> + <Title title="Ny garderobe? 👗" /> + <TagsCarousell tags={clothesTags} position={position} /> + </> + )} <View style={{ height: 50 }}></View> </ScrollView> <LoadingScreen loading={loading} /> diff --git a/components/order/order-modal.js b/components/order/order-modal.js index 8dd4a6cbaf59a5cbef56732ec126e13fe962cd94..31d381d89cdf600cabbbee3429cc6c3f0334cabb 100644 --- a/components/order/order-modal.js +++ b/components/order/order-modal.js @@ -31,7 +31,7 @@ export default function OrderModal({ orderId, completed, locationId, isVisible, // Set the size of the animation to 0 when the animation is done setTimeout(() => { setPercentageSizeAnimation('0%'); - }, 1000); + }, 1500); } }, [isVisible]); diff --git a/components/tags-display.js b/components/tags-display.js index abe5d0b3fd10243b33eb610f36260ca0bc57700e..2e78e858eda4cbb0d5eb4d26bb092635f49c5304 100644 --- a/components/tags-display.js +++ b/components/tags-display.js @@ -50,9 +50,10 @@ const TagsBigButtons = ({ tags, position }) => { // Modify the category_url to file path based on the category_name tags.forEach(tag => { + console.log(tag.category_name); if (tag.category_name == "Mat og drikke") { tag.category_img = require('../assets/images/categories/food.jpg'); - console.log(tag.category_url); + //console.log(tag.category_url); } else if (tag.category_name === 'Klær og tekstil') { tag.category_img = require('../assets/images/categories/textile.jpg'); } else if (tag.category_name === 'Hage og blomster') {