<script setup>
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
import { useStateStore } from 'stores/useStateStore';

import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';

const { t } = useI18n();
const props = defineProps({
    dataKey: {
        type: String,
        required: true,
    },
});
const stateStore = useStateStore();
const emit = defineEmits(['set-user-params']);
const setUserParams = (params) => {
    emit('set-user-params', params);
};
onMounted(async () => {
    stateStore.rightDrawer = true;
});
</script>

<template>
    <VnFilterPanel
        :data-key="props.dataKey"
        :search-button="true"
        search-url="table"
        @set-user-params="setUserParams"
    >
        <template #tags="{ tag, formatFn }">
            <div class="q-gutter-x-xs">
                <strong>{{ t(`params.${tag.label}`) }}: </strong>
                <span>{{ formatFn(tag.value) }}</span>
            </div>
        </template>
        <template #body="{ params }">
            <QItem class="q-my-sm">
                <QItemSection>
                    <VnInputDate
                        id="date"
                        v-model="params.dated"
                        :label="t('Date')"
                        is-outlined
                    />
                </QItemSection>
            </QItem>
        </template>
    </VnFilterPanel>
</template>
<i18n>
    en:
        params:
            dated: Date
            workerFk: Worker
    es:
        Date: Fecha
        params:
            dated: Date
            workerFk: Trabajador
</i18n>
