update tasks to use types

This commit is contained in:
AbdBarho
2023-02-03 08:30:01 +01:00
parent db5ea75796
commit ae829d0e3d
4 changed files with 8 additions and 5 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ 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 { CreateTaskReply } from "src/types/TaskResponses";
import { CreateTaskType } from "src/types/Tasks";
export const CreateTask = ({
@@ -17,7 +18,7 @@ export const CreateTask = ({
isDisabled,
onReplyChanged,
onValidityChanged,
}: TaskSurveyProps<CreateTaskType, { text: string }>) => {
}: TaskSurveyProps<CreateTaskType, CreateTaskReply>) => {
const { t, i18n } = useTranslation(["tasks", "common"]);
const cardColor = useColorModeValue("gray.50", "gray.800");
const titleColor = useColorModeValue("gray.800", "gray.300");
@@ -6,6 +6,7 @@ import { SurveyCard } from "src/components/Survey/SurveyCard";
import { TaskSurveyProps } from "src/components/Tasks/Task";
import { TaskHeader } from "src/components/Tasks/TaskHeader";
import { TaskType } from "src/types/Task";
import { EvaluateTaskReply } from "src/types/TaskResponses";
import { RankTaskType } from "src/types/Tasks";
export const EvaluateTask = ({
@@ -15,7 +16,7 @@ export const EvaluateTask = ({
isDisabled,
onReplyChanged,
onValidityChanged,
}: TaskSurveyProps<RankTaskType, { ranking: number[] }>) => {
}: TaskSurveyProps<RankTaskType, EvaluateTaskReply>) => {
const cardColor = useColorModeValue("gray.50", "gray.800");
const [ranking, setRanking] = useState<number[]>(null);
@@ -6,6 +6,7 @@ import { MessageTable } from "src/components/Messages/MessageTable";
import { TwoColumnsWithCards } from "src/components/Survey/TwoColumnsWithCards";
import { TaskSurveyProps } from "src/components/Tasks/Task";
import { TaskHeader } from "src/components/Tasks/TaskHeader";
import { LabelTaskReply } from "src/types/TaskResponses";
import { LabelTaskType } from "src/types/Tasks";
const isRequired = (labelName: string, requiredLabels?: string[]) => {
@@ -18,7 +19,7 @@ export const LabelTask = ({
isEditable,
onReplyChanged,
onValidityChanged,
}: TaskSurveyProps<LabelTaskType, { text: string; labels: Record<string, number>; message_id: string }>) => {
}: TaskSurveyProps<LabelTaskType, LabelTaskReply>) => {
const { t } = useTranslation("labelling");
const [values, setValues] = useState<number[]>(new Array(task.labels.length).fill(null));
const [userInputMade, setUserInputMade] = useBoolean(false);
+2 -2
View File
@@ -53,12 +53,12 @@ interface UpdateValidity {
replyValidity: TaskReplyValidity;
}
export interface TaskSurveyProps<TaskType extends BaseTask, T> {
export interface TaskSurveyProps<TaskType extends BaseTask, ReplyContent> {
task: TaskType;
taskType: TaskInfo;
isEditable: boolean;
isDisabled?: boolean;
onReplyChanged: (content: T) => void;
onReplyChanged: (content: ReplyContent) => void;
onValidityChanged: (validity: TaskReplyValidity) => void;
}