|
@@ -1,20 +1,20 @@
|
|
|
import React, { FC, useEffect, useState } from 'react';
|
|
|
-import { Text, TouchableOpacity, View, Image, StyleSheet } from 'react-native';
|
|
|
+import { View, StyleSheet } from 'react-native';
|
|
|
import { NavigationProp, useFocusEffect } from '@react-navigation/native';
|
|
|
import { storage, StoreType } from 'src/storage';
|
|
|
-import { PageWrapper, Header, Input, AvatarWithInitials, WarningModal } from 'src/components';
|
|
|
+import { PageWrapper, Header, Input, WarningModal } from 'src/components';
|
|
|
import { usePostGetGroupMembersQuery, usePostGetGroupSettingsQuery } from '@api/chat';
|
|
|
import { Colors } from 'src/theme';
|
|
|
-import { API_HOST } from 'src/constants';
|
|
|
-import { getFontSize } from 'src/utils';
|
|
|
-import { SheetManager } from 'react-native-actions-sheet';
|
|
|
import UserOptionsModal from '../Components/UserOptionsModal';
|
|
|
-import { chatStyles } from '../Components/styles';
|
|
|
import { FlashList } from '@shopify/flash-list';
|
|
|
|
|
|
import SearchIcon from 'assets/icons/search.svg';
|
|
|
-import DotsIcon from 'assets/icons/messages/dots-vertical.svg';
|
|
|
-import { NAVIGATION_PAGES } from 'src/types';
|
|
|
+import { dataRanking } from '../../TravellersScreen/utils';
|
|
|
+import { RankingDropdown } from '../../TravellersScreen/utils/types';
|
|
|
+import { FilterButton, FilterModal } from '../../TravellersScreen/Components/FilterModal';
|
|
|
+import { usePostGetCountriesRanking } from '@api/ranking';
|
|
|
+import { Profile } from '../Components/Profile';
|
|
|
+import { applyModalSort } from '../applySort';
|
|
|
|
|
|
type Props = {
|
|
|
navigation: NavigationProp<any>;
|
|
@@ -23,7 +23,6 @@ type Props = {
|
|
|
|
|
|
const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
|
- const currentUserId = storage.get('uid', StoreType.STRING) as string;
|
|
|
const { groupToken, canChangeAdmin } = route.params;
|
|
|
|
|
|
const [modalState, setModalState] = useState({
|
|
@@ -41,6 +40,10 @@ const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
groupToken,
|
|
|
true
|
|
|
);
|
|
|
+ const { data: masterCountries } = usePostGetCountriesRanking();
|
|
|
+
|
|
|
+ const [confirmedValueRanking, setConfirmedValueRanking] = useState<RankingDropdown | null>();
|
|
|
+ const [isModalVisible, setModalVisible] = useState(false);
|
|
|
|
|
|
useFocusEffect(() => {
|
|
|
navigation.getParent()?.setOptions({
|
|
@@ -51,7 +54,7 @@ const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
});
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (members && members.settings) {
|
|
|
+ if (members && members.settings && members.settings) {
|
|
|
setFilteredData(members.settings);
|
|
|
}
|
|
|
}, [members]);
|
|
@@ -60,7 +63,11 @@ const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
if (text && members) {
|
|
|
const searchData =
|
|
|
members?.settings?.filter((item: any) => {
|
|
|
- const itemData = item.name ? item.name.toLowerCase() : ''.toLowerCase();
|
|
|
+ const itemData = item.ranking_data
|
|
|
+ ? item.ranking_data.first_name.toLowerCase() +
|
|
|
+ ' ' +
|
|
|
+ item.ranking_data.last_name.toLowerCase()
|
|
|
+ : ''.toLowerCase();
|
|
|
const textData = text.toLowerCase();
|
|
|
return itemData.indexOf(textData) > -1;
|
|
|
}) ?? [];
|
|
@@ -72,70 +79,12 @@ const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const renderItem = ({ item }: { item: any }) => (
|
|
|
- <TouchableOpacity
|
|
|
- onPress={() =>
|
|
|
- navigation.navigate(
|
|
|
- ...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: item.uid }] as never)
|
|
|
- )
|
|
|
- }
|
|
|
- style={styles.userItem}
|
|
|
- >
|
|
|
- {item.avatar ? (
|
|
|
- <Image source={{ uri: API_HOST + item.avatar }} style={chatStyles.avatar} />
|
|
|
- ) : (
|
|
|
- <AvatarWithInitials
|
|
|
- text={item.name?.split(' ')[0][0] + (item.name?.split(' ')[1][0] ?? '')}
|
|
|
- flag={API_HOST + item?.flag1}
|
|
|
- size={36}
|
|
|
- fontSize={12}
|
|
|
- borderColor={Colors.LIGHT_GRAY}
|
|
|
- borderWidth={1}
|
|
|
- />
|
|
|
- )}
|
|
|
-
|
|
|
- <View style={chatStyles.textContainer}>
|
|
|
- <Text style={chatStyles.name}>{item.name}</Text>
|
|
|
- </View>
|
|
|
- {item.admin === 1 && (
|
|
|
- <Text
|
|
|
- style={{
|
|
|
- fontSize: getFontSize(10),
|
|
|
- fontWeight: '600',
|
|
|
- color: Colors.LIGHT_GRAY
|
|
|
- }}
|
|
|
- >
|
|
|
- Admin
|
|
|
- </Text>
|
|
|
- )}
|
|
|
- {item.uid !== +currentUserId && (
|
|
|
- <TouchableOpacity
|
|
|
- style={{ padding: 6 }}
|
|
|
- onPress={() =>
|
|
|
- SheetManager.show('user-options-modal', {
|
|
|
- payload: {
|
|
|
- admin: item.admin,
|
|
|
- uid: item.uid,
|
|
|
- name: item.name,
|
|
|
- canChangeAdmin,
|
|
|
- token,
|
|
|
- groupToken,
|
|
|
- refetch,
|
|
|
- refetchMembers,
|
|
|
- setIsWarningVisible: setModalState
|
|
|
- } as any
|
|
|
- })
|
|
|
- }
|
|
|
- >
|
|
|
- <DotsIcon />
|
|
|
- </TouchableOpacity>
|
|
|
- )}
|
|
|
- </TouchableOpacity>
|
|
|
- );
|
|
|
-
|
|
|
return (
|
|
|
<PageWrapper>
|
|
|
- <Header label="Nomads" />
|
|
|
+ <Header
|
|
|
+ label="Nomads"
|
|
|
+ rightElement={<FilterButton onPress={() => setModalVisible(!isModalVisible)} />}
|
|
|
+ />
|
|
|
<View style={styles.container}>
|
|
|
<Input
|
|
|
inputMode={'search'}
|
|
@@ -151,13 +100,63 @@ const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
itemVisiblePercentThreshold: 50,
|
|
|
minimumViewTime: 1000
|
|
|
}}
|
|
|
+ estimatedItemSize={50}
|
|
|
data={filteredData || []}
|
|
|
- renderItem={renderItem}
|
|
|
+ renderItem={({ item, index }) => (
|
|
|
+ <Profile
|
|
|
+ admin={item.admin}
|
|
|
+ canChangeAdmin={canChangeAdmin}
|
|
|
+ groupToken={groupToken}
|
|
|
+ refetch={refetch}
|
|
|
+ refetchMembers={refetchMembers}
|
|
|
+ setIsWarningVisible={setModalState}
|
|
|
+ userId={item.uid}
|
|
|
+ key={index}
|
|
|
+ index={index}
|
|
|
+ first_name={item.ranking_data?.first_name ?? item.name}
|
|
|
+ last_name={item.ranking_data?.last_name ?? ''}
|
|
|
+ avatar={
|
|
|
+ item.ranking_data?.avatar
|
|
|
+ ? '/img/avatars/' + item.ranking_data?.avatar
|
|
|
+ : (item.avatar ?? null)
|
|
|
+ }
|
|
|
+ date_of_birth={item.ranking_data?.age}
|
|
|
+ homebase_flag={'/img/flags_new/' + item.ranking_data?.flag1}
|
|
|
+ homebase2_flag={
|
|
|
+ item.ranking_data?.flag2 ? '/img/flags_new/' + item.ranking_data?.flag2 : null
|
|
|
+ }
|
|
|
+ score={[
|
|
|
+ item.ranking_data?.score_nm ?? 1,
|
|
|
+ item.ranking_data?.score_un ?? 1,
|
|
|
+ item.ranking_data?.score_unp ?? 1,
|
|
|
+ item.ranking_data?.score_dare,
|
|
|
+ item.ranking_data?.score_tcc,
|
|
|
+ item.ranking_data?.score_deep,
|
|
|
+ item.ranking_data?.score_slow,
|
|
|
+ item.ranking_data?.score_yes,
|
|
|
+ item.ranking_data?.score_kye,
|
|
|
+ item.ranking_data?.score_whs,
|
|
|
+ item.ranking_data?.score_tbt
|
|
|
+ ]}
|
|
|
+ active_score={
|
|
|
+ confirmedValueRanking ? confirmedValueRanking.value - 1 : dataRanking[0].value - 1
|
|
|
+ }
|
|
|
+ tbt_score={item.ranking_data?.score_tbt}
|
|
|
+ tbt_rank={item.ranking_data?.rank_tbt}
|
|
|
+ badge_tbt={item.ranking_data?.badge_tbt}
|
|
|
+ badge_1281={item.ranking_data?.badge_1281}
|
|
|
+ badge_un={item.ranking_data?.badge_un}
|
|
|
+ badge_un_25={item.ranking_data?.badge_un_25}
|
|
|
+ badge_un_50={item.ranking_data?.badge_un_50}
|
|
|
+ badge_un_75={item.ranking_data?.badge_un_75}
|
|
|
+ badge_un_100={item.ranking_data?.badge_un_100}
|
|
|
+ badge_un_150={item.ranking_data?.badge_un_150}
|
|
|
+ auth={item.ranking_data?.auth}
|
|
|
+ />
|
|
|
+ )}
|
|
|
keyExtractor={(item) => item.uid.toString()}
|
|
|
- estimatedItemSize={100}
|
|
|
- extraData={filteredData}
|
|
|
+ contentContainerStyle={{ paddingBottom: 16, paddingTop: 8 }}
|
|
|
showsVerticalScrollIndicator={false}
|
|
|
- contentContainerStyle={{ paddingBottom: 16 }}
|
|
|
/>
|
|
|
</View>
|
|
|
|
|
@@ -171,6 +170,23 @@ const MembersListScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
title={modalState.title}
|
|
|
/>
|
|
|
<UserOptionsModal />
|
|
|
+ <FilterModal
|
|
|
+ isModalVisible={isModalVisible}
|
|
|
+ setModalVisible={(value) => setModalVisible(value)}
|
|
|
+ applyFilter={(filterAge, filterRanking, filterCountry) => {
|
|
|
+ setConfirmedValueRanking(filterRanking);
|
|
|
+ setFilteredData(
|
|
|
+ applyModalSort(
|
|
|
+ (members?.settings as any) ?? [],
|
|
|
+ filterAge,
|
|
|
+ filterRanking ?? dataRanking[0],
|
|
|
+ filterCountry
|
|
|
+ )
|
|
|
+ );
|
|
|
+ setModalVisible(false);
|
|
|
+ }}
|
|
|
+ countriesData={masterCountries ? masterCountries.data : []}
|
|
|
+ />
|
|
|
</PageWrapper>
|
|
|
);
|
|
|
};
|