<script setup>
import { ref } from 'vue';

import VnInputDate from 'src/components/common/VnInputDate.vue';
import split from './components/split';
const emit = defineEmits(['ticketTransfered']);

const $props = defineProps({
    ticket: {
        type: [Array, Object],
        default: () => {},
    },
});

const splitDate = ref(Date.vnNew());

const splitSelectedRows = async () => {
    const tickets = Array.isArray($props.ticket) ? $props.ticket : [$props.ticket];
    await split(tickets, splitDate.value);
    emit('ticketTransfered', tickets);
};
</script>

<template>
    <VnInputDate class="q-mr-sm" :label="$t('New date')" v-model="splitDate" clearable />
    <QBtn class="q-mr-sm" color="primary" label="Split" @click="splitSelectedRows"></QBtn>
</template>
<style lang="scss">
.q-table__bottom.row.items-center.q-table__bottom--nodata {
    border-top: none;
}
</style>
<i18n>
es:
    Sales to transfer: Líneas a transferir
    Destination ticket: Ticket destinatario
</i18n>
