import { View } from "@tarojs/components";
import style from "./index.module.less";
import { TAgentDetail } from "@/types/agent";
interface IProps {
  agent: TAgentDetail | null;
  chatInputActions: {
    sendChatMessage: (message: string) => Promise<void>;
  };
}
export default ({ agent, chatInputActions }: IProps) => {
  const { sendChatMessage } = chatInputActions;

  const handleClick = (q: string) => {
    sendChatMessage(q);
  };

  if (!agent) {
    return <></>;
  }

  let greeting = "";
  // 默认打招呼文案
  if (!agent.greeting) {
    greeting = `Hi～ 你好我是${agent.name}`;
  } else {
    // 用户自定义文案
    greeting = agent.greeting;
  }

  // 3个引导提问提示词
  const questions = agent.questionGuides ?? [];

  return (
    <View className={style.container}>
      <View className="flex flex-col gap-16">
        <View className="text-[#111A34] text-14 leading-28">{greeting}</View>
        {!!questions.length && (
          <View className="flex flex-col gap-8">
            {questions.map((q) => {
              return (
                <View
                  className="p-12 rounded-8 leading-22 text-12 bg-[#F4F9FF] text-[#414A64]"
                  onClick={() => handleClick(q)}
                >
                  {q}
                </View>
              );
            })}
          </View>
        )}
      </View>
    </View>
  );
};
