<script setup lang="ts">
import ConfigViewTemplate from '../../ConfigViewTemplate.vue'
import { useMaterial, useConnection } from '../../../composables/useAllData'
import { useMapStore } from '@/stores/map'

const role = inject('role') as string

defineProps<{ node: any }>()

const operateList = ref([
  { label: '向用户发送文本私信', value: '0' },
  { label: '向用户发送图片私信', value: '1' },
  { label: '向用户发送视频私信', value: '2' }
])

const { connectionList } = useConnection()

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

const materialTypeList = useMapStore().getMapValuesByKey('experiment_marketing_material_type')

const { materialList } = useMaterial()
</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) }}
      发送{{ materialTypeList.find(item => item.value === node.data.student?.material_type)?.label }}
      {{ materialList.find(item => item.id === node.data.student?.material_id)?.name }}
    </el-form-item>
    <el-form-item label="正确答案">
      {{ operateList.find(item => item.value === node.data.teacher?.operate)?.label || '' }}
      {{ getConnectionLabel(node.data.teacher?.connection_id) }}
      发送{{ materialTypeList.find(item => item.value === node.data.teacher?.material_type)?.label }}
      {{ materialList.find(item => item.id === node.data.teacher?.material_id)?.name }}
    </el-form-item>
  </ConfigViewTemplate>
</template>
