mobilizon/js/src/views/Interact.vue
Thomas Citharel 4144e9ffd0
Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-06-03 16:01:26 +02:00

67 lines
1.6 KiB
Vue

<template>
<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>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { SEARCH_EVENTS } from "@/graphql/search";
import { IEvent } from "@/types/event.model";
import RouteName from "../router/name";
@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 }) {
if (
data.searchEvents &&
data.searchEvents.total > 0 &&
data.searchEvents.elements.length > 0
) {
const event = data.searchEvents.elements[0];
return await this.$router.replace({
name: RouteName.EVENT,
params: { uuid: event.uuid },
});
}
},
},
},
})
export default class Interact extends Vue {
searchEvents!: IEvent[];
RouteName = RouteName;
}
</script>
<style lang="scss">
@import "@/variables.scss";
main > .container {
background: $white;
}
</style>