<script setup>
import { useI18n } from 'vue-i18n';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FormModelPopup from './FormModelPopup.vue';

const emit = defineEmits(['onDataSaved']);
const { t } = useI18n();
</script>
<template>
    <FormModelPopup
        url-create="Expenses"
        model="Expense"
        :title="t('New expense')"
        :form-initial-data="{ id: null, isWithheld: false, name: null }"
        @on-data-saved="emit('onDataSaved', $event)"
    >
        <template #form-inputs="{ data, validate }">
            <VnRow>
                <VnInput
                    :label="`${t('globals.code')}`"
                    v-model="data.id"
                    :required="true"
                    :rules="validate('expense.code')"
                />
                <QCheckbox
                    dense
                    size="sm"
                    :label="`${t('It\'s a withholding')}`"
                    v-model="data.isWithheld"
                    :rules="validate('expense.isWithheld')"
                />
            </VnRow>
            <VnRow>
                <VnInput
                    :label="`${t('globals.description')}`"
                    v-model="data.name"
                    :required="true"
                    :rules="validate('expense.description')"
                />
            </VnRow>
        </template>
    </FormModelPopup>
</template>

<i18n>
es:
    New expense: Nuevo gasto
    It's a withholding: Es una retención
</i18n>
