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

import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnBankDetailsForm from 'src/components/common/VnBankDetailsForm.vue';

const { t } = useI18n();
const route = useRoute();
</script>

<template>
    <FormModel :url-update="`Clients/${route.params.id}`" auto-load model="Customer">
        <template #form="{ data }">
            <VnRow>
                <VnSelect
                    auto-load
                    url="PayMethods"
                    :label="t('Billing data')"
                    hide-selected
                    option-label="name"
                    option-value="id"
                    v-model="data.payMethodFk"
                />
                <VnInput :label="t('Due day')" clearable v-model="data.dueDay" />
            </VnRow>
            <VnRow>
                <VnBankDetailsForm
                    v-model:iban="data.iban"
                    v-model:bankEntityFk="data.bankEntityFk"
                    @update-bic="
                        ({ iban, bankEntityFk }) => {
                            if (!iban || !bankEntityFk) return;
                            data.iban = iban;
                            data.bankEntityFk = bankEntityFk;
                        }
                    "
                />
            </VnRow>
            <VnRow>
                <QCheckbox :label="t('Received LCR')" v-model="data.hasLcr" />
                <QCheckbox :label="t('VNL core received')" v-model="data.hasCoreVnl" />
                <QCheckbox :label="t('VNL B2B received')" v-model="data.hasSepaVnl" />
            </VnRow>
        </template>
    </FormModel>
</template>

<i18n>
es:
    Billing data: Forma de pago
    Due day: Vencimiento
    IBAN: IBAN
    Swift / BIC: Swift / BIC
    Received LCR: Recibido LCR
    VNL core received: Recibido core VNL
    VNL B2B received: Recibido B2B VNL
</i18n>
