2022-07-12 10:55:28 +02:00
|
|
|
<template>
|
|
|
|
<close-content
|
2022-08-22 12:12:09 +02:00
|
|
|
class="container mx-auto px-2"
|
2022-07-12 10:55:28 +02:00
|
|
|
v-show="loadingEvents || (events && events.total > 0)"
|
|
|
|
:suggestGeoloc="suggestGeoloc"
|
|
|
|
v-on="attrs"
|
2022-08-22 12:12:09 +02:00
|
|
|
@doGeoLoc="emit('doGeoLoc')"
|
2022-07-12 10:55:28 +02:00
|
|
|
>
|
|
|
|
<template #title>
|
2022-08-19 15:07:58 +02:00
|
|
|
<template v-if="userLocationName">
|
|
|
|
{{ t("Events nearby {position}", { position: userLocationName }) }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ t("Events close to you") }}
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
</template>
|
|
|
|
<template #content>
|
|
|
|
<skeleton-event-result
|
|
|
|
v-for="i in 6"
|
|
|
|
class="scroll-ml-6 snap-center shrink-0 w-[18rem] my-4"
|
|
|
|
:key="i"
|
|
|
|
v-show="loadingEvents"
|
|
|
|
/>
|
|
|
|
<event-card
|
|
|
|
v-for="event in events.elements"
|
|
|
|
:event="event"
|
|
|
|
:key="event.uuid"
|
|
|
|
/>
|
|
|
|
<more-content
|
2022-08-22 12:12:09 +02:00
|
|
|
v-if="userLocationName && userLocation?.lat && userLocation?.lon"
|
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,
|
|
|
|
lat: userLocation.lat?.toString(),
|
|
|
|
lon: userLocation.lon?.toString(),
|
|
|
|
contentType: 'EVENTS',
|
2022-08-22 12:12:09 +02:00
|
|
|
distance: '25_km',
|
2022-07-12 10:55:28 +02:00
|
|
|
},
|
|
|
|
}"
|
2022-08-22 12:12:09 +02:00
|
|
|
:picture="userLocation?.picture"
|
2022-07-12 10:55:28 +02:00
|
|
|
>
|
|
|
|
{{
|
|
|
|
t("View more events around {position}", {
|
|
|
|
position: userLocationName,
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
</more-content>
|
|
|
|
</template>
|
|
|
|
</close-content>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { LocationType } from "../../types/user-location.model";
|
|
|
|
import MoreContent from "./MoreContent.vue";
|
|
|
|
import CloseContent from "./CloseContent.vue";
|
|
|
|
import { computed, useAttrs } from "vue";
|
|
|
|
import { SEARCH_EVENTS } from "@/graphql/search";
|
|
|
|
import { IEvent } from "@/types/event.model";
|
|
|
|
import { useQuery } from "@vue/apollo-composable";
|
|
|
|
import EventCard from "../Event/EventCard.vue";
|
|
|
|
import { Paginate } from "@/types/paginate";
|
|
|
|
import SkeletonEventResult from "../Event/SkeletonEventResult.vue";
|
|
|
|
import { useI18n } from "vue-i18n";
|
2022-08-22 12:12:09 +02:00
|
|
|
import { coordsToGeoHash } from "@/utils/location";
|
2022-08-26 16:08:58 +02:00
|
|
|
import { roundToNearestMinute } from "@/utils/datetime";
|
|
|
|
import RouteName from "@/router/name";
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const props = defineProps<{ userLocation: LocationType }>();
|
|
|
|
const emit = defineEmits(["doGeoLoc"]);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-22 12:12:09 +02:00
|
|
|
const EVENT_PAGE_LIMIT = 12;
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const { t } = useI18n({ useScope: "global" });
|
|
|
|
const attrs = useAttrs();
|
|
|
|
|
|
|
|
const userLocationName = computed(() => {
|
2022-08-22 12:12:09 +02:00
|
|
|
return props.userLocation?.name;
|
2022-07-12 10:55:28 +02:00
|
|
|
});
|
2022-08-22 12:12:09 +02:00
|
|
|
const suggestGeoloc = computed(() => props.userLocation?.isIPLocation);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
2022-08-26 16:08:58 +02:00
|
|
|
const geoHash = computed(() =>
|
|
|
|
coordsToGeoHash(props.userLocation.lat, props.userLocation.lon)
|
|
|
|
);
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { result: eventsResult, loading: loadingEvents } = useQuery<{
|
|
|
|
searchEvents: Paginate<IEvent>;
|
2022-08-26 16:08:58 +02:00
|
|
|
}>(
|
|
|
|
SEARCH_EVENTS,
|
|
|
|
() => ({
|
|
|
|
location: geoHash.value,
|
|
|
|
beginsOn: roundToNearestMinute(new Date()),
|
|
|
|
endsOn: undefined,
|
|
|
|
radius: 25,
|
|
|
|
eventPage: 1,
|
|
|
|
limit: EVENT_PAGE_LIMIT,
|
|
|
|
type: "IN_PERSON",
|
|
|
|
}),
|
|
|
|
() => ({
|
|
|
|
enabled: geoHash.value !== undefined,
|
|
|
|
})
|
|
|
|
);
|
2022-07-12 10:55:28 +02:00
|
|
|
|
|
|
|
const events = computed(
|
|
|
|
() => eventsResult.value?.searchEvents ?? { elements: [], total: 0 }
|
|
|
|
);
|
|
|
|
</script>
|