|
@@ -132,6 +132,8 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
const [isWarningModalVisible, setIsWarningModalVisible] = useState<boolean>(false);
|
|
const [isWarningModalVisible, setIsWarningModalVisible] = useState<boolean>(false);
|
|
|
|
|
|
const { data: photosData } = useGetPhotosForRegionQuery(nmId ?? 0, nmId !== null);
|
|
const { data: photosData } = useGetPhotosForRegionQuery(nmId ?? 0, nmId !== null);
|
|
|
|
+ const { mutateAsync: getPhotosForRegion } = usePostGetPhotosForRegionMutation();
|
|
|
|
+ const [regions, setRegions] = useState<any[]>([]);
|
|
|
|
|
|
const [modalInfo, setModalInfo] = useState({
|
|
const [modalInfo, setModalInfo] = useState({
|
|
visible: false,
|
|
visible: false,
|
|
@@ -142,6 +144,53 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
action: () => {}
|
|
action: () => {}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (regions && regions.length > 0 && event && event.type === 4) {
|
|
|
|
+ handleGetPhotosForAllRegions(regions);
|
|
|
|
+ } else {
|
|
|
|
+ setPhotosForRegion([]);
|
|
|
|
+ }
|
|
|
|
+ }, [regions, event]);
|
|
|
|
+
|
|
|
|
+ const handleGetPhotosForAllRegions = useCallback(
|
|
|
|
+ async (regionsArray: any[]) => {
|
|
|
|
+ if (!regionsArray || regionsArray.length === 0) {
|
|
|
|
+ setPhotosForRegion([]);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const allPhotos: any[] = [];
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ for (const region of regionsArray) {
|
|
|
|
+ await getPhotosForRegion(
|
|
|
|
+ { region_id: region },
|
|
|
|
+ {
|
|
|
|
+ onSuccess: (res) => {
|
|
|
|
+ if (res.photos && res.photos.length > 0) {
|
|
|
|
+ allPhotos.push(...res.photos);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onError: (error) => {
|
|
|
|
+ console.log(`Error loading photos for region ${region}:`, error);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setPhotosForRegion(
|
|
|
|
+ allPhotos.map((item) => ({
|
|
|
|
+ uriSmall: `${API_HOST}/ajax/pic/${item}/small`,
|
|
|
|
+ uri: `${API_HOST}/ajax/pic/${item}/full`
|
|
|
|
+ }))
|
|
|
|
+ );
|
|
|
|
+ } catch (error) {
|
|
|
|
+ setPhotosForRegion([]);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ [getPhotosForRegion, token]
|
|
|
|
+ );
|
|
|
|
+
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
photosData &&
|
|
photosData &&
|
|
setPhotosForRegion(
|
|
setPhotosForRegion(
|
|
@@ -157,12 +206,16 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
setEvent(data.data);
|
|
setEvent(data.data);
|
|
setJoined(data.data.joined);
|
|
setJoined(data.data.joined);
|
|
setNmId(data.data.settings.nm_region ?? null);
|
|
setNmId(data.data.settings.nm_region ?? null);
|
|
|
|
+ if (data.data.settings.nm_regions && data.data.type === 4) {
|
|
|
|
+ const ids = JSON.parse(data.data.settings.nm_regions);
|
|
|
|
+ setRegions(ids);
|
|
|
|
+ }
|
|
|
|
|
|
setMyFiles(data.data.files ?? []);
|
|
setMyFiles(data.data.files ?? []);
|
|
setPhotos(data.data.photos);
|
|
setPhotos(data.data.photos);
|
|
|
|
|
|
const partisipantsWidth = contentWidth / 2;
|
|
const partisipantsWidth = contentWidth / 2;
|
|
- setMaxVisibleParticipants(Math.floor(partisipantsWidth / 22));
|
|
|
|
|
|
+ setMaxVisibleParticipants(Math.floor(partisipantsWidth / 24));
|
|
setMaxVisibleParticipantsWithGap(Math.floor(partisipantsWidth / 32));
|
|
setMaxVisibleParticipantsWithGap(Math.floor(partisipantsWidth / 32));
|
|
setFilteredParticipants(
|
|
setFilteredParticipants(
|
|
data.data.type === 4 ? data.data.participants_approved_data : data.data.participants_data
|
|
data.data.type === 4 ? data.data.participants_approved_data : data.data.participants_data
|
|
@@ -622,7 +675,7 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
flex: 1
|
|
flex: 1
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- {dateFrom} -{' '}
|
|
|
|
|
|
+ {dateFrom}{' '}
|
|
</Text>
|
|
</Text>
|
|
<Text
|
|
<Text
|
|
style={{
|
|
style={{
|
|
@@ -647,7 +700,7 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
flex: 1
|
|
flex: 1
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- {moment(event.settings.date_from, 'YYYY-MM-DD').format('DD MMMM YYYY')} -{' '}
|
|
|
|
|
|
+ {moment(event.settings.date_from, 'YYYY-MM-DD').format('DD MMMM YYYY')}{' '}
|
|
</Text>
|
|
</Text>
|
|
<Text
|
|
<Text
|
|
style={{
|
|
style={{
|
|
@@ -800,9 +853,7 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
.catch((err) => console.error('Error opening event location', err));
|
|
.catch((err) => console.error('Error opening event location', err));
|
|
};
|
|
};
|
|
|
|
|
|
- const photoUrl = event.photo
|
|
|
|
- ? API_HOST + '/webapi/events/get-main-photo/' + event.id
|
|
|
|
- : API_HOST + '/static/img/events/trip.webp';
|
|
|
|
|
|
+ const photoUrl = API_HOST + '/webapi/events/get-main-photo/' + event.id;
|
|
|
|
|
|
return (
|
|
return (
|
|
<View style={styles.container}>
|
|
<View style={styles.container}>
|
|
@@ -1043,10 +1094,13 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
<View style={[styles.statItem, { justifyContent: 'flex-start' }]} />
|
|
<View style={[styles.statItem, { justifyContent: 'flex-start' }]} />
|
|
)}
|
|
)}
|
|
|
|
|
|
- {filteredParticipants.length > 0 ? (
|
|
|
|
|
|
+ {(filteredParticipants.length > 0 && event.type !== 4) ||
|
|
|
|
+ (filteredInterested.length === 0 &&
|
|
|
|
+ event.type === 4 &&
|
|
|
|
+ filteredParticipants.length > 0) ? (
|
|
<View style={{ gap: 8, flex: 1 }}>
|
|
<View style={{ gap: 8, flex: 1 }}>
|
|
<Text style={[styles.travelSeriesTitle, { fontSize: 12 }]}>
|
|
<Text style={[styles.travelSeriesTitle, { fontSize: 12 }]}>
|
|
- Participants{` (${filteredParticipants.length})`}
|
|
|
|
|
|
+ Joined{` (${filteredParticipants.length})`}
|
|
</Text>
|
|
</Text>
|
|
|
|
|
|
<View style={[styles.statItem, { justifyContent: 'flex-start' }]}>
|
|
<View style={[styles.statItem, { justifyContent: 'flex-start' }]}>
|
|
@@ -1129,13 +1183,11 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
- ) : (
|
|
|
|
- <View style={[styles.statItem, { justifyContent: 'flex-end' }]} />
|
|
|
|
- )}
|
|
|
|
- </View>
|
|
|
|
|
|
+ ) : null}
|
|
|
|
|
|
- {filteredInterested.length > 0 && event.type === 4 && (
|
|
|
|
- <View>
|
|
|
|
|
|
+ {filteredParticipants.length === 0 &&
|
|
|
|
+ event.type === 4 &&
|
|
|
|
+ filteredInterested.length > 0 ? (
|
|
<View style={{ gap: 8, flex: 1 }}>
|
|
<View style={{ gap: 8, flex: 1 }}>
|
|
<Text style={[styles.travelSeriesTitle, { fontSize: 12 }]}>
|
|
<Text style={[styles.travelSeriesTitle, { fontSize: 12 }]}>
|
|
Interested{` (${filteredInterested.length})`}
|
|
Interested{` (${filteredInterested.length})`}
|
|
@@ -1219,8 +1271,194 @@ const EventScreen = ({ route }: { route: any }) => {
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
- </View>
|
|
|
|
- )}
|
|
|
|
|
|
+ ) : null}
|
|
|
|
+ </View>
|
|
|
|
+
|
|
|
|
+ {filteredInterested.length > 0 &&
|
|
|
|
+ filteredParticipants.length > 0 &&
|
|
|
|
+ event.type === 4 && (
|
|
|
|
+ <View style={styles.stats}>
|
|
|
|
+ {filteredInterested.length > 0 ? (
|
|
|
|
+ <View style={{ gap: 8, flex: 1 }}>
|
|
|
|
+ <Text style={[styles.travelSeriesTitle, { fontSize: 12 }]}>
|
|
|
|
+ Interested{` (${filteredInterested.length})`}
|
|
|
|
+ </Text>
|
|
|
|
+
|
|
|
|
+ <View style={[styles.statItem, { justifyContent: 'flex-start' }]}>
|
|
|
|
+ <View style={styles.userImageContainer}>
|
|
|
|
+ {(filteredInterested.length > maxVisibleParticipants
|
|
|
|
+ ? filteredInterested.slice(0, maxVisibleParticipants - 1)
|
|
|
|
+ : filteredInterested
|
|
|
|
+ ).map((user, index) => (
|
|
|
|
+ <Tooltip
|
|
|
|
+ isVisible={tooltipInterested === index}
|
|
|
|
+ content={
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ onPress={() => {
|
|
|
|
+ setTooltipInterested(null);
|
|
|
|
+ navigation.navigate(
|
|
|
|
+ ...([
|
|
|
|
+ NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW,
|
|
|
|
+ { userId: user.uid }
|
|
|
|
+ ] as never)
|
|
|
|
+ );
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <Text>{user.name}</Text>
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ }
|
|
|
|
+ contentStyle={{ backgroundColor: Colors.FILL_LIGHT }}
|
|
|
|
+ placement="top"
|
|
|
|
+ onClose={() => setTooltipInterested(null)}
|
|
|
|
+ key={index}
|
|
|
|
+ backgroundColor="transparent"
|
|
|
|
+ >
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={index !== 0 ? { marginLeft: -10 } : {}}
|
|
|
|
+ onPress={() => setTooltipInterested(index)}
|
|
|
|
+ >
|
|
|
|
+ {user.avatar ? (
|
|
|
|
+ <Image
|
|
|
|
+ key={index}
|
|
|
|
+ source={{ uri: API_HOST + user.avatar }}
|
|
|
|
+ style={[styles.userImage]}
|
|
|
|
+ />
|
|
|
|
+ ) : (
|
|
|
|
+ <AvatarWithInitials
|
|
|
|
+ text={
|
|
|
|
+ user.name?.split(' ')[0][0] +
|
|
|
|
+ (user.name?.split(' ')[1][0] ?? '')
|
|
|
|
+ }
|
|
|
|
+ flag={API_HOST + user?.flag}
|
|
|
|
+ size={28}
|
|
|
|
+ fontSize={12}
|
|
|
|
+ borderColor={Colors.DARK_LIGHT}
|
|
|
|
+ borderWidth={1}
|
|
|
|
+ />
|
|
|
|
+ )}
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ </Tooltip>
|
|
|
|
+ ))}
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={styles.userCountContainer}
|
|
|
|
+ onPress={() =>
|
|
|
|
+ navigation.navigate(
|
|
|
|
+ ...([
|
|
|
|
+ NAVIGATION_PAGES.PARTICIPANTS_LIST,
|
|
|
|
+ {
|
|
|
|
+ participants: event.participants_full_data,
|
|
|
|
+ eventId: event.id,
|
|
|
|
+ isHost: event.settings.host_profile === +currentUserId,
|
|
|
|
+ interested: true,
|
|
|
|
+ isTrip: event.type === 4
|
|
|
|
+ }
|
|
|
|
+ ] as never)
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ >
|
|
|
|
+ <View style={styles.dots}></View>
|
|
|
|
+ <View style={styles.dots}></View>
|
|
|
|
+ <View style={styles.dots}></View>
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ </View>
|
|
|
|
+ </View>
|
|
|
|
+ </View>
|
|
|
|
+ ) : (
|
|
|
|
+ <View style={[styles.statItem, { justifyContent: 'flex-start' }]} />
|
|
|
|
+ )}
|
|
|
|
+
|
|
|
|
+ {filteredParticipants.length > 0 ? (
|
|
|
|
+ <View style={{ gap: 8, flex: 1 }}>
|
|
|
|
+ <Text style={[styles.travelSeriesTitle, { fontSize: 12 }]}>
|
|
|
|
+ Joined{` (${filteredParticipants.length})`}
|
|
|
|
+ </Text>
|
|
|
|
+
|
|
|
|
+ <View style={[styles.statItem, { justifyContent: 'flex-start' }]}>
|
|
|
|
+ <View style={styles.userImageContainer}>
|
|
|
|
+ {(filteredParticipants.length > maxVisibleParticipants
|
|
|
|
+ ? filteredParticipants.slice(0, maxVisibleParticipants - 1)
|
|
|
|
+ : filteredParticipants
|
|
|
|
+ ).map((user, index) => (
|
|
|
|
+ <Tooltip
|
|
|
|
+ isVisible={tooltipUser === index}
|
|
|
|
+ content={
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ onPress={() => {
|
|
|
|
+ setTooltipUser(null);
|
|
|
|
+ navigation.navigate(
|
|
|
|
+ ...([
|
|
|
|
+ NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW,
|
|
|
|
+ { userId: user.uid }
|
|
|
|
+ ] as never)
|
|
|
|
+ );
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <Text>{user.name}</Text>
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ }
|
|
|
|
+ contentStyle={{ backgroundColor: Colors.FILL_LIGHT }}
|
|
|
|
+ placement="top"
|
|
|
|
+ onClose={() => setTooltipUser(null)}
|
|
|
|
+ key={index}
|
|
|
|
+ backgroundColor="transparent"
|
|
|
|
+ >
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={index !== 0 ? { marginLeft: -10 } : {}}
|
|
|
|
+ onPress={() => setTooltipUser(index)}
|
|
|
|
+ >
|
|
|
|
+ {user.avatar ? (
|
|
|
|
+ <Image
|
|
|
|
+ key={index}
|
|
|
|
+ source={{ uri: API_HOST + user.avatar }}
|
|
|
|
+ style={[styles.userImage]}
|
|
|
|
+ />
|
|
|
|
+ ) : (
|
|
|
|
+ <AvatarWithInitials
|
|
|
|
+ text={
|
|
|
|
+ user.name?.split(' ')[0][0] +
|
|
|
|
+ (user.name?.split(' ')[1][0] ?? '')
|
|
|
|
+ }
|
|
|
|
+ flag={API_HOST + user?.flag}
|
|
|
|
+ size={28}
|
|
|
|
+ fontSize={12}
|
|
|
|
+ borderColor={Colors.DARK_LIGHT}
|
|
|
|
+ borderWidth={1}
|
|
|
|
+ />
|
|
|
|
+ )}
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ </Tooltip>
|
|
|
|
+ ))}
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={styles.userCountContainer}
|
|
|
|
+ onPress={() =>
|
|
|
|
+ navigation.navigate(
|
|
|
|
+ ...([
|
|
|
|
+ NAVIGATION_PAGES.PARTICIPANTS_LIST,
|
|
|
|
+ {
|
|
|
|
+ participants:
|
|
|
|
+ event.type === 4
|
|
|
|
+ ? event.participants_approved_full_data
|
|
|
|
+ : event.participants_full_data,
|
|
|
|
+ eventId: event.id,
|
|
|
|
+ isHost: event.settings.host_profile === +currentUserId,
|
|
|
|
+ isTrip: event.type === 4
|
|
|
|
+ }
|
|
|
|
+ ] as never)
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ >
|
|
|
|
+ <View style={styles.dots}></View>
|
|
|
|
+ <View style={styles.dots}></View>
|
|
|
|
+ <View style={styles.dots}></View>
|
|
|
|
+ </TouchableOpacity>
|
|
|
|
+ </View>
|
|
|
|
+ </View>
|
|
|
|
+ </View>
|
|
|
|
+ ) : (
|
|
|
|
+ <View style={[styles.statItem, { justifyContent: 'flex-end' }]} />
|
|
|
|
+ )}
|
|
|
|
+ </View>
|
|
|
|
+ )}
|
|
|
|
|
|
{/* TO DO */}
|
|
{/* TO DO */}
|
|
{event.settings.host_profile === +currentUserId &&
|
|
{event.settings.host_profile === +currentUserId &&
|