<script setup>
import LeftMenu from 'components/LeftMenu.vue';
import { getUrl } from 'composables/getUrl';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import ClaimDescriptor from './ClaimDescriptor.vue';

import { onMounted, onUnmounted } from 'vue';
const stateStore = useStateStore();
const { t } = useI18n();
const route = useRoute();
const $props = defineProps({
    id: {
        type: Number,
        required: false,
        default: null,
    },
});
const entityId = computed(() => {
    return $props.id || route.params.id;
});

onMounted(() => {
    console.log('MOUNTED', stateStore.isSubToolbarShown());
    stateStore.toggleSubToolbar();
    console.log('MOUNTED', stateStore.isSubToolbarShown());
});

onUnmounted(() => {
    console.log('MOUNTED', stateStore.isSubToolbarShown());
    stateStore.toggleSubToolbar();
    console.log('MOUNTED', stateStore.isSubToolbarShown());
});
</script>
<template>
    <Teleport to="#searchbar" v-if="stateStore.isHeaderMounted()">
        <VnSearchbar
            data-key="ClaimList"
            url="Claims/filter"
            :label="t('Search claim')"
            :info="t('You can search by claim id or customer name')"
        />
    </Teleport>
    <QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
        <QScrollArea class="fit">
            <ClaimDescriptor />
            <QSeparator />
            <LeftMenu source="card" />
        </QScrollArea>
    </QDrawer>
    <QPageContainer>
        <QPage>
            <QToolbar class="bg-vn-dark justify-end">
                <div id="st-data"></div>
                <QSpace />
                <div id="st-actions"></div>
            </QToolbar>
            <div class="q-pa-md"><RouterView></RouterView></div>
        </QPage>
    </QPageContainer>
</template>

<i18n>
es:
    Search claim: Buscar reclamación
    You can search by claim id or customer name: Puedes buscar por id de la reclamación o nombre del cliente
    Details: Detalles
    Notes: Notas
    Action: Acción
</i18n>
