<template>
  <div>
    <ModuleTitle :title="recommendTheme.themeName" />
    <div class="flex flex-row overflow-x-auto mt-1">
      <div v-for="(item, index) in recommendTheme.recommendPostsList" :key="index">
        <div class="flex flex-col items-start w-[188px] h-[154px] bg-white rounded-[10px] mr-2 relative"
          @click="sendReply(item)">
          <img class="w-[188px] h-[112px]" :src="item.coverPhoto">
          <span class="p-3 text-center font-medium text-xs text-[#333]">{{ item.topic }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from "vue";
import { emitter } from '@/utils/events'
import { SEND_MESSAGE_CONTENT_TEXT, SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
import ModuleTitle from "@/components/ModuleTitle/index.vue";

const props = defineProps({
  recommendTheme: {
    type: Object,
    default: {},
  },
});

const sendReply = (item) => {
  if (item.userInputContentType && item.userInputContentType === '1') {
    const commonItem = { type: item.userInputContent, title: item.topic }
    emitter.emit(SEND_MESSAGE_COMMAND_TYPE, commonItem);
    return;
  }
  emitter.emit(SEND_MESSAGE_CONTENT_TEXT, item.userInputContent);
};
</script>
