2022-07-12 10:55:28 +02:00
|
|
|
<template>
|
2022-08-22 12:12:09 +02:00
|
|
|
<close-content
|
|
|
|
class="container mx-auto px-2"
|
2022-10-05 17:42:12 +02:00
|
|
|
v-show="loading || selectedGroups.length > 0"
|
2022-08-22 12:12:09 +02:00
|
|
|
@do-geo-loc="emit('doGeoLoc')"
|
|
|
|
:suggestGeoloc="userLocation.isIPLocation"
|
2022-10-05 17:42:12 +02:00
|
|
|
:doingGeoloc="doingGeoloc"
|
2022-08-22 12:12:09 +02:00
|
|
|
>
|
2022-07-12 10:55:28 +02:00
|
|
|
<template #title>
|
2022-08-22 12:12:09 +02:00
|
|
|
<template v-if="userLocationName">
|
|
|
|
{{
|
|
|
|
t("Popular groups nearby {position}", {
|
|
|
|
position: userLocationName,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ t("Popular groups close to you") }}
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
</template>
|
|
|
|
<template #content>
|
2022-08-26 16:08:58 +02:00
|
|
|
<skeleton-group-result
|
2022-07-12 10:55:28 +02:00
|
|
|
v-for="i in [...Array(6).keys()]"
|
|
|
|
class="scroll-ml-6 snap-center shrink-0 w-[18rem] my-4"
|
|
|
|
:key="i"
|
2022-10-05 17:42:12 +02:00
|
|
|
v-show="loading"
|
2022-08-26 16:08:58 +02:00
|
|
|
/>
|
2022-08-22 12:12:09 +02:00
|
|
|
<group-card
|
2022-07-12 10:55:28 +02:00
|
|
|
v-for="group in selectedGroups"
|
|
|
|
:key="group.id"
|
|
|
|
:group="group"
|
|
|
|
:view-mode="'column'"
|
|
|
|
:minimal="true"
|
|
|
|
:has-border="true"
|
2022-08-22 12:12:09 +02:00
|
|
|
:showSummary="false"
|
2022-07-12 10:55:28 +02:00
|
|
|
/>
|
|
|
|
|
|
|
|
<more-content
|
2022-08-22 12:12:09 +02:00
|
|
|
v-if="userLocationName"
|
2022-07-12 10:55:28 +02:00
|
|
|
:to="{
|
2022-08-26 16:08:58 +02:00
|
|
|
name: RouteName.SEARCH,
|
2022-07-12 10:55:28 +02:00
|
|
|
query: {
|
|
|
|
locationName: userLocationName,
|
2022-08-22 12:12:09 +02:00
|
|
|
lat: userLocation.lat?.toString(),
|
|
|
|
lon: userLocation.lon?.toString(),
|
2022-07-12 10:55:28 +02:00
|
|
|
contentType: 'GROUPS',
|
2022-10-05 17:42:12 +02:00
|
|
|
distance: `${distance}_km`,
|
2022-07-12 10:55:28 +02:00
|
|
|
},
|
|
|
|
}"
|
|
|
|
:picture="userLocation.picture"
|
|
|
|
>
|
|
|
|
{{
|
2022-08-22 12:12:09 +02:00
|
|
|
t("View more groups around {position}", {
|
2022-07-12 10:55:28 +02:00
|
|
|
position: userLocationName,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</more-content>
|
|
|
|
</template>
|
|
|
|
</close-content>
|
|
|
|
</template>
|
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
<script lang="ts" setup>
|
2022-08-26 16:08:58 +02:00
|
|
|
import SkeletonGroupResult from "@/components/Group/SkeletonGroupResult.vue";
|
2022-07-12 10:55:28 +02:00
|
|
|
import sampleSize from "lodash/sampleSize";
|
2022-08-26 16:08:58 +02:00
|
|
|
import { LocationType } from "@/types/user-location.model";
|
2022-07-12 10:55:28 +02:00
|
|
|
import MoreContent from "./MoreContent.vue";
|
|
|
|
import CloseContent from "./CloseContent.vue";
|
|
|
|
import { IGroup } from "@/types/actor";
|
|
|
|
import { SEARCH_GROUPS } from "@/graphql/search";
|
2022-08-22 12:12:09 +02:00
|
|
|
import { useQuery } from "@vue/apollo-composable";
|
|
|
|
import { Paginate } from "@/types/paginate";
|
|
|
|
import { computed } from "vue";
|
|
|
|
import GroupCard from "@/components/Group/GroupCard.vue";
|
|
|
|
import { coordsToGeoHash } from "@/utils/location";
|
|
|
|
import { useI18n } from "vue-i18n";
|
2022-08-26 16:08:58 +02:00
|
|
|
import RouteName from "@/router/name";
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-10-05 17:42:12 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
userLocation: LocationType;
|
|
|
|
doingGeoloc?: boolean;
|
|
|
|
}>();
|
2022-08-22 12:12:09 +02:00
|
|
|
const emit = defineEmits(["doGeoLoc"]);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const { t } = useI18n({ useScope: "global" });
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-10-05 17:42:12 +02:00
|
|
|
const userLocation = computed(() => props.userLocation);
|
|
|
|
|
|
|
|
const geoHash = computed(() =>
|
|
|
|
coordsToGeoHash(userLocation.value.lat, userLocation.value.lon)
|
|
|
|
);
|
|
|
|
|
|
|
|
const distance = computed<number>(() =>
|
|
|
|
userLocation.value?.isIPLocation ? 150 : 25
|
|
|
|
);
|
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const { result: groupsResult, loading: loadingGroups } = useQuery<{
|
|
|
|
searchGroups: Paginate<IGroup>;
|
|
|
|
}>(
|
|
|
|
SEARCH_GROUPS,
|
|
|
|
() => ({
|
2022-10-05 17:42:12 +02:00
|
|
|
location: geoHash.value,
|
|
|
|
radius: distance.value,
|
2022-08-22 12:12:09 +02:00
|
|
|
page: 1,
|
|
|
|
limit: 12,
|
|
|
|
}),
|
2022-10-05 17:42:12 +02:00
|
|
|
() => ({ enabled: geoHash.value !== undefined })
|
2022-08-22 12:12:09 +02:00
|
|
|
);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const groups = computed(
|
|
|
|
() => groupsResult.value?.searchGroups ?? { total: 0, elements: [] }
|
|
|
|
);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const selectedGroups = computed(() => sampleSize(groups.value?.elements, 5));
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const userLocationName = computed(() => props?.userLocation?.name);
|
2022-10-05 17:42:12 +02:00
|
|
|
|
|
|
|
const loading = computed(() => props.doingGeoloc || loadingGroups.value);
|
2022-07-12 10:55:28 +02:00
|
|
|
</script>
|