@anker-in/ui 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1671,7 +1671,12 @@ var QuestionnaireForm = ({
|
|
|
1671
1671
|
const [phoneCountryCodes, setPhoneCountryCodes] = useState({});
|
|
1672
1672
|
const [otherInputs, setOtherInputs] = useState({});
|
|
1673
1673
|
const prevHasBookedBeforeRef = useRef(false);
|
|
1674
|
-
const
|
|
1674
|
+
const hasBookedBeforeInitialized = useRef(false);
|
|
1675
|
+
const hasBookedBeforeQuestion = questions.find(
|
|
1676
|
+
(q) => (q.key || q.id) === "has_booked_before"
|
|
1677
|
+
);
|
|
1678
|
+
const hasBookedBeforeQuestionId = hasBookedBeforeQuestion ? hasBookedBeforeQuestion.key || hasBookedBeforeQuestion.id || "" : "has_booked_before";
|
|
1679
|
+
const hasBookedBefore = responses[hasBookedBeforeQuestionId] === "option2";
|
|
1675
1680
|
const hiddenQuestionIds = useMemo(() => {
|
|
1676
1681
|
if (!hasBookedBefore) return [];
|
|
1677
1682
|
return questions.filter((q) => q.is_default === false).map((q) => q.key || q.id || "");
|
|
@@ -1684,6 +1689,21 @@ var QuestionnaireForm = ({
|
|
|
1684
1689
|
return true;
|
|
1685
1690
|
});
|
|
1686
1691
|
}, [questions, hasBookedBefore]);
|
|
1692
|
+
useEffect(() => {
|
|
1693
|
+
if (hasBookedBeforeInitialized.current) return;
|
|
1694
|
+
if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
|
|
1695
|
+
setResponses((prev) => {
|
|
1696
|
+
if (!prev[hasBookedBeforeQuestionId]) {
|
|
1697
|
+
return {
|
|
1698
|
+
...prev,
|
|
1699
|
+
[hasBookedBeforeQuestionId]: "option1"
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
return prev;
|
|
1703
|
+
});
|
|
1704
|
+
hasBookedBeforeInitialized.current = true;
|
|
1705
|
+
}
|
|
1706
|
+
}, [hasBookedBeforeQuestion, hasBookedBeforeQuestionId]);
|
|
1687
1707
|
useEffect(() => {
|
|
1688
1708
|
if (hasBookedBefore && !prevHasBookedBeforeRef.current) {
|
|
1689
1709
|
if (hiddenQuestionIds.length > 0) {
|