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

const role = inject('role') as string

defineProps<{ node: any }>()

const operateList = [
  { label: '用户发送文本私信', value: '0' },
  { label: '用户发送表情私信', value: '1' },
  { label: '用户发送卡片私信', value: '2' },
  { label: '在主页Tab提交预约', value: '3' }
]

const { connectionList } = useConnection()

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) }}
      {{ node.data.student?.app_name }}
    </el-form-item>
    <el-form-item label="正确答案">
      {{ operateList.find(item => item.value === node.data.teacher?.operate)?.label || '' }}
      {{ getConnectionLabel(node.data.teacher?.connection_id) }}
      {{ node.data.teacher?.app_name }}
    </el-form-item>
  </ConfigViewTemplate>
</template>
