import { Box, Stack, Text, useColorModeValue } from "@chakra-ui/react"; import { useTranslation } from "next-i18next"; import { useState } from "react"; import { MessageTable } from "src/components/Messages/MessageTable"; import { TrackedTextarea } from "src/components/Survey/TrackedTextarea"; import { TwoColumnsWithCards } from "src/components/Survey/TwoColumnsWithCards"; import { TaskSurveyProps } from "src/components/Tasks/Task"; import { TaskHeader } from "src/components/Tasks/TaskHeader"; import { getTypeSafei18nKey } from "src/lib/i18n"; import { TaskType } from "src/types/Task"; import { CreateTaskType } from "src/types/Tasks"; export const CreateTask = ({ task, taskType, isEditable, isDisabled, onReplyChanged, onValidityChanged, }: TaskSurveyProps) => { const { t, i18n } = useTranslation(["tasks", "common"]); const cardColor = useColorModeValue("gray.50", "gray.800"); const titleColor = useColorModeValue("gray.800", "gray.300"); const [inputText, setInputText] = useState(""); const textChangeHandler = (event: React.ChangeEvent) => { const text = event.target.value; onReplyChanged({ text }); const isTextBlank = !text || /^\s*$/.test(text); if (!isTextBlank) { onValidityChanged("VALID"); setInputText(text); } else { onValidityChanged("INVALID"); setInputText(""); } }; return (
<> {task.type !== TaskType.initial_prompt && ( )} <> {!!i18n.exists(`tasks:${taskType.id}.instruction`) && ( {t(getTypeSafei18nKey(`tasks:${taskType.id}.instruction`))} )}
); };