Browse Source

fix question

master
mortezaei 11 hours ago
parent
commit
67dee4f0d9
  1. 1
      src/components/Componentes/question-renderer.tsx
  2. 13
      src/components/Componentes/question-slider.tsx

1
src/components/Componentes/question-renderer.tsx

@ -117,6 +117,7 @@ export function QuestionRenderer({
);
case "slider":
case "scale":
case "range":
return (
<QuestionSlider
question={question}

13
src/components/Componentes/question-slider.tsx

@ -86,7 +86,10 @@ export function QuestionSlider({
? Number(question.extras.placeHolder)
: Math.round((min + max) / 2);
const isDesiredAgeRange = false;
const isDesiredAgeRange =
question.type === "range" ||
(question.id || "").toLowerCase().includes("desired_age") ||
(question.id || "").toLowerCase().includes("age_range");
const thumbWidth = 18;
@ -124,7 +127,7 @@ export function QuestionSlider({
})();
// Multi-state logic for Age Range Slider
let fromVal = 25;
let fromVal = 20;
let toVal = 30;
if (isDesiredAgeRange) {
if (typeof storedValue === "string" && storedValue.includes("-")) {
@ -140,6 +143,12 @@ export function QuestionSlider({
} else if (typeof storedValue === "number") {
fromVal = storedValue;
toVal = Math.max(storedValue, max);
} else if (typeof question.extras?.placeHolder === "string") {
const match = question.extras.placeHolder.match(/(\d+)[^\d]+(\d+)/);
if (match) {
fromVal = Number(match[1]);
toVal = Number(match[2]);
}
}
fromVal = Math.max(min, Math.min(max, fromVal));
toVal = Math.max(min, Math.min(max, toVal));

Loading…
Cancel
Save