mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-04 18:49:39 -06:00
fixes feedback
This commit is contained in:
@@ -335,8 +335,8 @@ export const QuestionFormInput = ({
|
||||
if (url) {
|
||||
const update =
|
||||
fileType === "video"
|
||||
? { videoUrl: url[0], imageUrl: "" }
|
||||
: { imageUrl: url[0], videoUrl: "" };
|
||||
? { videoUrl: url[0], imageUrl: undefined }
|
||||
: { imageUrl: url[0], videoUrl: undefined };
|
||||
if ((isWelcomeCard || isEndingCard) && updateSurvey) {
|
||||
updateSurvey(update);
|
||||
} else if (updateQuestion) {
|
||||
@@ -469,8 +469,8 @@ export const QuestionFormInput = ({
|
||||
if (url) {
|
||||
const update =
|
||||
fileType === "video"
|
||||
? { videoUrl: url[0], imageUrl: "" }
|
||||
: { imageUrl: url[0], videoUrl: "" };
|
||||
? { videoUrl: url[0], imageUrl: undefined }
|
||||
: { imageUrl: url[0], videoUrl: undefined };
|
||||
if (isEndingCard && updateSurvey) {
|
||||
updateSurvey(update);
|
||||
} else if (updateQuestion) {
|
||||
|
||||
@@ -200,21 +200,23 @@ export const FileInput = ({
|
||||
setSelectedFiles(getSelectedFiles());
|
||||
}, [fileUrl]);
|
||||
|
||||
// useEffect to handle the state when switching between 'image' and 'video' tabs.
|
||||
useEffect(() => {
|
||||
if (activeTab === "image" && typeof imageUrlTemp === "string") {
|
||||
// Temporarily store the current video URL before switching tabs.
|
||||
setVideoUrlTemp(videoUrl ?? "");
|
||||
|
||||
// Re-upload the image using the temporary image URL.
|
||||
onFileUpload([imageUrlTemp], "image");
|
||||
if (imageUrlTemp) {
|
||||
onFileUpload([imageUrlTemp], "image");
|
||||
}
|
||||
} else if (activeTab === "video") {
|
||||
// Temporarily store the current image URL before switching tabs.
|
||||
setImageUrlTemp(fileUrl ?? "");
|
||||
|
||||
// Re-upload the video using the temporary video URL.
|
||||
onFileUpload([videoUrlTemp], "video");
|
||||
if (videoUrlTemp) {
|
||||
onFileUpload([videoUrlTemp], "video");
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- Only run when activeTab changes to avoid infinite loops
|
||||
}, [activeTab]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -19,7 +19,7 @@ export function ProgressBar({ survey, questionId }: ProgressBarProps) {
|
||||
|
||||
const calculateProgress = useCallback(
|
||||
(index: number) => {
|
||||
let totalCards = questions.length;
|
||||
let totalCards = survey.blocks.length;
|
||||
if (endingCardIds.length > 0) totalCards += 1;
|
||||
let idx = index;
|
||||
|
||||
@@ -28,7 +28,7 @@ export function ProgressBar({ survey, questionId }: ProgressBarProps) {
|
||||
const elementIdx = calculateElementIdx(survey, idx, totalCards);
|
||||
return elementIdx / totalCards;
|
||||
},
|
||||
[survey, questions.length, endingCardIds.length]
|
||||
[survey, endingCardIds.length]
|
||||
);
|
||||
|
||||
const progressArray = useMemo(() => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { type TResponseData } from "@formbricks/types/responses";
|
||||
import { TSurveyElement } from "@formbricks/types/surveys/elements";
|
||||
import { type TSurveyElement } from "@formbricks/types/surveys/elements";
|
||||
import { SubmitButton } from "@/components/buttons/submit-button";
|
||||
import { processResponseData } from "@/lib/response";
|
||||
|
||||
|
||||
@@ -27,8 +27,13 @@ import { evaluateLogic, performActions } from "@/lib/logic";
|
||||
import { parseRecallInformation } from "@/lib/recall";
|
||||
import { ResponseQueue } from "@/lib/response-queue";
|
||||
import { SurveyState } from "@/lib/survey-state";
|
||||
import { findBlockByElementId, getFirstElementIdInBlock, getQuestionsFromSurvey } from "@/lib/utils";
|
||||
import { cn, getDefaultLanguageCode } from "@/lib/utils";
|
||||
import {
|
||||
cn,
|
||||
findBlockByElementId,
|
||||
getDefaultLanguageCode,
|
||||
getFirstElementIdInBlock,
|
||||
getQuestionsFromSurvey,
|
||||
} from "@/lib/utils";
|
||||
import { TResponseErrorCodesEnum } from "@/types/response-error-codes";
|
||||
|
||||
interface VariableStackEntry {
|
||||
|
||||
@@ -68,12 +68,12 @@ export const replaceRecallInfo = (
|
||||
return modifiedText;
|
||||
};
|
||||
|
||||
export const parseRecallInformation = <T extends TSurveyElement>(
|
||||
question: T,
|
||||
export const parseRecallInformation = (
|
||||
question: TSurveyElement,
|
||||
languageCode: string,
|
||||
responseData: TResponseData,
|
||||
variables: TResponseVariables
|
||||
): T => {
|
||||
): TSurveyElement => {
|
||||
const modifiedQuestion = JSON.parse(JSON.stringify(question));
|
||||
if (question.headline[languageCode].includes("recall:")) {
|
||||
modifiedQuestion.headline[languageCode] = replaceRecallInfo(
|
||||
|
||||
@@ -215,9 +215,8 @@ export const checkIfSurveyIsRTL = (survey: TJsEnvironmentStateSurvey, languageCo
|
||||
* @param survey The survey object with blocks
|
||||
* @returns An array of TSurveyElement (pure elements without block-level properties)
|
||||
*/
|
||||
export const getQuestionsFromSurvey = (survey: TJsEnvironmentStateSurvey): TSurveyElement[] => {
|
||||
return survey.blocks?.flatMap((block) => block.elements) ?? [];
|
||||
};
|
||||
export const getQuestionsFromSurvey = (survey: TJsEnvironmentStateSurvey): TSurveyElement[] =>
|
||||
survey.blocks.flatMap((block) => block.elements);
|
||||
|
||||
/**
|
||||
* Finds the parent block that contains the specified element ID.
|
||||
@@ -226,9 +225,8 @@ export const getQuestionsFromSurvey = (survey: TJsEnvironmentStateSurvey): TSurv
|
||||
* @param elementId The ID of the element to find
|
||||
* @returns The parent block or undefined if not found
|
||||
*/
|
||||
export const findBlockByElementId = (survey: TJsEnvironmentStateSurvey, elementId: string) => {
|
||||
return survey.blocks?.find((b) => b.elements.some((e) => e.id === elementId));
|
||||
};
|
||||
export const findBlockByElementId = (survey: TJsEnvironmentStateSurvey, elementId: string) =>
|
||||
survey.blocks.find((b) => b.elements.some((e) => e.id === elementId));
|
||||
|
||||
/**
|
||||
* Converts a block ID to the first element ID in that block.
|
||||
@@ -241,6 +239,6 @@ export const getFirstElementIdInBlock = (
|
||||
survey: TJsEnvironmentStateSurvey,
|
||||
blockId: string
|
||||
): string | undefined => {
|
||||
const block = survey.blocks?.find((b) => b.id === blockId);
|
||||
const block = survey.blocks.find((b) => b.id === blockId);
|
||||
return block?.elements[0]?.id;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user