<script setup lang="ts">
import type { ExperimentVideoType } from '../types'
import VideoItem from './VideoItem.vue'
import { getExperimentVideoList } from '../api'

interface Props {
  competition_id: string
}
const props = defineProps<Props>()

let list = $ref<ExperimentVideoType[]>([])
function fetchInfo() {
  if (!props.competition_id) return
  getExperimentVideoList({ competition_id: props.competition_id }).then(res => {
    list = res.data.list
  })
}
watchEffect(() => {
  fetchInfo()
})

const isEmpty = $computed(() => {
  return !props.competition_id || !list.length
})
</script>

<template>
  <el-empty description="暂无数据" v-if="isEmpty" />
  <template v-else>
    <VideoItem v-for="item in list" :key="item.id" :data="item" :competition_id="competition_id"></VideoItem>
  </template>
</template>

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