chore: migrate to script setup style
This commit is contained in:
@@ -16,27 +16,19 @@
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
import { computed, defineComponent, PropType } from 'vue'
|
||||
<script setup lang='ts'>
|
||||
import { computed, PropType } from 'vue'
|
||||
import { DanceHallDistance } from '~/graphql/generated/operations'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DistanceDisplay',
|
||||
props: {
|
||||
const props = defineProps({
|
||||
distance: {
|
||||
type: Object as PropType<DanceHallDistance>,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
setup (props) {
|
||||
const numericDistance = computed(() =>
|
||||
})
|
||||
const numericDistance = computed(() =>
|
||||
Number(props.distance.distance / 1000).toLocaleString('sv-SE', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
}))
|
||||
return {
|
||||
numericDistance
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -107,19 +107,16 @@
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
<script setup lang='ts'>
|
||||
|
||||
import { format, formatDistanceToNow, parseISO } from 'date-fns'
|
||||
|
||||
import { enGB, sv } from 'date-fns/locale'
|
||||
import { computed, defineComponent, getCurrentInstance, PropType } from 'vue'
|
||||
import { computed, getCurrentInstance, PropType } from 'vue'
|
||||
import { Event } from '~/graphql/generated/operations'
|
||||
import DistanceDisplay from '~/components/pages/events/Event/distance.vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EventDetail',
|
||||
components: { DistanceDisplay },
|
||||
props: {
|
||||
const props = defineProps({
|
||||
event: {
|
||||
type: Object as PropType<Event>,
|
||||
required: true
|
||||
@@ -132,20 +129,13 @@ export default defineComponent({
|
||||
type: Function,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
setup (props) {
|
||||
const instance = getCurrentInstance()
|
||||
const locale = computed(() => (instance?.proxy.$i18n.locale ?? 'sv') === 'en' ? enGB : sv)
|
||||
const time = computed(() => (props.event.time || '').split('-')[0].replace('.', ':'))
|
||||
const weekday = computed(() => format(parseISO(props.event.date), 'EEEE', { locale: locale.value }))
|
||||
const daysUntil = computed(() => formatDistanceToNow(parseISO(`${props.event.date}T${time.value}`), {
|
||||
})
|
||||
const instance = getCurrentInstance()
|
||||
const locale = computed(() => (instance?.proxy.$i18n.locale ?? 'sv') === 'en' ? enGB : sv)
|
||||
const time = computed(() => (props.event.time || '').split('-')[0].replace('.', ':'))
|
||||
const weekday = computed(() => format(parseISO(props.event.date), 'EEEE', { locale: locale.value }))
|
||||
const daysUntil = computed(() => formatDistanceToNow(parseISO(`${props.event.date}T${time.value}`), {
|
||||
addSuffix: true,
|
||||
locale: locale.value
|
||||
}))
|
||||
return {
|
||||
weekday,
|
||||
daysUntil
|
||||
}
|
||||
}
|
||||
})
|
||||
}))
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<v-row v-for="event in events" :key="event.id" wrap>
|
||||
<v-flex xs12>
|
||||
<Event
|
||||
<event-card
|
||||
:event="event"
|
||||
:has-user="hasUser"
|
||||
:toggle-ignore="toggleIgnore"
|
||||
@@ -12,15 +12,12 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Event from '../Event'
|
||||
<script setup lang='ts'>
|
||||
import { type PropType } from 'vue'
|
||||
import EventCard from '../Event/index.vue'
|
||||
import { type Event } from '~/graphql/generated/operations'
|
||||
|
||||
export default {
|
||||
name: 'EventList',
|
||||
components: {
|
||||
Event
|
||||
},
|
||||
props: {
|
||||
defineProps({
|
||||
hasUser: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
@@ -30,9 +27,8 @@ export default {
|
||||
required: true
|
||||
},
|
||||
events: {
|
||||
type: Array,
|
||||
type: Array as PropType<Event[]>,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div :key="isAuthenticated">
|
||||
<div :key="isAuthenticated ? 'true' : 'false'">
|
||||
<v-container :key="range" fluid grid-list-md class="app-fade-in">
|
||||
<v-row v-if="!isAuthenticated" wrap>
|
||||
<v-col xs="12">
|
||||
@@ -18,7 +18,7 @@
|
||||
<template #activator="{ on }">
|
||||
<v-icon
|
||||
v-on="on"
|
||||
@click="fetchAddress()"
|
||||
@click="fetchAddressFn()"
|
||||
>
|
||||
mdi-crosshairs-gps
|
||||
</v-icon>
|
||||
@@ -32,7 +32,7 @@
|
||||
<v-icon
|
||||
:disabled="!origin"
|
||||
v-on="on"
|
||||
@click="saveOrigin(origin)"
|
||||
@click="saveOriginFn(origin)"
|
||||
>
|
||||
mdi-bookmark-plus-outline
|
||||
</v-icon>
|
||||
@@ -74,10 +74,10 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="4">
|
||||
<v-checkbox v-model="state.includeHidden" :label="$t("events.includeHidden")" />
|
||||
<v-checkbox v-model="state.includeHidden" :label="$t('events.includeHidden')" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
<list
|
||||
<event-list
|
||||
:events="events"
|
||||
:has-user="isAuthenticated"
|
||||
:toggle-ignore="toggleIgnore"
|
||||
@@ -93,10 +93,9 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
import { computed, defineComponent, ref, watch } from 'vue'
|
||||
|
||||
import List from './List/index.vue'
|
||||
<script setup lang='ts'>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import EventList from './List/index.vue'
|
||||
import { useAuth } from '~/plugins/auth'
|
||||
import { useTranslation } from '~/plugins/i18n'
|
||||
import {
|
||||
@@ -112,44 +111,38 @@ import {
|
||||
} from '~/graphql/generated/operations'
|
||||
import { useState } from '~/store'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EventsPage',
|
||||
components: {
|
||||
List
|
||||
},
|
||||
setup () {
|
||||
const state = useState()
|
||||
const { t } = useTranslation()
|
||||
state.setTitle(t('app.links.events'))
|
||||
const { loading: authLoading, isAuthenticated } = useAuth()
|
||||
const variables = ref<FindEventsQueryVariables>({
|
||||
const state = useState()
|
||||
const range = computed(() => state.range)
|
||||
const { t } = useTranslation()
|
||||
state.setTitle(t('app.links.events'))
|
||||
const { isAuthenticated } = useAuth()
|
||||
const variables = ref<FindEventsQueryVariables>({
|
||||
range: state.range,
|
||||
includeOrigins: isAuthenticated.value || false,
|
||||
search: state.search,
|
||||
includeHidden: state.includeHidden
|
||||
})
|
||||
const { result, refetch } = useFindEventsQuery(() => variables.value)
|
||||
watch([state, isAuthenticated], () => {
|
||||
})
|
||||
const { result, refetch } = useFindEventsQuery(() => variables.value)
|
||||
watch([state, isAuthenticated], () => {
|
||||
variables.value.range = state.range
|
||||
variables.value.search = state.search
|
||||
variables.value.includeHidden = state.includeHidden
|
||||
variables.value.includeOrigins = isAuthenticated.value || false
|
||||
refetch(variables.value)
|
||||
})
|
||||
const events = computed(() => result.value?.events ?? [])
|
||||
const origins = computed(() => result.value?.origins ?? [])
|
||||
const submitting = ref(true)
|
||||
const ranges = [
|
||||
})
|
||||
const events = computed(() => result.value?.events ?? [])
|
||||
const origins = computed(() => result.value?.origins ?? [])
|
||||
const ranges = [
|
||||
{ name: '1 vecka', value: 'ONE_WEEK' },
|
||||
{ name: '2 veckor', value: 'TWO_WEEKS' },
|
||||
{ name: '1 månad', value: 'ONE_MONTH' },
|
||||
{ name: '1 kvartal', value: 'ONE_QUARTER' },
|
||||
{ name: '1 år', value: 'ONE_YEAR' }
|
||||
]
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
]
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
|
||||
const origin = ref('')
|
||||
const fetchEvents = () => {
|
||||
const origin = ref('')
|
||||
const fetchEvents = () => {
|
||||
const originsTemp = [...(origins.value || [])]
|
||||
if (origin.value) {
|
||||
originsTemp.push(origin.value)
|
||||
@@ -161,32 +154,32 @@ export default defineComponent({
|
||||
includeOrigins: isAuthenticated.value || false
|
||||
}
|
||||
refetch(variables.value)
|
||||
}
|
||||
}
|
||||
|
||||
const { mutate: doToggleIgnoreBand } = useToggleIgnoreBandMutation({})
|
||||
const { mutate: doToggleIgnoreDanceHall } = useToggleIgnoreDanceHallMutation({})
|
||||
const { mutate: doToggleIgnoreCity } = useToggleIgnoreCityMutation({})
|
||||
const { mutate: doToggleIgnoreMunicipality } = useToggleIgnoreMunicipalityMutation({})
|
||||
const { mutate: doToggleIgnoreState } = useToggleIgnoreStateMutation({})
|
||||
const { mutate: doToggleIgnoreBand } = useToggleIgnoreBandMutation({})
|
||||
const { mutate: doToggleIgnoreDanceHall } = useToggleIgnoreDanceHallMutation({})
|
||||
const { mutate: doToggleIgnoreCity } = useToggleIgnoreCityMutation({})
|
||||
const { mutate: doToggleIgnoreMunicipality } = useToggleIgnoreMunicipalityMutation({})
|
||||
const { mutate: doToggleIgnoreState } = useToggleIgnoreStateMutation({})
|
||||
|
||||
const toggleIgnoreSuccess = (name: string) => {
|
||||
const toggleIgnoreSuccess = (name: string) => {
|
||||
return () => {
|
||||
fetchEvents()
|
||||
snackbar.value.color = 'success'
|
||||
snackbar.value.text = `${name} har dolts`
|
||||
snackbar.value.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const toggleIgnoreFailed = (name: string) => {
|
||||
const toggleIgnoreFailed = (name: string) => {
|
||||
return () => {
|
||||
snackbar.value.color = 'error'
|
||||
snackbar.value.text = `${name} kunde inte döljas`
|
||||
snackbar.value.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const toggleIgnore = (type: string, name: string) => {
|
||||
const toggleIgnore = (type: string, name: string) => {
|
||||
switch (type) {
|
||||
case 'band':
|
||||
doToggleIgnoreBand({ name })
|
||||
@@ -215,11 +208,11 @@ export default defineComponent({
|
||||
break
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { mutate: doSaveOrigin } = useSaveOriginMutation({})
|
||||
const { refetch: doFetchAddress, load: loadFetchAddress } = useFetchAddressLazyQuery({ latlng: '' })
|
||||
const fetchAddressFn = () => {
|
||||
const { mutate: doSaveOrigin } = useSaveOriginMutation({})
|
||||
const { refetch: doFetchAddress, load: loadFetchAddress } = useFetchAddressLazyQuery({ latlng: '' })
|
||||
const fetchAddressFn = () => {
|
||||
if (window.navigator) {
|
||||
window.navigator.geolocation.getCurrentPosition((pos) => {
|
||||
loadFetchAddress()
|
||||
@@ -230,27 +223,11 @@ export default defineComponent({
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
const saveOriginFn = (o: string) =>
|
||||
}
|
||||
const saveOriginFn = (o: string) =>
|
||||
doSaveOrigin({ origin: o }).then(() => {
|
||||
origin.value = ''
|
||||
fetchEvents()
|
||||
})
|
||||
|
||||
return {
|
||||
authLoading,
|
||||
isAuthenticated,
|
||||
state,
|
||||
events,
|
||||
origins,
|
||||
submitting,
|
||||
ranges,
|
||||
snackbar,
|
||||
toggleIgnore,
|
||||
origin,
|
||||
fetchAddress: fetchAddressFn,
|
||||
saveOrigin: saveOriginFn
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -21,10 +21,8 @@
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'FiltersList',
|
||||
props: {
|
||||
<script setup lang='ts'>
|
||||
defineProps({
|
||||
model: {
|
||||
type: Array,
|
||||
required: true
|
||||
@@ -41,6 +39,5 @@ export default {
|
||||
type: Function,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -60,9 +60,8 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
<script setup lang='ts'>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import List from './List/index.vue'
|
||||
import { useAuth } from '~/plugins/auth'
|
||||
import { useTranslation } from '~/plugins/i18n'
|
||||
@@ -76,47 +75,41 @@ import {
|
||||
} from '~/graphql/generated/operations'
|
||||
import { useState } from '~/store'
|
||||
|
||||
export default {
|
||||
name: 'FiltersPage',
|
||||
components: {
|
||||
List
|
||||
},
|
||||
setup () {
|
||||
const state = useState()
|
||||
const { t } = useTranslation()
|
||||
state.setTitle(t('app.links.filters'))
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { result, loading, refetch } = useFetchFiltersQuery()
|
||||
const bands = computed(() => result.value?.bands ?? [])
|
||||
const cities = computed(() => result.value?.cities ?? [])
|
||||
const danceHalls = computed(() => result.value?.danceHalls ?? [])
|
||||
const municipalities = computed(() => result.value?.municipalities ?? [])
|
||||
const states = computed(() => result.value?.states ?? [])
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
const { mutate: doToggleIgnoreBand } = useToggleIgnoreBandMutation({})
|
||||
const { mutate: doToggleIgnoreDanceHall } = useToggleIgnoreDanceHallMutation({})
|
||||
const { mutate: doToggleIgnoreCity } = useToggleIgnoreCityMutation({})
|
||||
const { mutate: doToggleIgnoreMunicipality } = useToggleIgnoreMunicipalityMutation({})
|
||||
const { mutate: doToggleIgnoreState } = useToggleIgnoreStateMutation({})
|
||||
const state = useState()
|
||||
const { t } = useTranslation()
|
||||
state.setTitle(t('app.links.filters'))
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { result, refetch } = useFetchFiltersQuery()
|
||||
const bands = computed(() => result.value?.bands ?? [])
|
||||
const cities = computed(() => result.value?.cities ?? [])
|
||||
const danceHalls = computed(() => result.value?.danceHalls ?? [])
|
||||
const municipalities = computed(() => result.value?.municipalities ?? [])
|
||||
const states = computed(() => result.value?.states ?? [])
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
const { mutate: doToggleIgnoreBand } = useToggleIgnoreBandMutation({})
|
||||
const { mutate: doToggleIgnoreDanceHall } = useToggleIgnoreDanceHallMutation({})
|
||||
const { mutate: doToggleIgnoreCity } = useToggleIgnoreCityMutation({})
|
||||
const { mutate: doToggleIgnoreMunicipality } = useToggleIgnoreMunicipalityMutation({})
|
||||
const { mutate: doToggleIgnoreState } = useToggleIgnoreStateMutation({})
|
||||
|
||||
const toggleIgnoreSuccess = (name: string) => {
|
||||
const toggleIgnoreSuccess = (name: string) => {
|
||||
return () => {
|
||||
refetch()
|
||||
snackbar.value.color = 'success'
|
||||
snackbar.value.text = t('filters.success', { name })
|
||||
snackbar.value.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const toggleIgnoreFailed = (name: string) => {
|
||||
const toggleIgnoreFailed = (name: string) => {
|
||||
return () => {
|
||||
snackbar.value.color = 'error'
|
||||
snackbar.value.text = t('filters.failure', { name })
|
||||
snackbar.value.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const toggleIgnore = (type: string, name: string) => {
|
||||
const toggleIgnore = (type: string, name: string) => {
|
||||
switch (type) {
|
||||
case 'band':
|
||||
doToggleIgnoreBand({ name })
|
||||
@@ -145,19 +138,5 @@ export default {
|
||||
break
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
isAuthenticated,
|
||||
loading,
|
||||
bands,
|
||||
danceHalls,
|
||||
cities,
|
||||
municipalities,
|
||||
states,
|
||||
snackbar,
|
||||
toggleIgnore
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div :key="isAuthenticated">
|
||||
<div :key="isAuthenticated ? 'true' : 'false'">
|
||||
<v-container fluid grid-list-md class="app-fade-in">
|
||||
<v-layout row wrap>
|
||||
<v-flex xs12>
|
||||
@@ -13,7 +13,7 @@
|
||||
<template #activator="{ on }">
|
||||
<v-icon
|
||||
v-on="on"
|
||||
@click="fetchAddress()"
|
||||
@click="fetchAddressFn()"
|
||||
>
|
||||
mdi-crosshairs-gps
|
||||
</v-icon>
|
||||
@@ -27,7 +27,7 @@
|
||||
<v-icon
|
||||
:disabled="!origin"
|
||||
v-on="on"
|
||||
@click="saveOrigin(origin)"
|
||||
@click="saveOriginFn(origin)"
|
||||
>
|
||||
mdi-bookmark-plus-outline
|
||||
</v-icon>
|
||||
@@ -44,7 +44,7 @@
|
||||
<template #activator="{ on }">
|
||||
<v-icon
|
||||
v-on="on"
|
||||
@click="removeOrigin(o)"
|
||||
@click="removeOriginFn(o)"
|
||||
>
|
||||
mdi-delete-outline
|
||||
</v-icon>
|
||||
@@ -65,8 +65,8 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
import { computed, defineComponent, ref } from 'vue'
|
||||
<script setup lang='ts'>
|
||||
import { computed, ref } from 'vue'
|
||||
import { useAuth } from '~/plugins/auth'
|
||||
import { useTranslation } from '~/plugins/i18n'
|
||||
import {
|
||||
@@ -77,21 +77,18 @@ import {
|
||||
} from '~/graphql/generated/operations'
|
||||
import { useState } from '~/store'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'OriginsPage',
|
||||
setup () {
|
||||
const state = useState()
|
||||
const { t } = useTranslation()
|
||||
state.setTitle(t('app.links.origins'))
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { result, loading, refetch } = useFindOriginsQuery()
|
||||
const origins = computed(() => result.value?.origins ?? [])
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
const { mutate: doSaveOrigin } = useSaveOriginMutation({})
|
||||
const { mutate: doRemoveOrigin } = useRemoveOriginMutation({})
|
||||
const { refetch: doFetchAddress, load } = useFetchAddressLazyQuery({ latlng: '' })
|
||||
const origin = ref('')
|
||||
const fetchAddressFn = () => {
|
||||
const state = useState()
|
||||
const { t } = useTranslation()
|
||||
state.setTitle(t('app.links.origins'))
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { result, refetch } = useFindOriginsQuery()
|
||||
const origins = computed(() => result.value?.origins ?? [])
|
||||
const snackbar = ref({ active: false, color: 'success', text: '' })
|
||||
const { mutate: doSaveOrigin } = useSaveOriginMutation({})
|
||||
const { mutate: doRemoveOrigin } = useRemoveOriginMutation({})
|
||||
const { refetch: doFetchAddress, load } = useFetchAddressLazyQuery({ latlng: '' })
|
||||
const origin = ref('')
|
||||
const fetchAddressFn = () => {
|
||||
if (window.navigator) {
|
||||
window.navigator.geolocation.getCurrentPosition((pos) => {
|
||||
load()
|
||||
@@ -102,24 +99,12 @@ export default defineComponent({
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
const saveOriginFn = (o: string) =>
|
||||
}
|
||||
const saveOriginFn = (o: string) =>
|
||||
doSaveOrigin({ origin: o }).then(() => {
|
||||
refetch()
|
||||
origin.value = ''
|
||||
})
|
||||
const removeOriginFn = (o: string) =>
|
||||
const removeOriginFn = (o: string) =>
|
||||
doRemoveOrigin({ origin: o }).then(() => refetch())
|
||||
return {
|
||||
isAuthenticated,
|
||||
loading,
|
||||
origins,
|
||||
snackbar,
|
||||
origin,
|
||||
saveOrigin: saveOriginFn,
|
||||
removeOrigin: removeOriginFn,
|
||||
fetchAddress: fetchAddressFn
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -4,18 +4,13 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup lang='ts'>
|
||||
import { getCurrentInstance } from 'vue'
|
||||
import { useState } from '~/store'
|
||||
|
||||
export default {
|
||||
name: 'ThemedLayout',
|
||||
setup () {
|
||||
const instance = getCurrentInstance()
|
||||
const state = useState()
|
||||
if (instance) {
|
||||
const instance = getCurrentInstance()
|
||||
const state = useState()
|
||||
if (instance) {
|
||||
instance.proxy.$vuetify.theme.dark = state.darkMode
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
+24
-41
@@ -78,46 +78,42 @@
|
||||
</v-app>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup lang='ts'>
|
||||
|
||||
import { computed, getCurrentInstance, provide, ref } from 'vue'
|
||||
import { DefaultApolloClient } from '@vue/apollo-composable'
|
||||
import Themed from './components/themed'
|
||||
import Themed from './components/themed.vue'
|
||||
import { useAuth } from '~/plugins/auth'
|
||||
import { useState } from '~/store'
|
||||
|
||||
export default {
|
||||
name: 'DefaultLayout',
|
||||
components: {
|
||||
Themed
|
||||
},
|
||||
setup () {
|
||||
const instance = getCurrentInstance()
|
||||
if (instance) {
|
||||
const instance = getCurrentInstance()
|
||||
if (instance) {
|
||||
provide(DefaultApolloClient, instance.proxy.$apollo)
|
||||
}
|
||||
const state = useState()
|
||||
const router = useRouter()
|
||||
const onRedirectCallback = (appState) => {
|
||||
}
|
||||
const state = useState()
|
||||
const router = useRouter()
|
||||
const onRedirectCallback = (appState) => {
|
||||
router.push(
|
||||
appState && appState.targetUrl
|
||||
? appState.targetUrl
|
||||
: window.location.pathname
|
||||
)
|
||||
}
|
||||
const { loading, isAuthenticated, user, loginWithRedirect, logout } =
|
||||
}
|
||||
const { loading, isAuthenticated, user, loginWithRedirect, logout } =
|
||||
useAuth(onRedirectCallback)
|
||||
const doLogin = () => {
|
||||
loginWithRedirect()
|
||||
}
|
||||
const doLogout = () => {
|
||||
const doLogin = () => {
|
||||
loginWithRedirect({
|
||||
appState: { targetUrl: window.location.pathname }
|
||||
})
|
||||
}
|
||||
const doLogout = () => {
|
||||
logout({
|
||||
logoutParams: {
|
||||
returnTo: window.location.origin
|
||||
}
|
||||
})
|
||||
}
|
||||
const darkMode = computed({
|
||||
}
|
||||
const darkMode = computed({
|
||||
get: () => (instance ? instance.proxy.$vuetify.theme.dark : false),
|
||||
set: (val) => {
|
||||
if (instance) {
|
||||
@@ -125,8 +121,8 @@ export default {
|
||||
state.setDarkMode(instance.proxy.$vuetify.theme.dark)
|
||||
}
|
||||
}
|
||||
})
|
||||
const locale = computed({
|
||||
})
|
||||
const locale = computed({
|
||||
get: () => (instance ? instance.proxy.$i18n.locale : 'sv'),
|
||||
set: (newLocale) => {
|
||||
if (instance) {
|
||||
@@ -136,22 +132,9 @@ export default {
|
||||
}
|
||||
state.setLocale(newLocale)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const nav = ref(false)
|
||||
locale.value = instance.proxy.$i18n.locale
|
||||
|
||||
return {
|
||||
title: state.title,
|
||||
loading,
|
||||
isAuthenticated,
|
||||
user,
|
||||
doLogin,
|
||||
doLogout,
|
||||
darkMode,
|
||||
locale,
|
||||
nav
|
||||
}
|
||||
}
|
||||
}
|
||||
const nav = ref(false)
|
||||
locale.value = instance.proxy.$i18n.locale
|
||||
const title = computed(() => state.title)
|
||||
</script>
|
||||
|
||||
+4
-1
@@ -6,6 +6,9 @@ export default defineNuxtConfig({
|
||||
alias: {
|
||||
tslib: 'tslib/tslib.es6.js'
|
||||
},
|
||||
bridge: {
|
||||
meta: true
|
||||
},
|
||||
build: {
|
||||
extend (config) {
|
||||
config.module.rules.push({
|
||||
@@ -33,7 +36,7 @@ export default defineNuxtConfig({
|
||||
prettify: false
|
||||
}
|
||||
},
|
||||
transpile: ['date-fns']
|
||||
transpile: ['date-fns', '@unhead/vue', 'unhead']
|
||||
},
|
||||
buildModules: [
|
||||
// https://go.nuxtjs.dev/eslint
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"eslint-plugin-nuxt": "^4.0.0",
|
||||
"eslint-plugin-vue": "^9.21.1",
|
||||
"husky": "^9.0.10",
|
||||
"nuxi": "^3.10.0",
|
||||
"postcss-html": "^1.6.0",
|
||||
"stylelint": "^14.16.1",
|
||||
"stylelint-config-recommended-vue": "^1.5.0",
|
||||
|
||||
+7
-14
@@ -2,20 +2,13 @@
|
||||
<filters />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Filters from '../components/pages/filters'
|
||||
import { useTranslation } from '../plugins/i18n'
|
||||
<script setup lang='ts'>
|
||||
import { useHead } from '@unhead/vue'
|
||||
import Filters from '../components/pages/filters/index.vue'
|
||||
import { useTranslation } from '~/plugins/i18n'
|
||||
|
||||
export default {
|
||||
name: 'FiltersPage',
|
||||
components: {
|
||||
Filters
|
||||
},
|
||||
head () {
|
||||
const { t } = useTranslation()
|
||||
return {
|
||||
const { t } = useTranslation()
|
||||
useHead({
|
||||
title: t('filters.title')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
+5
-12
@@ -2,20 +2,13 @@
|
||||
<events />
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
<script setup lang='ts'>
|
||||
import { useHead } from '@unhead/vue'
|
||||
import Events from '~/components/pages/events/index.vue'
|
||||
import { useTranslation } from '~/plugins/i18n'
|
||||
|
||||
export default {
|
||||
name: 'IndexPage',
|
||||
components: {
|
||||
Events
|
||||
},
|
||||
head () {
|
||||
const { t } = useTranslation()
|
||||
return {
|
||||
const { t } = useTranslation()
|
||||
useHead({
|
||||
title: t('events.title')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
+7
-14
@@ -2,20 +2,13 @@
|
||||
<origins />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Origins from '../components/pages/origins'
|
||||
import { useTranslation } from '../plugins/i18n'
|
||||
<script setup lang='ts'>
|
||||
import { useHead } from '@unhead/vue'
|
||||
import Origins from '../components/pages/origins/index.vue'
|
||||
import { useTranslation } from '~/plugins/i18n'
|
||||
|
||||
export default {
|
||||
name: 'OriginsPage',
|
||||
components: {
|
||||
Origins
|
||||
},
|
||||
head () {
|
||||
const { t } = useTranslation()
|
||||
return {
|
||||
const { t } = useTranslation()
|
||||
useHead({
|
||||
title: t('origins.title')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user