<template>
    <div id="app">
        <AddItemModal v-if="addItemModalOpen && isLoggedIn" @close="closeAddItemModal()" isModal="true"/>
        <AddTicketModal v-if="addTicketModalOpen && isLoggedIn" @close="closeAddTicketModal()" isModal="true"/>
        <AddBoxModal v-if="showAddBoxModal && isLoggedIn" @close="closeAddBoxModal()" isModal="true"/>
        <Navbar v-if="isLoggedIn" @addItemClicked="openAddItemModal()" @addTicketClicked="openAddTicketModal()"/>
        <router-view/>
    </div>
</template>

<script>
import Navbar from '@/components/Navbar';
import AddItemModal from '@/components/AddItemModal';
import {mapState, mapMutations, mapActions, mapGetters} from 'vuex';
import AddTicketModal from "@/components/AddTicketModal.vue";
import AddBoxModal from "@/components/AddBoxModal.vue";

export default {
    name: 'app',
    components: {AddBoxModal, Navbar, AddItemModal, AddTicketModal},
    computed: {
        ...mapState(['loadedItems', 'layout', 'toasts', 'showAddBoxModal']),
        ...mapGetters(['isLoggedIn']),
    },
    data: () => ({
        addItemModalOpen: false,
        addTicketModalOpen: false
    }),
    methods: {
        ...mapMutations(['removeToast', 'createToast', 'closeAddBoxModal', 'openAddBoxModal']),
        ...mapActions(['loadEvents']),
        openAddItemModal() {
            this.addItemModalOpen = true;
        },
        openAddTicketModal() {
            this.addTicketModalOpen = true;
        },
        closeAddItemModal() {
            this.addItemModalOpen = false;
        },
        closeAddTicketModal() {
            this.addTicketModalOpen = false;
        }
    },
    created: function () {
        document.title = document.location.hostname;
    }
};
</script>

<style>
body, html, #app {
    background: #000;
}
</style>

