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

import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';

const { t } = useI18n();
const route = useRoute();
const router = useRouter();

const initialData = reactive({
    credit: null,
});

const toCustomerCredits = () => {
    router.push({
        name: 'CustomerCredits',
        params: {
            id: route.params.id,
        },
    });
};
</script>

<template>
    <FormModel
        :form-initial-data="initialData"
        :observe-form-changes="false"
        :url-update="`/Clients/${route.params.id}`"
        @on-data-saved="toCustomerCredits()"
    >
        <template #form="{ data }">
            <VnRow class="row q-gutter-md q-mb-md">
                <div class="col">
                    <QInput
                        :label="t('Credit')"
                        type="number"
                        v-model.number="data.credit"
                    />
                </div>
            </VnRow>
        </template>
    </FormModel>
</template>

<i18n>
es:
    Credit: Crédito
</i18n>
