<script>
    import axios from "axios";

    export default {
        name: "ScheduleTable",
        data: () => ({
            schedules: [],
            fetching: true
        }),
        methods: {
            parseDate(date){
                let dateArr = date.split("-");
                return dateArr[2] + "." + dateArr[1];
            }
        },
        mounted() {
            axios
                .get('/api/v1/schedules')
                .then(response => {
                    this.schedules = response.data;
                    this.fetching = false;
                });
        }
    }
</script>

<template>
    <div class="w-100 d-flex justify-center">
        <v-skeleton-loader v-if="fetching" type="table"/>
        <v-table v-else class="text-h5 w-66">
            <tbody>
            <tr v-for="schedule in schedules">
                <td>{{ parseDate(schedule.current_date) }} {{ schedule.weekday_name }} {{ schedule.stream_time }}</td>
                <td>{{ schedule.name }}</td>
            </tr>
            </tbody>
        </v-table>
    </div>
</template>

<style scoped>

</style>
