import { useTests } from '@/api/tests'; import { TestResponse } from '@/api/types'; import useTaxonomyContext from '@/components/providers/taxonomy-provider/hook'; import Test from '@/components/test'; import Content from '@/components/ui/content'; import CustomSelect from '@/components/ui/custom-select'; import PaginationList from '@/components/ui/pagination-list'; import { ThemedText } from '@/components/ui/themed-text'; import getCategoryOptions from '@/utils/get-category-options'; import { router } from 'expo-router'; import { useRef, useState } from 'react'; import { ScrollView, View } from 'react-native'; export default function TestsScreen() { const { categories } = useTaxonomyContext(); const [category, setCategory] = useState(undefined); const [page, setPage] = useState(1); const { data: testsPagination, isLoading } = useTests({ page: page, category_id: category }); const scrollRef = useRef(null); const categoryOptions = getCategoryOptions(categories); const handleChangeCategory = (value: string) => { setPage(1); if(value === "all") setCategory(undefined); else setCategory(+value); } return ( Tests pagination={testsPagination} isLoadingPage={isLoading} renderItem={(item) => ( router.push(`/tests/${item.id}`)} /> )} skeleton={} currentPage={page} setCurrentPage={setPage} scrollView={scrollRef} /> ); }