fix: NPS response exported as empty string (#3080)

Co-authored-by: Johannes <johannes@formbricks.com>
This commit is contained in:
Dhruwang Jariwala
2024-09-03 14:28:48 +05:30
committed by GitHub
parent 211fc22b2a
commit 198df84b89
2 changed files with 19 additions and 24 deletions

View File

@@ -59,7 +59,7 @@ export const SurveyLoadingAnimation = ({
if (isMediaLoaded && minTimePassed) {
const hideTimer = setTimeout(() => {
setIsHidden(true);
}, 1500);
}, 500);
return () => clearTimeout(hideTimer);
} else {
@@ -71,7 +71,7 @@ export const SurveyLoadingAnimation = ({
// Ensure the animation is shown for at least 1.5 seconds
const minTimeTimer = setTimeout(() => {
setMinTimePassed(true);
}, 1500);
}, 500);
// Observe the DOM for when the survey package (child elements) is added to the target node
const observer = new MutationObserver((mutations) => {

View File

@@ -8,28 +8,25 @@ export const convertResponseValue = (
answer: string | number | string[] | Record<string, string>,
question: TSurveyQuestion
): string | string[] => {
if (!answer) return "";
else {
switch (question.type) {
case "ranking":
case "fileUpload":
if (typeof answer === "string") {
return [answer];
} else return answer as string[];
switch (question.type) {
case "ranking":
case "fileUpload":
if (typeof answer === "string") {
return [answer];
} else return answer as string[];
case "pictureSelection":
if (typeof answer === "string") {
const imageUrl = question.choices.find((choice) => choice.id === answer)?.imageUrl;
return imageUrl ? [imageUrl] : [];
} else if (Array.isArray(answer)) {
return answer
.map((answerId) => question.choices.find((choice) => choice.id === answerId)?.imageUrl)
.filter((url): url is string => url !== undefined);
} else return [];
case "pictureSelection":
if (typeof answer === "string") {
const imageUrl = question.choices.find((choice) => choice.id === answer)?.imageUrl;
return imageUrl ? [imageUrl] : [];
} else if (Array.isArray(answer)) {
return answer
.map((answerId) => question.choices.find((choice) => choice.id === answerId)?.imageUrl)
.filter((url): url is string => url !== undefined);
} else return [];
default:
return processResponseData(answer);
}
default:
return processResponseData(answer);
}
};
@@ -58,8 +55,6 @@ export const getQuestionResponseMapping = (
export const processResponseData = (
responseData: string | number | string[] | Record<string, string>
): string => {
if (!responseData) return "";
switch (typeof responseData) {
case "string":
return responseData;