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

import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FormModelPopup from 'src/components/FormModelPopup.vue';

const emit = defineEmits(['onDataSaved']);

const { t } = useI18n();

const initialData = reactive({
    nif: null,
    fiscalName: null,
    street: null,
    phone: null,
});

const onDataSaved = (dataSaved) => {
    emit('onDataSaved', dataSaved);
};
</script>

<template>
    <FormModelPopup
        :title="t('New customs agent')"
        url-create="CustomsAgents"
        model="customer"
        :form-initial-data="initialData"
        @on-data-saved="onDataSaved($event)"
    >
        <template #form-inputs="{ data }">
            <VnRow class="row q-gutter-md q-mb-md">
                <div class="col">
                    <VnInput :label="t('NIF')" :required="true" v-model="data.nif" />
                </div>
                <div class="col">
                    <VnInput
                        :label="t('Fiscal name')"
                        :required="true"
                        v-model="data.fiscalName"
                    />
                </div>
            </VnRow>
            <VnRow class="row q-gutter-md q-mb-md">
                <div class="col">
                    <VnInput :label="t('Street')" v-model="data.street" />
                </div>
                <div class="col">
                    <VnInput :label="t('Phone')" v-model="data.phone" />
                </div>
            </VnRow>
        </template>
    </FormModelPopup>
</template>

<i18n>
es:
    New customs agent: Nuevo agente de aduanas
    NIF: NIF
    Fiscal name: Nombre fiscal
    Street: Dirección fiscal
    Phone: Teléfono
</i18n>
