mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-04 18:49:39 -06:00
fixes sonarqube issues
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TSurveyBlockLogic } from "@formbricks/types/surveys/blocks";
|
||||
import { TSurveyBlock } from "@formbricks/types/surveys/blocks";
|
||||
import { TSurveyBlock, TSurveyBlockLogic } from "@formbricks/types/surveys/blocks";
|
||||
import { TSurvey } from "@formbricks/types/surveys/types";
|
||||
import { getTextContent } from "@formbricks/types/surveys/validation";
|
||||
import { recallToHeadline } from "@/lib/utils/recall";
|
||||
|
||||
@@ -600,7 +600,7 @@ export const QuestionsView = ({
|
||||
|
||||
// If source block is now empty, delete it
|
||||
if (sourceBlock.elements.length === 0) {
|
||||
const blockIdx = updatedSurvey.blocks.findIndex((b) => b.id === sourceBlock!.id);
|
||||
const blockIdx = updatedSurvey.blocks.findIndex((b) => b.id === sourceBlock.id);
|
||||
if (blockIdx !== -1) {
|
||||
updatedSurvey.blocks.splice(blockIdx, 1);
|
||||
}
|
||||
@@ -778,7 +778,6 @@ export const QuestionsView = ({
|
||||
blocks.splice(destBlockIndex, 0, movedBlock);
|
||||
|
||||
setLocalSurvey({ ...localSurvey, blocks });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -91,15 +91,9 @@ export function createSharedConditionsFactory(
|
||||
};
|
||||
|
||||
const config: TConditionsEditorConfig<TSingleCondition> = {
|
||||
getLeftOperandOptions: () =>
|
||||
blockIdx !== undefined
|
||||
? getConditionValueOptions(survey, t, blockIdx)
|
||||
: getConditionValueOptions(survey, t),
|
||||
getLeftOperandOptions: () => getConditionValueOptions(survey, t, blockIdx),
|
||||
getOperatorOptions: (condition) => getConditionOperatorOptions(condition, survey, t),
|
||||
getValueProps: (condition) =>
|
||||
blockIdx !== undefined
|
||||
? getMatchValueProps(condition, survey, t, blockIdx)
|
||||
: getMatchValueProps(condition, survey, t),
|
||||
getValueProps: (condition) => getMatchValueProps(condition, survey, t, blockIdx),
|
||||
getDefaultOperator,
|
||||
formatLeftOperandValue: (condition) => getFormatLeftOperandValue(condition, survey),
|
||||
};
|
||||
|
||||
@@ -134,11 +134,9 @@ export const getConditionValueOptions = (
|
||||
// If blockIdx is provided, get elements from current block and all previous blocks
|
||||
// Otherwise, get all elements from all blocks
|
||||
const allElements =
|
||||
blockIdx !== undefined
|
||||
? localSurvey.blocks
|
||||
.slice(0, blockIdx + 1) // Include blocks from 0 to blockIdx (inclusive)
|
||||
.flatMap((block) => block.elements)
|
||||
: getElementsFromBlocks(localSurvey.blocks);
|
||||
blockIdx === undefined
|
||||
? getElementsFromBlocks(localSurvey.blocks)
|
||||
: localSurvey.blocks.slice(0, blockIdx + 1).flatMap((block) => block.elements);
|
||||
|
||||
const groupedOptions: TComboboxGroupedOption[] = [];
|
||||
const elementOptions: TComboboxOption[] = [];
|
||||
@@ -373,11 +371,11 @@ export const getMatchValueProps = (
|
||||
// If blockIdx is provided, get elements from current block and all previous blocks
|
||||
// Otherwise, get all elements from all blocks
|
||||
let elements =
|
||||
blockIdx !== undefined
|
||||
? localSurvey.blocks
|
||||
blockIdx === undefined
|
||||
? getElementsFromBlocks(localSurvey.blocks)
|
||||
: localSurvey.blocks
|
||||
.slice(0, blockIdx + 1) // Include blocks from 0 to blockIdx (inclusive)
|
||||
.flatMap((block) => block.elements)
|
||||
: getElementsFromBlocks(localSurvey.blocks);
|
||||
.flatMap((block) => block.elements);
|
||||
|
||||
let variables = localSurvey.variables ?? [];
|
||||
let hiddenFields = localSurvey.hiddenFields?.fieldIds ?? [];
|
||||
@@ -428,7 +426,7 @@ export const getMatchValueProps = (
|
||||
|
||||
const variableOptions = variables
|
||||
.filter((variable) =>
|
||||
selectedElement.inputType !== "number" ? variable.type === "text" : variable.type === "number"
|
||||
selectedElement.inputType === "number" ? variable.type === "number" : variable.type === "text"
|
||||
)
|
||||
.map((variable) => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user