mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-05 17:30:48 +08:00
update tasks to use types
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user