<script setup>
import LabKit from '@/views/pages/overview/LabKit.vue';
import axios from '@axios';
// import HeathCare from '@images/pages/healthcare-wellness-wellbeing-first-aid-box-word-graphic.jpg';
const isLoadingVisible = ref(false);
const loginuser = ref('');
const scheduleDate = ref('');
const scheduleTime = ref('');
const timeZone = ref('');
const timeDifference = ref();
const timeUntilMeeting = ref('');
onMounted(() => {
    localStorage.setItem('isLogin', true);
    const patient_id = localStorage.getItem('patient_id')
    const access_token = localStorage.getItem('access_token');
    isLoadingVisible.value = true;
    axios.post('/api/agent-last-appointment-detail/' + patient_id, {
        headers: {
            'Authorization': `Bearer ${access_token}`,
        }
    })
        .then(response => {
            console.log('Response:', response.data);
            if (response.data) {
                let diffInMinutes = response.data.time_diff;
                let appointmentData = response.data.appointment
                let patientData = response.data.patient
                loginuser.value = patientData.first_name + ' ' + patientData.last_name;
                scheduleTime.value = appointmentData.appointment_time;
                timeZone.value = appointmentData.timezone;
                timeDifference.value = diffInMinutes;
                console.log(scheduleTime.value);
                const appointment_date = new Date(appointmentData.appointment_date);
                const formattedDate = new Intl.DateTimeFormat('en-US', {
                    year: 'numeric',
                    month: 'long',
                    day: 'numeric',
                }).format(appointment_date);
                console.log('formattedDate', formattedDate)
                scheduleDate.value = formattedDate;
                isLoadingVisible.value = false;
            } else {
                isLoadingVisible.value = false;
            }
        })
        .catch(error => {
            console.error('Error:', error);
        });

});






</script>

<template>
    <VContainer>
        <VDialog v-model="isLoadingVisible" width="110" height="150" color="primary">
            <VCardText class="" style="color: white !important;">
                <div class="demo-space-x">
                    <VProgressCircular :size="40" color="primary" indeterminate />
                </div>
            </VCardText>

        </VDialog>
        <VRow>
            <VCol cols="12" md="8">
                <LabKit :date="scheduleDate" :time="scheduleTime" :timezone="timeZone" :timeDiff="timeDifference" />
            </VCol>

        </VRow>
    </VContainer>
</template>
