<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';

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

const { t } = useI18n();
const props = defineProps({
    dataKey: {
        type: String,
        required: true,
    },
});
const states = ref();
</script>
<template>
    <FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load />
    <VnFilterPanel :data-key="props.dataKey" :search-button="true">
        <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('Customer ID')"
                        v-model="params.clientFk"
                        is-outlined
                    />
                </QItemSection>
            </QItem>
            <QItem>
                <QItemSection>
                    <VnInput v-model="params.fi" :label="t('FI')" is-outlined />
                </QItemSection>
            </QItem>
            <QItem>
                <QItemSection>
                    <VnInputNumber
                        :label="t('Amount')"
                        v-model="params.amount"
                        is-outlined
                    />
                </QItemSection>
            </QItem>
            <QItem>
                <QItemSection>
                    <QInput
                        :label="t('Min')"
                        dense
                        lazy-rules
                        outlined
                        rounded
                        type="number"
                        v-model.number="params.min"
                    />
                </QItemSection>
                <QItemSection>
                    <QInput
                        :label="t('Max')"
                        dense
                        lazy-rules
                        outlined
                        rounded
                        type="number"
                        v-model.number="params.max"
                    />
                </QItemSection>
            </QItem>
            <QItem>
                <QItemSection>
                    <QCheckbox
                        :label="t('Has PDF')"
                        toggle-indeterminate
                        v-model="params.hasPdf"
                    />
                </QItemSection>
            </QItem>
            <QSeparator />
            <QExpansionItem :label="t('More options')" expand-separator>
                <QItem>
                    <QItemSection>
                        <VnInputDate
                            v-model="params.issued"
                            :label="t('Issued')"
                            is-outlined
                        />
                    </QItemSection>
                </QItem>
                <QItem>
                    <QItemSection>
                        <VnInputDate
                            v-model="params.created"
                            :label="t('Created')"
                            is-outlined
                        />
                    </QItemSection>
                </QItem>
                <QItem>
                    <QItemSection>
                        <VnInputDate
                            v-model="params.dued"
                            :label="t('Dued')"
                            is-outlined
                        />
                    </QItemSection>
                </QItem>
            </QExpansionItem>
        </template>
    </VnFilterPanel>
</template>

<i18n>
en:
    params:
        search: Contains
        clientFk: Customer
        fi: FI
        amount: Amount
        min: Min
        max: Max
        hasPdf: Has PDF
        issued: Issued
        created: Created
        dued: Dued
es:
    params:
        search: Contiene
        clientFk: Cliente
        fi: CIF
        amount: Importe
        min: Min
        max: Max
        hasPdf: Tiene PDF
        issued: Emitida
        created: Creada
        dued: Vencida
    Customer ID: ID cliente
    FI: CIF
    Amount: Importe
    Has PDF: Tiene PDF
    Issued: Fecha emisión
    Created: Fecha creación
    Dued: Fecha vencimiento
    More options: Más opciones
</i18n>
