import React, { useEffect, useState } from 'react'; import { FlatList, Text, TouchableOpacity, View } from 'react-native'; import { Image } from 'expo-image'; import { Header, HorizontalTabView, Loading, PageWrapper } from '../../../../components'; import { getMastersByType, getUNMastersTypes } from '../../../../database/unMastersService'; import { API_HOST } from '../../../../constants'; import { UNMastersListStyles } from './styles'; import ArrowUpWideIcon from '../../../../../assets/icons/arrow-up-wide-short.svg'; import type { Master } from '../../../../database/unMastersService'; const UNMastersScreen = () => { const [index, setIndex] = useState(0); const [routes, setRoutes] = useState<{ key: string; title: string }[]>([]); const [loading, setLoading] = useState(true); useEffect(() => { const types = getUNMastersTypes(); const parseRoutes = types?.map((item) => ({ key: item.type.toString(), title: item.name })); setRoutes(parseRoutes || []); setLoading(false); }, []); if (loading) return ; return (
( )} /> ); }; const UNMastersList = React.memo(({ type }: { type: string }) => { const [isLoading, setIsLoading] = useState(true); const [masters, setMasters] = useState([]); useEffect(() => { const fetchType = async () => { const data = getMastersByType(Number(type) || 1); setMasters(data); }; fetchType(); setIsLoading(false); }, [type]); if (isLoading) return ; const renderItem = ({ item }: { item: Master }) => { return ( {item.full_name} Born: {item.born} / Age when done: {item.age} / {item.origin2_flag && item.origin2_flag !== item.origin1_flag ? ( ) : null} Year / final country: {item.final_year} ); }; return ( item.id.toString()} showsVerticalScrollIndicator={false} /> ); }); export default UNMastersScreen;