import { ScrollView, View } from "react-native"; import { useQuestions } from "@/api"; import { QuestionResponse } from "@/api/types"; import useTaxonomyContext from "@/components/providers/taxonomy-provider/hook"; import Question from "@/components/question"; 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"; export default function QuestionsScreen() { const [category, setCategory] = useState(undefined); const [page, setPage] = useState(1); const { categories } = useTaxonomyContext(); const scrollRef = useRef(null); const { data: questionsPagination, isLoading } = useQuestions({ page: page, category_id: category }); const categoryOptions = getCategoryOptions(categories); const handleChangeCategory = (value: string) => { setPage(1); if(value === "all") setCategory(undefined); else setCategory(+value); } return ( Questions pagination={questionsPagination} renderItem={(item) => ( router.push(`/questions/${item.id}`)} withCategory={true} /> )} skeleton={} currentPage={page} setCurrentPage={setPage} scrollView={scrollRef} isLoadingPage={isLoading} /> ); }