Add global search

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-08-26 16:08:58 +02:00
parent bfc936f57c
commit 48935e2168
216 changed files with 3646 additions and 2806 deletions

View File

@@ -29,7 +29,7 @@
<more-content
v-if="userLocationName && userLocation?.lat && userLocation?.lon"
:to="{
name: 'SEARCH',
name: RouteName.SEARCH,
query: {
locationName: userLocationName,
lat: userLocation.lat?.toString(),
@@ -63,6 +63,8 @@ import { Paginate } from "@/types/paginate";
import SkeletonEventResult from "../Event/SkeletonEventResult.vue";
import { useI18n } from "vue-i18n";
import { coordsToGeoHash } from "@/utils/location";
import { roundToNearestMinute } from "@/utils/datetime";
import RouteName from "@/router/name";
const props = defineProps<{ userLocation: LocationType }>();
const emit = defineEmits(["doGeoLoc"]);
@@ -77,17 +79,27 @@ const userLocationName = computed(() => {
});
const suggestGeoloc = computed(() => props.userLocation?.isIPLocation);
const geoHash = computed(() =>
coordsToGeoHash(props.userLocation.lat, props.userLocation.lon)
);
const { result: eventsResult, loading: loadingEvents } = useQuery<{
searchEvents: Paginate<IEvent>;
}>(SEARCH_EVENTS, () => ({
location: coordsToGeoHash(props.userLocation.lat, props.userLocation.lon),
beginsOn: new Date(),
endsOn: undefined,
radius: 25,
eventPage: 1,
limit: EVENT_PAGE_LIMIT,
type: "IN_PERSON",
}));
}>(
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,
})
);
const events = computed(
() => eventsResult.value?.searchEvents ?? { elements: [], total: 0 }