<script setup>
import { useI18n } from 'vue-i18n';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();

const props = defineProps({
    dataKey: {
        type: String,
        required: true,
    },
});

const emit = defineEmits(['search']);
</script>

<template>
    <VnFilterPanel
        :data-key="props.dataKey"
        :search-button="true"
        @search="emit('search')"
    >
        <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>
                <QItemSection>
                    <VnInput :label="t('Name')" v-model="params.name" is-outlined />
                </QItemSection>
            </QItem>
            <QItem>
                <QItemSection>
                    <VnInput v-model="params.code" :label="t('Code')" is-outlined />
                </QItemSection>
            </QItem>
        </template>
    </VnFilterPanel>
</template>

<i18n>
en:
    params:
        name: Name
        code: Code
es:
    params:
        name: Nombre
        code: Código
    Name: Nombre
    Code: Código
</i18n>
