<template>
  <Calendar :doors="doors" />
</template>

<script lang="ts">
import { DoorsSaved } from "@/lib/api";
import { Door } from "@/lib/door";
import { Options, Vue } from "vue-class-component";

import Calendar from "./Calendar.vue";

@Options({
  components: {
    Calendar,
  },
})
export default class extends Vue {
  public doors: Door[] = [];

  public mounted(): void {
    this.$advent22
      .api_get<DoorsSaved>("user/doors")
      .then((data) => {
        this.doors.length = 0;

        for (const value of data) {
          this.doors.push(Door.load(value));
        }
      })
      .catch((error) => alert(this.$advent22.format_user_error(error)));
  }
}
</script>
