<template>
    <div>
        <LadaDialog :visible="showEditDialog" variant="modal-full">
            <template #header>
                <div class="modal-header">
                    <h5 class="modal-title">{{ updateStore.actionType.Title }}</h5>
                    <button @click="close" type="button" class="close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            </template>

            <template #body>
                <update-address v-if="updateStore.actionType.Name === updateStore.actionTypes.SourceAddress.Name"
                    :addressId="updateStore.addressId" @cancel="close"></update-address>

                <update-address v-if="updateStore.actionType.Name === updateStore.actionTypes.DestAddress.Name"
                    :addressId="updateStore.addressId" @cancel="close"></update-address>

                <update-fin v-if="updateStore.actionType.Name === updateStore.actionTypes.Finance.Name"
                    :orderFinId="updateStore.orderFinance.Id" :customerId="updateStore.orderFinance.CustomerId"
                    @cancel="close"></update-fin>

                <update-package v-if="updateStore.actionType.Name === updateStore.actionTypes.Packages.Name"
                    :orderId="updateStore.orderId" @cancel="close"></update-package>

                <p v-if="updateStore.actionName === null">
                    Nội dung dialog
                </p>
            </template>

        </LadaDialog>
    </div>
</template>
<script setup>
import { ref, reactive, onMounted, watch } from 'vue';
import { updateOrderStore } from '../../listStore';
const updateStore = updateOrderStore();


import UpdateAddress from "@/views/orders/shared/updateAddress.vue";
import UpdateFin from "@/views/orders/shared/updateFin.vue";
import UpdatePackage from "@/views/orders/shared/updatePackage.vue";


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

const props = defineProps({
    isShowdialog: Boolean
});


//#region DATA
// var items = reactive([]);
// var totalWeight = ref(0);
const showEditDialog = ref(false);
const dialogTitle = ref("");
//#endregion


//#region methods
function edit() {
    showEditDialog.value = true;
}
function close() {
    showEditDialog.value = false;
    emit('updated');
}
//#endregion



//#region Events
onMounted(async () => {
    console.log(updateStore);
})
//#endregion

// watch(selected, (nval) => {
//     console.log(nval);
// })

watch(() => props.isShowdialog, (nval) => {
    if (nval) {
        showEditDialog.value = true;
    }

})

</script>