import { View, Text, Pressable, ScrollView } from "react-native"; import { useLocalSearchParams, Link } from "expo-router"; import { useTheme } from "../../../components/theme"; import { useQuery } from "convex/react"; import { api } from "../../../convex/_generated/api"; import { CategoryGrid } from "../../../components/category-grid"; import { AdCard } from "../../../components/ad-card"; import { Loading } from "../../../components/ui/loading"; import { CATEGORIES, CATEGORY_EMOJI, getCategoryName } from "../../../lib/constants"; export default function ExploreScreen() { const theme = useTheme(); const { category } = useLocalSearchParams<{ category?: string }>(); const categories = useQuery(api.categories.list); const categoryAds = useQuery( api.ads.getByCategory, category ? { category } : "skip" ); const allAds = useQuery(api.ads.list); const displayCategories = categories ?? CATEGORIES; if (category) { const catName = getCategoryName(category); const catEmoji = CATEGORY_EMOJI[category] ?? "📋"; return ( ← Сите {catEmoji} {catName} {categoryAds === undefined ? ( ) : categoryAds.length === 0 ? ( Нема огласи во оваа категорија ) : ( {categoryAds.map((ad) => ( ))} )} ); } return ( Пребарувај по категорија Сите огласи {allAds === undefined ? ( ) : allAds.length === 0 ? ( Нема огласи ) : ( {allAds.map((ad) => ( ))} )} ); }