<script setup>
import { onMounted, 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({
    text: null,
});

onMounted(() => {
    initialData.clientFk = `${route.params.id}`;
});

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

<template>
    <FormModel
        :form-initial-data="initialData"
        :observe-form-changes="false"
        @on-data-saved="toCustomerNotes()"
        url-create="ClientObservations"
    >
        <template #form="{ data }">
            <VnRow class="row q-gutter-md q-mb-md">
                <div class="col">
                    <QInput :label="t('Note')" type="textarea" v-model="data.text" />
                </div>
            </VnRow>
        </template>
    </FormModel>
</template>

<i18n>
es:
    Note: Nota
</i18n>
