<script setup lang="ts">
import ConfigViewTemplate from '../../ConfigViewTemplate.vue'
import { useConnection } from '../../../composables/useAllData'

const role = inject('role') as string

defineProps<{ node: any }>()

const { connectionList } = useConnection()

const operateList = [
  { label: '被用户关注', value: '0' },
  { label: '主页被点赞', value: '1' },
  { label: '主页被收藏', value: '2' },
  { label: '笔记被点赞', value: '3' },
  { label: '笔记被收藏', value: '4' },
  { label: '笔记被转发', value: '5' }
]

const getConnectionLabel = function (id: string) {
  return connectionList.value.find(item => item.id === id)?.name || ''
}
</script>

<template>
  <ConfigViewTemplate :node="node">
    <el-form-item :label="role === 'student' ? '我的答案' : '学生答案'">
      {{ operateList.find(item => item.value === node.data.student?.operate)?.label || '' }}
      {{ getConnectionLabel(node.data.student?.connection_id) }}
    </el-form-item>
    <el-form-item label="正确答案">
      {{ operateList.find(item => item.value === node.data.teacher?.operate)?.label || '' }}
      {{ getConnectionLabel(node.data.teacher?.connection_id) }}
    </el-form-item>
  </ConfigViewTemplate>
</template>
