2019-12-20 13:04:34 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<div class="container section">
|
|
|
|
<b-notification v-if="$apollo.queries.searchEvents.loading">
|
|
|
|
{{ $t("Redirecting to event…") }}
|
|
|
|
</b-notification>
|
|
|
|
<b-notification v-if="$apollo.queries.searchEvents.skip" type="is-danger">
|
|
|
|
{{ $t("Resource provided is not an URL") }}
|
|
|
|
</b-notification>
|
|
|
|
</div>
|
2019-12-20 13:04:34 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Vue } from "vue-property-decorator";
|
|
|
|
import { SEARCH_EVENTS } from "@/graphql/search";
|
|
|
|
import { IEvent } from "@/types/event.model";
|
|
|
|
import RouteName from "../router/name";
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
searchEvents: {
|
|
|
|
query: SEARCH_EVENTS,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
searchText: this.$route.query.url,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
skip() {
|
|
|
|
try {
|
|
|
|
const url = this.$route.query.url as string;
|
|
|
|
new URL(url);
|
|
|
|
return false;
|
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof TypeError) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async result({ data }) {
|
2020-02-18 08:57:00 +01:00
|
|
|
if (
|
|
|
|
data.searchEvents &&
|
|
|
|
data.searchEvents.total > 0 &&
|
|
|
|
data.searchEvents.elements.length > 0
|
|
|
|
) {
|
2019-12-20 13:04:34 +01:00
|
|
|
const event = data.searchEvents.elements[0];
|
2020-02-18 08:57:00 +01:00
|
|
|
return await this.$router.replace({
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: event.uuid },
|
|
|
|
});
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Interact extends Vue {
|
|
|
|
searchEvents!: IEvent[];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
RouteName = RouteName;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss">
|
2020-02-18 08:57:00 +01:00
|
|
|
@import "@/variables.scss";
|
2019-12-20 13:04:34 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
main > .container {
|
|
|
|
background: $white;
|
|
|
|
}
|
|
|
|
</style>
|