+
+
+
+
+
+
+
+
+
+
+
+
+ {type === "structured" && (
+
+
+
+
+ )}
+
+
+
+
+ updateField("required", val)}
+ id={`required-${getQuestionPath()}`}
+ />
+
+
+
+
+ updateField("repeats", val)}
+ id={`repeats-${getQuestionPath()}`}
+ />
+
+
+
+
+ updateField("collect_time", val)}
+ id={`collect_time-${getQuestionPath()}`}
+ />
+
+
+
+
+ updateField("collect_performer", val)}
+ id={`collect_performer-${getQuestionPath()}`}
+ />
+
+
+
+
+ updateField("collect_body_site", val)}
+ id={`collect_body_site-${getQuestionPath()}`}
+ />
+
+
+
+
+ updateField("collect_method", val)}
+ id={`collect_method-${getQuestionPath()}`}
+ />
+
+
+
+
+ updateField("read_only", val)}
+ id={`read_only-${getQuestionPath()}`}
+ />
+
+
+
+
+
+
+ {type === "choice" && (
+
+
+
+
+
+
+ {(!question.answer_value_set ||
+ question.answer_value_set === "custom") && (
+
+ {(answer_option || []).map((opt, idx) => (
+
+ ))}
+
+
+ )}
+
+
+
+
+
+ {(question.enable_when || []).length > 0 && (
+
+
+
+
+ )}
+ {(question.enable_when || []).map((condition, idx) => (
+
+
+
+ {
+ const newConditions = [
+ ...(question.enable_when || []),
+ ];
+ newConditions[idx] = {
+ ...condition,
+ question: e.target.value,
+ };
+ updateField("enable_when", newConditions);
+ }}
+ placeholder="Question Link ID"
+ />
+
+
+
+
+
+
+
+
+ {condition.operator === "exists" ? (
+
+ ) : (
+ {
+ const newConditions = [
+ ...(question.enable_when || []),
+ ];
+ const value = e.target.value;
+ let newCondition;
+
+ if (
+ [
+ "greater",
+ "less",
+ "greater_or_equals",
+ "less_or_equals",
+ ].includes(condition.operator)
+ ) {
+ newCondition = {
+ question: condition.question,
+ operator: condition.operator as
+ | "greater"
+ | "less"
+ | "greater_or_equals"
+ | "less_or_equals",
+ answer: Number(value),
+ };
+ } else {
+ newCondition = {
+ question: condition.question,
+ operator: condition.operator as
+ | "equals"
+ | "not_equals",
+ answer: value,
+ };
+ }
+
+ newConditions[idx] = newCondition;
+ updateField("enable_when", newConditions);
+ }}
+ placeholder="Answer value"
+ />
+ )}
+
+
+
+
+ ))}
+
+
+
+
+ )}
+
+ {type === "group" && (
+
+
+
+
+
+
+
{
+ if (!result.destination) return;
+
+ const items = Array.from(questions || []);
+ const [reorderedItem] = items.splice(result.source.index, 1);
+ items.splice(result.destination.index, 0, reorderedItem);
+
+ updateField("questions", items);
+ }}
+ >
+
+ {(provided) => (
+
+ {(questions || []).map((subQuestion, idx) => (
+
+ {(provided) => (
+
+ {
+ const newQuestions = [...(questions || [])];
+ newQuestions[idx] = updated;
+ updateField("questions", newQuestions);
+ }}
+ onDelete={() => {
+ const newQuestions = questions?.filter(
+ (_, i) => i !== idx,
+ );
+ updateField("questions", newQuestions);
+ }}
+ dragHandleProps={provided.dragHandleProps}
+ isExpanded={expandedSubQuestions.has(
+ subQuestion.id,
+ )}
+ onToggleExpand={() =>
+ toggleSubQuestionExpanded(subQuestion.id)
+ }
+ depth={depth + 1}
+ parentId={getQuestionPath()}
+ />
+
+ )}
+
+ ))}
+ {provided.placeholder}
+
+ )}
+
+
+
+ )}
+
+