|
@@ -26,7 +26,7 @@ const CountriesScreen = () => {
|
|
const { data, refetch } = useGetSlowQuery(String(token));
|
|
const { data, refetch } = useGetSlowQuery(String(token));
|
|
const [megaSelectorVisible, setMegaSelectorVisible] = useState(false);
|
|
const [megaSelectorVisible, setMegaSelectorVisible] = useState(false);
|
|
const [selectedMega, setSelectedMega] = useState<{ name: string; id: number }>({
|
|
const [selectedMega, setSelectedMega] = useState<{ name: string; id: number }>({
|
|
- name: 'ALL',
|
|
|
|
|
|
+ name: 'ALL MEGAREGIONS',
|
|
id: -1
|
|
id: -1
|
|
});
|
|
});
|
|
const [total, setTotal] = useState({ slow: 0, visited: 0 });
|
|
const [total, setTotal] = useState({ slow: 0, visited: 0 });
|
|
@@ -51,10 +51,18 @@ const CountriesScreen = () => {
|
|
}, [slow]);
|
|
}, [slow]);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
+ const refetchData = async () => {
|
|
|
|
+ await refetch().then((res) => {
|
|
|
|
+ if (res.data) {
|
|
|
|
+ setSlow(res.data.slow);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
if (data && data.result === 'OK') {
|
|
if (data && data.result === 'OK') {
|
|
setSearch('');
|
|
setSearch('');
|
|
if (selectedMega.id === -1) {
|
|
if (selectedMega.id === -1) {
|
|
- refetch()
|
|
|
|
|
|
+ refetchData()
|
|
} else {
|
|
} else {
|
|
setSlow(data?.slow?.filter((item) => item.mega.includes(selectedMega.id)));
|
|
setSlow(data?.slow?.filter((item) => item.mega.includes(selectedMega.id)));
|
|
}
|
|
}
|
|
@@ -187,10 +195,10 @@ const CountriesScreen = () => {
|
|
style={styles.btnOption}
|
|
style={styles.btnOption}
|
|
onPress={() => {
|
|
onPress={() => {
|
|
setMegaSelectorVisible(false);
|
|
setMegaSelectorVisible(false);
|
|
- setSelectedMega({ name: 'ALL', id: -1 });
|
|
|
|
|
|
+ setSelectedMega({ name: 'ALL MEGAREGIONS', id: -1 });
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- <Text style={styles.btnOptionText}>ALL</Text>
|
|
|
|
|
|
+ <Text style={styles.btnOptionText}>ALL MEGAREGIONS</Text>
|
|
</TouchableOpacity>
|
|
</TouchableOpacity>
|
|
{data?.megaregions?.map((mega) => (
|
|
{data?.megaregions?.map((mega) => (
|
|
<TouchableOpacity
|
|
<TouchableOpacity
|