<script lang="ts" setup>
import ListItem from './ListItem.vue'
import { useTaskStore } from '@/store/modules/task'

defineOptions({ name: 'WorkSheetList' })

defineProps({
  activeId: {
    type: String,
    required: true,
  },
  data: {
    type: Object as PropType<any[]>,
    required: true,
  },
})

const taskStore = useTaskStore()

function selectHandler(id: string, index: number) {
  taskStore.setActive(index)
}
</script>

<template>
  <n-scrollbar class="wrapper">
    <ListItem
      v-for="(item, index) in data" :key="item.id" :selected="activeId === item.formid" :list-item="item"
      @click="selectHandler(item.id, index)"
    />
  </n-scrollbar>
</template>

<style lang="less" scoped>
</style>
