<template>
  <div>
    <app-wadiz-welcome />
    <!-- <app-board-list
      v-model="selectedSort"
      :title="compdata.title"
      :sortOptions="sortOptions"
      :userRole="userRole"
      :current-page="currentPage"
      :total-pages="totalPages"
      :page-numbers="pageNumbers"
      :show-select-boxes="showSelectBoxes"
      :uploadRoute="currentUploadRoute"
      @toggle-select-boxes="showSelectBoxes = !showSelectBoxes"
      @delete-selected="onDeleteSelected"
      @go-to-page="onGoToPage"
      @prev-page="onPrevPage"
      @next-page="onNextPage"
      :isLoading="isLoading"
      :loadingMessage="loadingMessage"
    >
      <template #list>
        <app-board-list-single
          v-for="item in currentItems"
          :key="item.docId"
          :userId="item.userId"
          :item="item"
          :showSelectBox="showSelectBoxes"
          @select="onToggleSelect(item)"
          :iconName="['fas', 'bell']"
          :routeName="currentBoardRouteName"
        />
      </template>
    </app-board-list> -->
  </div>
</template>

<script setup lang="ts">
import AppWadizWelcome from '~/components/WadizWelcome.vue';
import AppBoardsHeader from '@/components/boards/BoardHeader.vue';
import AppBoardList from '@/components/boards/BoardList.vue';
import AppBoardListSingle from '@/components/boards/BoardListSingle.vue';
import type { OrderByDirection, BoardAccessMode } from '@/types';

//customize
const access: BoardAccessMode = 'public';
const currentCollection = 'wadizes';
const currentUploadRoute = '/wadiz/upload';
const currentBoardRouteName = '/wadiz';
const compData = {
  title: '공지사항',
  itemsPerPage: 20,
  defaultSort: 'desc' as OrderByDirection,
};
const loading = '게시물을 불러오는 중입니다...';
import { useBoardList } from '@/composables/useBoardList';

// destructure only the things you actually need
const {
  isLoading,
  loadingMessage,
  compdata,
  currentItems,
  currentPage,
  pageNumbers,
  selectedSort,
  sortOptions,
  userRole,
  totalPages,
  selectedItems,
  showSelectBoxes,
  onToggleSelect,
  onDeleteSelected,
  onGoToPage,
  onPrevPage,
  onNextPage,
} = useBoardList(currentCollection, {
  title: compData.title,
  itemsPerPage: compData.itemsPerPage,
  defaultSort: compData.defaultSort,
  access: access,
  loadingMessage: loading,
});

// no more fetchBoardsAndUpdateItems or onBeforeMount
</script>
