<template>
  <widget-page
    @load="infinityLoad"
    :disable="isDisableInfinity"
    :is-loading="isInitialLoading"
  >
    <threads :threads="threads" />
    <widget-page-state
      v-if="!isInitialLoading && !threads.length"
      @submit="toCreateRoute"
      submit-label="Написать сообщение"
      icon="la la-home"
      title="В заказе нет сообщений"
      submit-color="primary"
      has-btn
    />
  </widget-page>
</template>

<script lang="ts">
import { Component } from 'vue-property-decorator'
import { GetThreadsPayload } from '@/widgets/messages/services/ThreadService'
import WidgetPage from '@/widgets/base/components/widget-page/WidgetPage.vue'
import Threads from '@/widgets/messages/components/Threads.vue'
import BaseThreadsPage from '@/widgets/messages/pages/BaseThreadsPage'
import WidgetPageState from '@/widgets/base/components/widget-page/WidgetPageState.vue'
import { hashNavRoutes } from '@/widgets/messages/router/hashRoutes'

@Component({
  components: { WidgetPageState, Threads, WidgetPage },
})
export default class OrderThreadsPage extends BaseThreadsPage {
  get orderName() {
    return this.messageModule.orderName
  }

  get initialPayload(): GetThreadsPayload {
    return {
      orderName: this.orderName,
    }
  }

  toCreateRoute() {
    return this.$router.push({
      hash: hashNavRoutes.createThread.compile({ orderName: this.orderName }),
    })
  }
}
</script>
