Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<template>
<div v-if="loaded.shows">
<AddShowModal v-if="!modal" ref="addShowModal" />
<b-button
v-if="authStore.isSuperuser"
variant="primary"
data-testid="show-selector:add-show"
class="md:tw-whitespace-nowrap"
@click="resolvedModal.openModal()"
>
{{ t('showCreator.title') }}
</b-button>
</div>
</template>
<script lang="ts" setup>
import { useStore } from 'vuex'
import { computed, ref } from 'vue'
import AddShowModal from './AddShowModal.vue'
import { useI18n } from '@/i18n'
import { useAuthStore } from '@/stores/auth'
type Modal = {
openModal: () => void
}
const props = defineProps<{
modal?: Modal
}>()
const store = useStore()
const authStore = useAuthStore()
const { t } = useI18n()
const addShowModal = ref<Modal>()
const resolvedModal = computed(() => (props.modal ?? addShowModal) as unknown as Modal)
const loaded = computed(() => ({
shows: store.state.shows.loaded.shows,
types: store.state.shows.loaded.types,
fundingCategories: store.state.shows.loaded.fundingcategories,
}))
// TODO: not sure these belong here.
if (!loaded.value.types) {
store.dispatch('shows/fetchMetaArray', { property: 'types', onlyActive: true })
}
if (!loaded.value.fundingCategories) {
store.dispatch('shows/fetchMetaArray', { property: 'fundingcategories', onlyActive: true })
}
</script>