mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-10 00:20:06 +08:00
Merge pull request #684 from melvinebenezer/592_non_empty_text
#592 non empty text
This commit is contained in:
@@ -11,11 +11,16 @@ export const CreateTask = ({ task, taskType, isDisabled, onReplyChanged }: TaskS
|
||||
const labelColor = useColorModeValue("gray.600", "gray.400");
|
||||
|
||||
const [inputText, setInputText] = useState("");
|
||||
|
||||
const textChangeHandler = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
const text = event.target.value;
|
||||
onReplyChanged({ content: { text }, state: "VALID" });
|
||||
setInputText(text);
|
||||
const isTextBlank = !text || /^\s*$/.test(text) ? true : false;
|
||||
if (!isTextBlank) {
|
||||
onReplyChanged({ content: { text }, state: "VALID" });
|
||||
setInputText(text);
|
||||
} else {
|
||||
onReplyChanged({ content: { text }, state: "INVALID" });
|
||||
setInputText("");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -51,6 +51,8 @@ export const Task = ({ frontendId, task, trigger, mutate }) => {
|
||||
if (taskStatus !== "DEFAULT") setTaskStatus("DEFAULT");
|
||||
} else if (state.state === "VALID") {
|
||||
if (taskStatus !== "SUBMITABLE") setTaskStatus("SUBMITABLE");
|
||||
} else if (state.state == "INVALID") {
|
||||
setTaskStatus("NOT_SUBMITTABLE");
|
||||
}
|
||||
}).current;
|
||||
|
||||
|
||||
@@ -6,5 +6,9 @@ export interface TaskReplyDefault<T> {
|
||||
content: T;
|
||||
state: "DEFAULT";
|
||||
}
|
||||
export interface TaskReplyInValid<T> {
|
||||
content: T;
|
||||
state: "INVALID";
|
||||
}
|
||||
|
||||
export type TaskReplyState<T> = TaskReplyValid<T> | TaskReplyDefault<T>;
|
||||
export type TaskReplyState<T> = TaskReplyValid<T> | TaskReplyDefault<T> | TaskReplyInValid<T>;
|
||||
|
||||
Reference in New Issue
Block a user