mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-03 03:14:34 -05:00
chore: fix eslint issues in ee & email packages (#2742)
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { LocalizedEditor } from "@formbricks/ee/multiLanguage/components/LocalizedEditor";
|
||||
import { LocalizedEditor } from "@formbricks/ee/multi-language/components/localized-editor";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TSurvey, TSurveyCTAQuestion } from "@formbricks/types/surveys";
|
||||
import { Input } from "@formbricks/ui/Input";
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { LocalizedEditor } from "@formbricks/ee/multiLanguage/components/LocalizedEditor";
|
||||
import { LocalizedEditor } from "@formbricks/ee/multi-language/components/localized-editor";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TSurvey, TSurveyConsentQuestion } from "@formbricks/types/surveys";
|
||||
import { Label } from "@formbricks/ui/Label";
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import * as Collapsible from "@radix-ui/react-collapsible";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { LocalizedEditor } from "@formbricks/ee/multiLanguage/components/LocalizedEditor";
|
||||
import { LocalizedEditor } from "@formbricks/ee/multi-language/components/localized-editor";
|
||||
import { cn } from "@formbricks/lib/cn";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TSurvey } from "@formbricks/types/surveys";
|
||||
|
||||
+2
-3
@@ -8,7 +8,6 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
import { getLocalizedValue } from "@formbricks/lib/i18n/utils";
|
||||
import { structuredClone } from "@formbricks/lib/pollyfills/structuredClone";
|
||||
import { replaceHeadlineRecall } from "@formbricks/lib/utils/recall";
|
||||
@@ -18,7 +17,7 @@ import {
|
||||
TSurveyLogic,
|
||||
TSurveyLogicCondition,
|
||||
TSurveyQuestion,
|
||||
TSurveyQuestionType,
|
||||
TSurveyQuestionTypeEnum,
|
||||
} from "@formbricks/types/surveys";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import {
|
||||
@@ -66,7 +65,7 @@ export const LogicEditor = ({
|
||||
return question.choices.map((choice) => getLocalizedValue(choice.label, "default"));
|
||||
} else if ("range" in question) {
|
||||
return Array.from({ length: question.range ? question.range : 0 }, (_, i) => (i + 1).toString());
|
||||
} else if (question.type === TSurveyQuestionType.NPS) {
|
||||
} else if (question.type === TSurveyQuestionTypeEnum.NPS) {
|
||||
return Array.from({ length: 11 }, (_, i) => (i + 0).toString());
|
||||
}
|
||||
return [];
|
||||
|
||||
+6
-8
@@ -5,7 +5,6 @@ import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable"
|
||||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { PlusIcon, TrashIcon } from "lucide-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { createI18nString, extractLanguageCodes } from "@formbricks/lib/i18n/utils";
|
||||
import { getLocalizedValue } from "@formbricks/lib/i18n/utils";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
@@ -14,13 +13,12 @@ import {
|
||||
TShuffleOption,
|
||||
TSurvey,
|
||||
TSurveyMultipleChoiceQuestion,
|
||||
TSurveyQuestionType,
|
||||
TSurveyQuestionTypeEnum,
|
||||
} from "@formbricks/types/surveys";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import { Label } from "@formbricks/ui/Label";
|
||||
import { QuestionFormInput } from "@formbricks/ui/QuestionFormInput";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@formbricks/ui/Select";
|
||||
|
||||
import { SelectQuestionChoice } from "./SelectQuestionChoice";
|
||||
|
||||
interface OpenQuestionFormProps {
|
||||
@@ -309,13 +307,13 @@ export const MultipleChoiceQuestionForm = ({
|
||||
onClick={() => {
|
||||
updateQuestion(questionIdx, {
|
||||
type:
|
||||
question.type === TSurveyQuestionType.MultipleChoiceMulti
|
||||
? TSurveyQuestionType.MultipleChoiceSingle
|
||||
: TSurveyQuestionType.MultipleChoiceMulti,
|
||||
question.type === TSurveyQuestionTypeEnum.MultipleChoiceMulti
|
||||
? TSurveyQuestionTypeEnum.MultipleChoiceSingle
|
||||
: TSurveyQuestionTypeEnum.MultipleChoiceMulti,
|
||||
});
|
||||
}}>
|
||||
Convert to {question.type === TSurveyQuestionType.MultipleChoiceSingle ? "Multiple" : "Single"}{" "}
|
||||
Select
|
||||
Convert to{" "}
|
||||
{question.type === TSurveyQuestionTypeEnum.MultipleChoiceSingle ? "Multiple" : "Single"} Select
|
||||
</Button>
|
||||
|
||||
<div className="flex flex-1 items-center justify-end gap-2">
|
||||
|
||||
+21
-23
@@ -1,21 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { QUESTIONS_ICON_MAP, getTSurveyQuestionTypeName } from "@/app/lib/questions";
|
||||
import { QUESTIONS_ICON_MAP, getTSurveyQuestionTypeEnumName } from "@/app/lib/questions";
|
||||
import { useSortable } from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import * as Collapsible from "@radix-ui/react-collapsible";
|
||||
import { ChevronDownIcon, ChevronRightIcon, GripIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { cn } from "@formbricks/lib/cn";
|
||||
import { recallToHeadline } from "@formbricks/lib/utils/recall";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TProduct } from "@formbricks/types/product";
|
||||
import { TI18nString, TSurvey, TSurveyQuestion, TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TI18nString, TSurvey, TSurveyQuestion, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { Label } from "@formbricks/ui/Label";
|
||||
import { QuestionFormInput } from "@formbricks/ui/QuestionFormInput";
|
||||
import { Switch } from "@formbricks/ui/Switch";
|
||||
|
||||
import { AddressQuestionForm } from "./AddressQuestionForm";
|
||||
import { AdvancedSettings } from "./AdvancedSettings";
|
||||
import { CTAQuestionForm } from "./CTAQuestionForm";
|
||||
@@ -192,7 +190,7 @@ export const QuestionCard = ({
|
||||
attributeClasses
|
||||
)[selectedLanguageCode] ?? ""
|
||||
)
|
||||
: getTSurveyQuestionTypeName(question.type)}
|
||||
: getTSurveyQuestionTypeEnumName(question.type)}
|
||||
</p>
|
||||
{!open && question?.required && (
|
||||
<p className="mt-1 truncate text-xs text-slate-500">{question?.required && "Required"}</p>
|
||||
@@ -216,7 +214,7 @@ export const QuestionCard = ({
|
||||
</div>
|
||||
</Collapsible.CollapsibleTrigger>
|
||||
<Collapsible.CollapsibleContent className="px-4 pb-4">
|
||||
{question.type === TSurveyQuestionType.OpenText ? (
|
||||
{question.type === TSurveyQuestionTypeEnum.OpenText ? (
|
||||
<OpenQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -228,7 +226,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.MultipleChoiceSingle ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.MultipleChoiceSingle ? (
|
||||
<MultipleChoiceQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -240,7 +238,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.MultipleChoiceMulti ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.MultipleChoiceMulti ? (
|
||||
<MultipleChoiceQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -252,7 +250,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.NPS ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.NPS ? (
|
||||
<NPSQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -264,7 +262,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.CTA ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.CTA ? (
|
||||
<CTAQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -276,7 +274,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.Rating ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.Rating ? (
|
||||
<RatingQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -288,7 +286,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.Consent ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.Consent ? (
|
||||
<ConsentQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -299,7 +297,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.Date ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.Date ? (
|
||||
<DateQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -311,7 +309,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.PictureSelection ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.PictureSelection ? (
|
||||
<PictureSelectionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -323,7 +321,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.FileUpload ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.FileUpload ? (
|
||||
<FileUploadQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
product={product}
|
||||
@@ -336,7 +334,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.Cal ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.Cal ? (
|
||||
<CalQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -348,7 +346,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.Matrix ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.Matrix ? (
|
||||
<MatrixQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -360,7 +358,7 @@ export const QuestionCard = ({
|
||||
isInvalid={isInvalid}
|
||||
attributeClasses={attributeClasses}
|
||||
/>
|
||||
) : question.type === TSurveyQuestionType.Address ? (
|
||||
) : question.type === TSurveyQuestionTypeEnum.Address ? (
|
||||
<AddressQuestionForm
|
||||
localSurvey={localSurvey}
|
||||
question={question}
|
||||
@@ -385,9 +383,9 @@ export const QuestionCard = ({
|
||||
</Collapsible.CollapsibleTrigger>
|
||||
|
||||
<Collapsible.CollapsibleContent className="space-y-4">
|
||||
{question.type !== TSurveyQuestionType.NPS &&
|
||||
question.type !== TSurveyQuestionType.Rating &&
|
||||
question.type !== TSurveyQuestionType.CTA ? (
|
||||
{question.type !== TSurveyQuestionTypeEnum.NPS &&
|
||||
question.type !== TSurveyQuestionTypeEnum.Rating &&
|
||||
question.type !== TSurveyQuestionTypeEnum.CTA ? (
|
||||
<div className="mt-2 flex space-x-2">
|
||||
<div className="w-full">
|
||||
<QuestionFormInput
|
||||
@@ -433,8 +431,8 @@ export const QuestionCard = ({
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
{(question.type === TSurveyQuestionType.Rating ||
|
||||
question.type === TSurveyQuestionType.NPS) &&
|
||||
{(question.type === TSurveyQuestionTypeEnum.Rating ||
|
||||
question.type === TSurveyQuestionTypeEnum.NPS) &&
|
||||
questionIdx !== 0 && (
|
||||
<div className="mt-4">
|
||||
<QuestionFormInput
|
||||
|
||||
+12
-13
@@ -4,9 +4,8 @@ import { QUESTIONS_ICON_MAP, QUESTIONS_NAME_MAP, getQuestionDefaults } from "@/a
|
||||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { ArrowDownIcon, ArrowUpIcon, CopyIcon, EllipsisIcon, TrashIcon } from "lucide-react";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { TProduct } from "@formbricks/types/product";
|
||||
import { TSurveyQuestion, TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestion, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { ConfirmationModal } from "@formbricks/ui/ConfirmationModal";
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -44,7 +43,7 @@ export const QuestionMenu = ({
|
||||
const [logicWarningModal, setLogicWarningModal] = useState(false);
|
||||
const [changeToType, setChangeToType] = useState(question.type);
|
||||
|
||||
const changeQuestionType = (type: TSurveyQuestionType) => {
|
||||
const changeQuestionType = (type: TSurveyQuestionTypeEnum) => {
|
||||
const { headline, required, subheader, imageUrl, videoUrl, buttonLabel, backButtonLabel } = question;
|
||||
|
||||
const questionDefaults = getQuestionDefaults(type, product);
|
||||
@@ -52,10 +51,10 @@ export const QuestionMenu = ({
|
||||
// if going from single select to multi select or vice versa, we need to keep the choices as well
|
||||
|
||||
if (
|
||||
(type === TSurveyQuestionType.MultipleChoiceSingle &&
|
||||
question.type === TSurveyQuestionType.MultipleChoiceMulti) ||
|
||||
(type === TSurveyQuestionType.MultipleChoiceMulti &&
|
||||
question.type === TSurveyQuestionType.MultipleChoiceSingle)
|
||||
(type === TSurveyQuestionTypeEnum.MultipleChoiceSingle &&
|
||||
question.type === TSurveyQuestionTypeEnum.MultipleChoiceMulti) ||
|
||||
(type === TSurveyQuestionTypeEnum.MultipleChoiceMulti &&
|
||||
question.type === TSurveyQuestionTypeEnum.MultipleChoiceSingle)
|
||||
) {
|
||||
updateQuestion(questionIdx, {
|
||||
choices: question.choices,
|
||||
@@ -80,7 +79,7 @@ export const QuestionMenu = ({
|
||||
});
|
||||
};
|
||||
|
||||
const addQuestionBelow = (type: TSurveyQuestionType) => {
|
||||
const addQuestionBelow = (type: TSurveyQuestionTypeEnum) => {
|
||||
const questionDefaults = getQuestionDefaults(type, product);
|
||||
|
||||
addQuestion(
|
||||
@@ -143,15 +142,15 @@ export const QuestionMenu = ({
|
||||
key={type}
|
||||
className="min-h-8 cursor-pointer text-slate-500"
|
||||
onClick={() => {
|
||||
setChangeToType(type as TSurveyQuestionType);
|
||||
setChangeToType(type as TSurveyQuestionTypeEnum);
|
||||
if (question.logic) {
|
||||
setLogicWarningModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
changeQuestionType(type as TSurveyQuestionType);
|
||||
changeQuestionType(type as TSurveyQuestionTypeEnum);
|
||||
}}>
|
||||
{QUESTIONS_ICON_MAP[type as TSurveyQuestionType]}
|
||||
{QUESTIONS_ICON_MAP[type as TSurveyQuestionTypeEnum]}
|
||||
<span className="ml-2">{name}</span>
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
@@ -176,9 +175,9 @@ export const QuestionMenu = ({
|
||||
className="min-h-8 cursor-pointer text-slate-500"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
addQuestionBelow(type as TSurveyQuestionType);
|
||||
addQuestionBelow(type as TSurveyQuestionTypeEnum);
|
||||
}}>
|
||||
{QUESTIONS_ICON_MAP[type as TSurveyQuestionType]}
|
||||
{QUESTIONS_ICON_MAP[type as TSurveyQuestionTypeEnum]}
|
||||
<span className="ml-2">{name}</span>
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import { createId } from "@paralleldrive/cuid2";
|
||||
import React, { SetStateAction, useEffect, useMemo, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import { MultiLanguageCard } from "@formbricks/ee/multiLanguage/components/MultiLanguageCard";
|
||||
import { MultiLanguageCard } from "@formbricks/ee/multi-language/components/multi-language-card";
|
||||
import { extractLanguageCodes, getLocalizedValue, translateQuestion } from "@formbricks/lib/i18n/utils";
|
||||
import { structuredClone } from "@formbricks/lib/pollyfills/structuredClone";
|
||||
import { checkForEmptyFallBackValue, extractRecallInfo } from "@formbricks/lib/utils/recall";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { AdvancedTargetingCard } from "@formbricks/ee/advancedTargeting/components/AdvancedTargetingCard";
|
||||
import { AdvancedTargetingCard } from "@formbricks/ee/advanced-targeting/components/advanced-targeting-card";
|
||||
import { TActionClass } from "@formbricks/types/actionClasses";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TEnvironment } from "@formbricks/types/environment";
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import { useRouter } from "next/navigation";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import { createSegmentAction } from "@formbricks/ee/advancedTargeting/lib/actions";
|
||||
import { createSegmentAction } from "@formbricks/ee/advanced-targeting/lib/actions";
|
||||
import { TEnvironment } from "@formbricks/types/environment";
|
||||
import { TProduct } from "@formbricks/types/product";
|
||||
import { TSegment } from "@formbricks/types/segment";
|
||||
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
// extend this object in order to add more validation rules
|
||||
import { isEqual } from "lodash";
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
import { extractLanguageCodes, getLocalizedValue } from "@formbricks/lib/i18n/utils";
|
||||
import { checkForEmptyFallBackValue } from "@formbricks/lib/utils/recall";
|
||||
import { ZSegmentFilters } from "@formbricks/types/segment";
|
||||
@@ -16,7 +15,7 @@ import {
|
||||
TSurveyOpenTextQuestion,
|
||||
TSurveyPictureSelectionQuestion,
|
||||
TSurveyQuestion,
|
||||
TSurveyQuestionType,
|
||||
TSurveyQuestionTypeEnum,
|
||||
TSurveyQuestions,
|
||||
TSurveyThankYouCard,
|
||||
TSurveyWelcomeCard,
|
||||
@@ -363,8 +362,8 @@ export const isSurveyValid = (
|
||||
existingQuestionIds.add(question.id);
|
||||
|
||||
if (
|
||||
question.type === TSurveyQuestionType.MultipleChoiceSingle ||
|
||||
question.type === TSurveyQuestionType.MultipleChoiceMulti
|
||||
question.type === TSurveyQuestionTypeEnum.MultipleChoiceSingle ||
|
||||
question.type === TSurveyQuestionTypeEnum.MultipleChoiceMulti
|
||||
) {
|
||||
const haveSameChoices =
|
||||
question.choices.some((element) => element.label[selectedLanguageCode]?.trim() === "") ||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
|
||||
import { useMemo, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import { createSegmentAction } from "@formbricks/ee/advancedTargeting/lib/actions";
|
||||
import { createSegmentAction } from "@formbricks/ee/advanced-targeting/lib/actions";
|
||||
import { structuredClone } from "@formbricks/lib/pollyfills/structuredClone";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TBaseFilter, TSegment, ZSegmentFilters } from "@formbricks/types/segment";
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import { UsersIcon } from "lucide-react";
|
||||
|
||||
import { SegmentSettings } from "@formbricks/ee/advancedTargeting/components/SegmentSettings";
|
||||
import { SegmentSettings } from "@formbricks/ee/advanced-targeting/components/segment-settings";
|
||||
import { TActionClass } from "@formbricks/types/actionClasses";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TSegment, TSegmentWithSurveyNames } from "@formbricks/types/segment";
|
||||
|
||||
@@ -2,8 +2,8 @@ import { PeopleSecondaryNavigation } from "@/app/(app)/environments/[environment
|
||||
import { BasicCreateSegmentModal } from "@/app/(app)/environments/[environmentId]/(people)/segments/components/BasicCreateSegmentModal";
|
||||
import { SegmentTable } from "@/app/(app)/environments/[environmentId]/(people)/segments/components/SegmentTable";
|
||||
|
||||
import { CreateSegmentModal } from "@formbricks/ee/advancedTargeting/components/CreateSegmentModal";
|
||||
import { ACTIONS_TO_EXCLUDE } from "@formbricks/ee/advancedTargeting/lib/constants";
|
||||
import { CreateSegmentModal } from "@formbricks/ee/advanced-targeting/components/create-segment-modal";
|
||||
import { ACTIONS_TO_EXCLUDE } from "@formbricks/ee/advanced-targeting/lib/constants";
|
||||
import { getAdvancedTargetingPermission } from "@formbricks/ee/lib/service";
|
||||
import { getActionClasses } from "@formbricks/lib/actionClass/service";
|
||||
import { getAttributeClasses } from "@formbricks/lib/attributeClass/service";
|
||||
|
||||
+2
-3
@@ -11,7 +11,6 @@ import Image from "next/image";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import { getLocalizedValue } from "@formbricks/lib/i18n/utils";
|
||||
import { structuredClone } from "@formbricks/lib/pollyfills/structuredClone";
|
||||
import { replaceHeadlineRecall } from "@formbricks/lib/utils/recall";
|
||||
@@ -22,7 +21,7 @@ import {
|
||||
TIntegrationNotionConfigData,
|
||||
TIntegrationNotionDatabase,
|
||||
} from "@formbricks/types/integration/notion";
|
||||
import { TSurvey, TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurvey, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import { DropdownSelector } from "@formbricks/ui/DropdownSelector";
|
||||
import { Label } from "@formbricks/ui/Label";
|
||||
@@ -123,7 +122,7 @@ export const AddIntegrationModal = ({
|
||||
? selectedSurvey?.hiddenFields.fieldIds?.map((fId) => ({
|
||||
id: fId,
|
||||
name: fId,
|
||||
type: TSurveyQuestionType.OpenText,
|
||||
type: TSurveyQuestionTypeEnum.OpenText,
|
||||
})) || []
|
||||
: [];
|
||||
return [...questions, ...hiddenFields];
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
|
||||
export const TYPE_MAPPING = {
|
||||
[TSurveyQuestionType.CTA]: ["checkbox"],
|
||||
[TSurveyQuestionType.MultipleChoiceMulti]: ["multi_select"],
|
||||
[TSurveyQuestionType.MultipleChoiceSingle]: ["select", "status"],
|
||||
[TSurveyQuestionType.OpenText]: [
|
||||
[TSurveyQuestionTypeEnum.CTA]: ["checkbox"],
|
||||
[TSurveyQuestionTypeEnum.MultipleChoiceMulti]: ["multi_select"],
|
||||
[TSurveyQuestionTypeEnum.MultipleChoiceSingle]: ["select", "status"],
|
||||
[TSurveyQuestionTypeEnum.OpenText]: [
|
||||
"created_by",
|
||||
"created_time",
|
||||
"date",
|
||||
@@ -17,15 +17,15 @@ export const TYPE_MAPPING = {
|
||||
"title",
|
||||
"url",
|
||||
],
|
||||
[TSurveyQuestionType.NPS]: ["number"],
|
||||
[TSurveyQuestionType.Consent]: ["checkbox"],
|
||||
[TSurveyQuestionType.Rating]: ["number"],
|
||||
[TSurveyQuestionType.PictureSelection]: ["url"],
|
||||
[TSurveyQuestionType.FileUpload]: ["url"],
|
||||
[TSurveyQuestionType.Date]: ["date"],
|
||||
[TSurveyQuestionType.Address]: ["rich_text"],
|
||||
[TSurveyQuestionType.Matrix]: ["rich_text"],
|
||||
[TSurveyQuestionType.Cal]: ["checkbox"],
|
||||
[TSurveyQuestionTypeEnum.NPS]: ["number"],
|
||||
[TSurveyQuestionTypeEnum.Consent]: ["checkbox"],
|
||||
[TSurveyQuestionTypeEnum.Rating]: ["number"],
|
||||
[TSurveyQuestionTypeEnum.PictureSelection]: ["url"],
|
||||
[TSurveyQuestionTypeEnum.FileUpload]: ["url"],
|
||||
[TSurveyQuestionTypeEnum.Date]: ["date"],
|
||||
[TSurveyQuestionTypeEnum.Address]: ["rich_text"],
|
||||
[TSurveyQuestionTypeEnum.Matrix]: ["rich_text"],
|
||||
[TSurveyQuestionTypeEnum.Cal]: ["checkbox"],
|
||||
};
|
||||
|
||||
export const UNSUPPORTED_TYPES_BY_NOTION = [
|
||||
|
||||
@@ -3,7 +3,7 @@ import { SettingsCard } from "@/app/(app)/environments/[environmentId]/settings/
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { getMultiLanguagePermission } from "@formbricks/ee/lib/service";
|
||||
import { EditLanguage } from "@formbricks/ee/multiLanguage/components/EditLanguage";
|
||||
import { EditLanguage } from "@formbricks/ee/multi-language/components/edit-language";
|
||||
import { getOrganization } from "@formbricks/lib/organization/service";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
|
||||
import { PageContentWrapper } from "@formbricks/ui/PageContentWrapper";
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@
|
||||
import { getServerSession } from "next-auth";
|
||||
|
||||
import { StripePriceLookupKeys } from "@formbricks/ee/billing/lib/constants";
|
||||
import { createCustomerPortalSession } from "@formbricks/ee/billing/lib/createCustomerPortalSession";
|
||||
import { createSubscription } from "@formbricks/ee/billing/lib/createSubscription";
|
||||
import { removeSubscription } from "@formbricks/ee/billing/lib/removeSubscription";
|
||||
import { createCustomerPortalSession } from "@formbricks/ee/billing/lib/create-customer-portal-session";
|
||||
import { createSubscription } from "@formbricks/ee/billing/lib/create-subscription";
|
||||
import { removeSubscription } from "@formbricks/ee/billing/lib/remove-subscription";
|
||||
import { authOptions } from "@formbricks/lib/authOptions";
|
||||
import { WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { canUserAccessOrganization } from "@formbricks/lib/organization/auth";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { MemberActions } from "@/app/(app)/environments/[environmentId]/settings/(organization)/members/components/EditMemberships/MemberActions";
|
||||
import { isInviteExpired } from "@/app/lib/utils";
|
||||
|
||||
import { EditMembershipRole } from "@formbricks/ee/RoleManagement/components/EditMembershipRole";
|
||||
import { EditMembershipRole } from "@formbricks/ee/role-management/components/edit-membership-role";
|
||||
import { TInvite } from "@formbricks/types/invites";
|
||||
import { TMember, TMembershipRole } from "@formbricks/types/memberships";
|
||||
import { TOrganization } from "@formbricks/types/organizations";
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { AddMemberRole } from "@formbricks/ee/RoleManagement/components/AddMemberRole";
|
||||
import { AddMemberRole } from "@formbricks/ee/role-management/components/add-member-role";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import { Input } from "@formbricks/ui/Input";
|
||||
import { Label } from "@formbricks/ui/Label";
|
||||
|
||||
+14
-16
@@ -11,15 +11,13 @@ import { NPSSummary } from "@/app/(app)/environments/[environmentId]/surveys/[su
|
||||
import { OpenTextSummary } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/OpenTextSummary";
|
||||
import { PictureChoiceSummary } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/PictureChoiceSummary";
|
||||
import { RatingSummary } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/RatingSummary";
|
||||
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TEnvironment } from "@formbricks/types/environment";
|
||||
import { TSurveySummary } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { TSurvey } from "@formbricks/types/surveys";
|
||||
import { EmptySpaceFiller } from "@formbricks/ui/EmptySpaceFiller";
|
||||
import { SkeletonLoader } from "@formbricks/ui/SkeletonLoader";
|
||||
|
||||
import { AddressSummary } from "./AddressSummary";
|
||||
|
||||
interface SummaryListProps {
|
||||
@@ -58,7 +56,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
) : (
|
||||
summary.map((questionSummary) => {
|
||||
if (questionSummary.type === TSurveyQuestionType.OpenText) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.OpenText) {
|
||||
return (
|
||||
<OpenTextSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -70,8 +68,8 @@ export const SummaryList = ({
|
||||
);
|
||||
}
|
||||
if (
|
||||
questionSummary.type === TSurveyQuestionType.MultipleChoiceSingle ||
|
||||
questionSummary.type === TSurveyQuestionType.MultipleChoiceMulti
|
||||
questionSummary.type === TSurveyQuestionTypeEnum.MultipleChoiceSingle ||
|
||||
questionSummary.type === TSurveyQuestionTypeEnum.MultipleChoiceMulti
|
||||
) {
|
||||
return (
|
||||
<MultipleChoiceSummary
|
||||
@@ -84,7 +82,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.NPS) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.NPS) {
|
||||
return (
|
||||
<NPSSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -94,7 +92,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.CTA) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.CTA) {
|
||||
return (
|
||||
<CTASummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -104,7 +102,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.Rating) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.Rating) {
|
||||
return (
|
||||
<RatingSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -114,7 +112,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.Consent) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.Consent) {
|
||||
return (
|
||||
<ConsentSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -124,7 +122,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.PictureSelection) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.PictureSelection) {
|
||||
return (
|
||||
<PictureChoiceSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -134,7 +132,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.Date) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.Date) {
|
||||
return (
|
||||
<DateQuestionSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -145,7 +143,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.FileUpload) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.FileUpload) {
|
||||
return (
|
||||
<FileUploadSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -156,7 +154,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.Cal) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.Cal) {
|
||||
return (
|
||||
<CalSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -167,7 +165,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.Matrix) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.Matrix) {
|
||||
return (
|
||||
<MatrixQuestionSummary
|
||||
key={questionSummary.question.id}
|
||||
@@ -177,7 +175,7 @@ export const SummaryList = ({
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (questionSummary.type === TSurveyQuestionType.Address) {
|
||||
if (questionSummary.type === TSurveyQuestionTypeEnum.Address) {
|
||||
return (
|
||||
<AddressSummary
|
||||
key={questionSummary.question.id}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { getPreviewEmailTemplateHtml } from "@formbricks/email/components/survey/PreviewEmailTemplate";
|
||||
import { getPreviewEmailTemplateHtml } from "@formbricks/email/components/survey/preview-email-template";
|
||||
import { WEBAPP_URL } from "@formbricks/lib/constants";
|
||||
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
|
||||
import { getSurvey } from "@formbricks/lib/survey/service";
|
||||
|
||||
+6
-7
@@ -4,10 +4,9 @@ import { OptionsType } from "@/app/(app)/environments/[environmentId]/surveys/[s
|
||||
import clsx from "clsx";
|
||||
import { ChevronDown, ChevronUp, X } from "lucide-react";
|
||||
import * as React from "react";
|
||||
|
||||
import { getLocalizedValue } from "@formbricks/lib/i18n/utils";
|
||||
import { useClickOutside } from "@formbricks/lib/utils/hooks/useClickOutside";
|
||||
import { TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { Command, CommandEmpty, CommandGroup, CommandItem, CommandList } from "@formbricks/ui/Command";
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -23,7 +22,7 @@ type QuestionFilterComboBoxProps = {
|
||||
filterComboBoxValue: string | string[] | undefined;
|
||||
onChangeFilterValue: (o: string) => void;
|
||||
onChangeFilterComboBoxValue: (o: string | string[]) => void;
|
||||
type?: TSurveyQuestionType | Omit<OptionsType, OptionsType.QUESTIONS>;
|
||||
type?: TSurveyQuestionTypeEnum | Omit<OptionsType, OptionsType.QUESTIONS>;
|
||||
handleRemoveMultiSelect: (value: string[]) => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
@@ -47,9 +46,9 @@ export const QuestionFilterComboBox = ({
|
||||
|
||||
// multiple when question type is multi selection
|
||||
const isMultiple =
|
||||
type === TSurveyQuestionType.MultipleChoiceMulti ||
|
||||
type === TSurveyQuestionType.MultipleChoiceSingle ||
|
||||
type === TSurveyQuestionType.PictureSelection;
|
||||
type === TSurveyQuestionTypeEnum.MultipleChoiceMulti ||
|
||||
type === TSurveyQuestionTypeEnum.MultipleChoiceSingle ||
|
||||
type === TSurveyQuestionTypeEnum.PictureSelection;
|
||||
|
||||
// when question type is multi selection so we remove the option from the options which has been already selected
|
||||
const options = isMultiple
|
||||
@@ -63,7 +62,7 @@ export const QuestionFilterComboBox = ({
|
||||
|
||||
// disable the combo box for selection of value when question type is nps or rating and selected value is submitted or skipped
|
||||
const isDisabledComboBox =
|
||||
(type === TSurveyQuestionType.NPS || type === TSurveyQuestionType.Rating) &&
|
||||
(type === TSurveyQuestionTypeEnum.NPS || type === TSurveyQuestionTypeEnum.Rating) &&
|
||||
(filterValue === "Submitted" || filterValue === "Skipped");
|
||||
|
||||
return (
|
||||
|
||||
+12
-13
@@ -22,10 +22,9 @@ import {
|
||||
User,
|
||||
} from "lucide-react";
|
||||
import * as React from "react";
|
||||
|
||||
import { getLocalizedValue } from "@formbricks/lib/i18n/utils";
|
||||
import { useClickOutside } from "@formbricks/lib/utils/hooks/useClickOutside";
|
||||
import { TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
@@ -47,7 +46,7 @@ export enum OptionsType {
|
||||
|
||||
export type QuestionOption = {
|
||||
label: string;
|
||||
questionType?: TSurveyQuestionType;
|
||||
questionType?: TSurveyQuestionTypeEnum;
|
||||
type: OptionsType;
|
||||
id: string;
|
||||
};
|
||||
@@ -67,25 +66,25 @@ const SelectedCommandItem = ({ label, questionType, type }: Partial<QuestionOpti
|
||||
switch (type) {
|
||||
case OptionsType.QUESTIONS:
|
||||
switch (questionType) {
|
||||
case TSurveyQuestionType.OpenText:
|
||||
case TSurveyQuestionTypeEnum.OpenText:
|
||||
return <MessageSquareTextIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.Rating:
|
||||
case TSurveyQuestionTypeEnum.Rating:
|
||||
return <StarIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.CTA:
|
||||
case TSurveyQuestionTypeEnum.CTA:
|
||||
return <MousePointerClickIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.OpenText:
|
||||
case TSurveyQuestionTypeEnum.OpenText:
|
||||
return <HelpCircleIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.MultipleChoiceMulti:
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceMulti:
|
||||
return <ListIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.MultipleChoiceSingle:
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceSingle:
|
||||
return <Rows3Icon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.NPS:
|
||||
case TSurveyQuestionTypeEnum.NPS:
|
||||
return <NetPromoterScoreIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.Consent:
|
||||
case TSurveyQuestionTypeEnum.Consent:
|
||||
return <CheckIcon width={18} height={18} className="text-white" />;
|
||||
case TSurveyQuestionType.PictureSelection:
|
||||
case TSurveyQuestionTypeEnum.PictureSelection:
|
||||
return <ImageIcon width={18} className="text-white" />;
|
||||
case TSurveyQuestionType.Matrix:
|
||||
case TSurveyQuestionTypeEnum.Matrix:
|
||||
return <GridIcon width={18} className="text-white" />;
|
||||
}
|
||||
case OptionsType.ATTRIBUTES:
|
||||
|
||||
+2
-4
@@ -14,16 +14,14 @@ import { TrashIcon } from "lucide-react";
|
||||
import { ChevronDown, ChevronUp, Plus } from "lucide-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { TSurvey, TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurvey, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import { Checkbox } from "@formbricks/ui/Checkbox";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@formbricks/ui/Popover";
|
||||
|
||||
import { OptionsType, QuestionOption, QuestionsComboBox } from "./QuestionsComboBox";
|
||||
|
||||
export type QuestionFilterOptions = {
|
||||
type: TSurveyQuestionType | "Attributes" | "Tags" | "Languages";
|
||||
type: TSurveyQuestionTypeEnum | "Attributes" | "Tags" | "Languages";
|
||||
filterOptions: string[];
|
||||
filterComboBoxOptions: string[];
|
||||
id: string;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { responses } from "@/app/lib/api/response";
|
||||
import { headers } from "next/headers";
|
||||
|
||||
import { ProductFeatureKeys } from "@formbricks/ee/billing/lib/constants";
|
||||
import { reportUsageToStripe } from "@formbricks/ee/billing/lib/reportUsage";
|
||||
import { reportUsageToStripe } from "@formbricks/ee/billing/lib/report-usage";
|
||||
import { CRON_SECRET, IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
|
||||
import {
|
||||
getMonthlyActiveOrganizationPeopleCount,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { TIntegrationGoogleSheets } from "@formbricks/types/integration/googleSh
|
||||
import { TIntegrationNotion, TIntegrationNotionConfigData } from "@formbricks/types/integration/notion";
|
||||
import { TIntegrationSlack } from "@formbricks/types/integration/slack";
|
||||
import { TPipelineInput } from "@formbricks/types/pipelines";
|
||||
import { TSurvey, TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurvey, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
|
||||
export const handleIntegrations = async (
|
||||
integrations: TIntegration[],
|
||||
@@ -103,7 +103,7 @@ const extractResponses = async (
|
||||
|
||||
if (responseValue !== undefined) {
|
||||
let answer: typeof responseValue;
|
||||
if (question.type === TSurveyQuestionType.PictureSelection) {
|
||||
if (question.type === TSurveyQuestionTypeEnum.PictureSelection) {
|
||||
const selectedChoiceIds = responseValue as string[];
|
||||
answer = question?.choices
|
||||
.filter((choice) => selectedChoiceIds.includes(choice.id))
|
||||
@@ -147,7 +147,7 @@ const buildNotionPayloadProperties = (
|
||||
const responses = data.response.data;
|
||||
|
||||
const mappingQIds = mapping
|
||||
.filter((m) => m.question.type === TSurveyQuestionType.PictureSelection)
|
||||
.filter((m) => m.question.type === TSurveyQuestionTypeEnum.PictureSelection)
|
||||
.map((m) => m.question.id);
|
||||
|
||||
Object.keys(responses).forEach((resp) => {
|
||||
|
||||
@@ -14,9 +14,8 @@ import {
|
||||
Rows3Icon,
|
||||
StarIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
import {
|
||||
TSurveyQuestionType as QuestionId,
|
||||
TSurveyQuestionTypeEnum as QuestionId,
|
||||
TSurveyAddressQuestion,
|
||||
TSurveyCTAQuestion,
|
||||
TSurveyCalQuestion,
|
||||
@@ -28,10 +27,9 @@ import {
|
||||
TSurveyNPSQuestion,
|
||||
TSurveyOpenTextQuestion,
|
||||
TSurveyPictureSelectionQuestion,
|
||||
TSurveyQuestionType,
|
||||
TSurveyQuestionTypeEnum,
|
||||
TSurveyRatingQuestion,
|
||||
} from "@formbricks/types/surveys";
|
||||
|
||||
import { replaceQuestionPresetPlaceholders } from "./templates";
|
||||
|
||||
export type TQuestion = {
|
||||
@@ -232,7 +230,7 @@ export const QUESTIONS_NAME_MAP = questionTypes.reduce(
|
||||
[curr.id]: curr.label,
|
||||
}),
|
||||
{}
|
||||
) as Record<TSurveyQuestionType, string>;
|
||||
) as Record<TSurveyQuestionTypeEnum, string>;
|
||||
|
||||
export const universalQuestionPresets = {
|
||||
required: true,
|
||||
@@ -243,7 +241,7 @@ export const getQuestionDefaults = (id: string, product: any) => {
|
||||
return replaceQuestionPresetPlaceholders(questionType?.preset, product);
|
||||
};
|
||||
|
||||
export const getTSurveyQuestionTypeName = (id: string) => {
|
||||
export const getTSurveyQuestionTypeEnumName = (id: string) => {
|
||||
const questionType = questionTypes.find((questionType) => questionType.id === id);
|
||||
return questionType?.label;
|
||||
};
|
||||
|
||||
@@ -9,14 +9,13 @@ import {
|
||||
QuestionOptions,
|
||||
} from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/components/QuestionsComboBox";
|
||||
import { QuestionFilterOptions } from "@/app/(app)/environments/[environmentId]/surveys/[surveyId]/components/ResponseFilter";
|
||||
|
||||
import {
|
||||
TResponseFilterCriteria,
|
||||
TResponseHiddenFieldsFilter,
|
||||
TSurveyMetaFieldFilter,
|
||||
TSurveyPersonAttributes,
|
||||
} from "@formbricks/types/responses";
|
||||
import { TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { TSurvey } from "@formbricks/types/surveys";
|
||||
import { TTag } from "@formbricks/types/tags";
|
||||
|
||||
@@ -75,8 +74,8 @@ export const generateQuestionAndFilterOptions = (
|
||||
survey.questions.forEach((q) => {
|
||||
if (Object.keys(conditionOptions).includes(q.type)) {
|
||||
if (
|
||||
q.type === TSurveyQuestionType.MultipleChoiceMulti ||
|
||||
q.type === TSurveyQuestionType.MultipleChoiceSingle
|
||||
q.type === TSurveyQuestionTypeEnum.MultipleChoiceMulti ||
|
||||
q.type === TSurveyQuestionTypeEnum.MultipleChoiceSingle
|
||||
) {
|
||||
questionFilterOptions.push({
|
||||
type: q.type,
|
||||
@@ -86,14 +85,14 @@ export const generateQuestionAndFilterOptions = (
|
||||
: [""],
|
||||
id: q.id,
|
||||
});
|
||||
} else if (q.type === TSurveyQuestionType.PictureSelection) {
|
||||
} else if (q.type === TSurveyQuestionTypeEnum.PictureSelection) {
|
||||
questionFilterOptions.push({
|
||||
type: q.type,
|
||||
filterOptions: conditionOptions[q.type],
|
||||
filterComboBoxOptions: q?.choices ? q?.choices?.map((_, idx) => `Picture ${idx + 1}`) : [""],
|
||||
id: q.id,
|
||||
});
|
||||
} else if (q.type === TSurveyQuestionType.Matrix) {
|
||||
} else if (q.type === TSurveyQuestionTypeEnum.Matrix) {
|
||||
questionFilterOptions.push({
|
||||
type: q.type,
|
||||
filterOptions: q.rows.flatMap((row) => Object.values(row)),
|
||||
@@ -268,8 +267,8 @@ export const getFormattedFilters = (
|
||||
questions.forEach(({ filterType, questionType }) => {
|
||||
if (!filters.data) filters.data = {};
|
||||
switch (questionType.questionType) {
|
||||
case TSurveyQuestionType.OpenText:
|
||||
case TSurveyQuestionType.Address: {
|
||||
case TSurveyQuestionTypeEnum.OpenText:
|
||||
case TSurveyQuestionTypeEnum.Address: {
|
||||
if (filterType.filterComboBoxValue === "Filled out") {
|
||||
filters.data[questionType.id ?? ""] = {
|
||||
op: "submitted",
|
||||
@@ -280,8 +279,8 @@ export const getFormattedFilters = (
|
||||
};
|
||||
}
|
||||
}
|
||||
case TSurveyQuestionType.MultipleChoiceSingle:
|
||||
case TSurveyQuestionType.MultipleChoiceMulti: {
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceSingle:
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceMulti: {
|
||||
if (filterType.filterValue === "Includes either") {
|
||||
filters.data[questionType.id ?? ""] = {
|
||||
op: "includesOne",
|
||||
@@ -294,8 +293,8 @@ export const getFormattedFilters = (
|
||||
};
|
||||
}
|
||||
}
|
||||
case TSurveyQuestionType.NPS:
|
||||
case TSurveyQuestionType.Rating: {
|
||||
case TSurveyQuestionTypeEnum.NPS:
|
||||
case TSurveyQuestionTypeEnum.Rating: {
|
||||
if (filterType.filterValue === "Is equal to") {
|
||||
filters.data[questionType.id ?? ""] = {
|
||||
op: "equals",
|
||||
@@ -321,7 +320,7 @@ export const getFormattedFilters = (
|
||||
};
|
||||
}
|
||||
}
|
||||
case TSurveyQuestionType.CTA: {
|
||||
case TSurveyQuestionTypeEnum.CTA: {
|
||||
if (filterType.filterComboBoxValue === "Clicked") {
|
||||
filters.data[questionType.id ?? ""] = {
|
||||
op: "clicked",
|
||||
@@ -332,7 +331,7 @@ export const getFormattedFilters = (
|
||||
};
|
||||
}
|
||||
}
|
||||
case TSurveyQuestionType.Consent: {
|
||||
case TSurveyQuestionTypeEnum.Consent: {
|
||||
if (filterType.filterComboBoxValue === "Accepted") {
|
||||
filters.data[questionType.id ?? ""] = {
|
||||
op: "accepted",
|
||||
@@ -343,12 +342,12 @@ export const getFormattedFilters = (
|
||||
};
|
||||
}
|
||||
}
|
||||
case TSurveyQuestionType.PictureSelection: {
|
||||
case TSurveyQuestionTypeEnum.PictureSelection: {
|
||||
const questionId = questionType.id ?? "";
|
||||
const question = survey.questions.find((q) => q.id === questionId);
|
||||
|
||||
if (
|
||||
question?.type !== TSurveyQuestionType.PictureSelection ||
|
||||
question?.type !== TSurveyQuestionTypeEnum.PictureSelection ||
|
||||
!Array.isArray(filterType.filterComboBoxValue)
|
||||
) {
|
||||
return;
|
||||
@@ -371,7 +370,7 @@ export const getFormattedFilters = (
|
||||
};
|
||||
}
|
||||
}
|
||||
case TSurveyQuestionType.Matrix: {
|
||||
case TSurveyQuestionTypeEnum.Matrix: {
|
||||
if (
|
||||
filterType.filterValue &&
|
||||
filterType.filterComboBoxValue &&
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TResponseData } from "@formbricks/types/responses";
|
||||
import { TSurveyQuestionType } from "@formbricks/types/surveys";
|
||||
import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys";
|
||||
import { TSurvey, TSurveyQuestion } from "@formbricks/types/surveys";
|
||||
|
||||
export const getPrefillValue = (
|
||||
@@ -32,10 +32,10 @@ export const checkValidity = (question: TSurveyQuestion, answer: string, languag
|
||||
if (question.required && (!answer || answer === "")) return false;
|
||||
try {
|
||||
switch (question.type) {
|
||||
case TSurveyQuestionType.OpenText: {
|
||||
case TSurveyQuestionTypeEnum.OpenText: {
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.MultipleChoiceSingle: {
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceSingle: {
|
||||
const hasOther = question.choices[question.choices.length - 1].id === "other";
|
||||
if (!hasOther) {
|
||||
if (!question.choices.find((choice) => choice.label[language] === answer)) return false;
|
||||
@@ -48,7 +48,7 @@ export const checkValidity = (question: TSurveyQuestion, answer: string, languag
|
||||
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.MultipleChoiceMulti: {
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceMulti: {
|
||||
const answerChoices = answer.split(",");
|
||||
const hasOther = question.choices[question.choices.length - 1].id === "other";
|
||||
if (!hasOther) {
|
||||
@@ -62,7 +62,7 @@ export const checkValidity = (question: TSurveyQuestion, answer: string, languag
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.NPS: {
|
||||
case TSurveyQuestionTypeEnum.NPS: {
|
||||
answer = answer.replace(/&/g, ";");
|
||||
const answerNumber = Number(JSON.parse(answer));
|
||||
|
||||
@@ -70,23 +70,23 @@ export const checkValidity = (question: TSurveyQuestion, answer: string, languag
|
||||
if (answerNumber < 0 || answerNumber > 10) return false;
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.CTA: {
|
||||
case TSurveyQuestionTypeEnum.CTA: {
|
||||
if (question.required && answer === "dismissed") return false;
|
||||
if (answer !== "clicked" && answer !== "dismissed") return false;
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.Consent: {
|
||||
case TSurveyQuestionTypeEnum.Consent: {
|
||||
if (question.required && answer === "dismissed") return false;
|
||||
if (answer !== "accepted" && answer !== "dismissed") return false;
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.Rating: {
|
||||
case TSurveyQuestionTypeEnum.Rating: {
|
||||
answer = answer.replace(/&/g, ";");
|
||||
const answerNumber = Number(JSON.parse(answer));
|
||||
if (answerNumber < 1 || answerNumber > question.range) return false;
|
||||
return true;
|
||||
}
|
||||
case TSurveyQuestionType.PictureSelection: {
|
||||
case TSurveyQuestionTypeEnum.PictureSelection: {
|
||||
const answerChoices = answer.split(",");
|
||||
return answerChoices.every((ans: string) => !isNaN(Number(ans)));
|
||||
}
|
||||
@@ -104,20 +104,20 @@ export const transformAnswer = (
|
||||
language: string
|
||||
): string | number | string[] => {
|
||||
switch (question.type) {
|
||||
case TSurveyQuestionType.OpenText:
|
||||
case TSurveyQuestionType.MultipleChoiceSingle:
|
||||
case TSurveyQuestionType.Consent:
|
||||
case TSurveyQuestionType.CTA: {
|
||||
case TSurveyQuestionTypeEnum.OpenText:
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceSingle:
|
||||
case TSurveyQuestionTypeEnum.Consent:
|
||||
case TSurveyQuestionTypeEnum.CTA: {
|
||||
return answer;
|
||||
}
|
||||
|
||||
case TSurveyQuestionType.Rating:
|
||||
case TSurveyQuestionType.NPS: {
|
||||
case TSurveyQuestionTypeEnum.Rating:
|
||||
case TSurveyQuestionTypeEnum.NPS: {
|
||||
answer = answer.replace(/&/g, ";");
|
||||
return Number(JSON.parse(answer));
|
||||
}
|
||||
|
||||
case TSurveyQuestionType.PictureSelection: {
|
||||
case TSurveyQuestionTypeEnum.PictureSelection: {
|
||||
const answerChoicesIdx = answer.split(",");
|
||||
const answerArr: string[] = [];
|
||||
|
||||
@@ -130,7 +130,7 @@ export const transformAnswer = (
|
||||
return answerArr.slice(0, 1);
|
||||
}
|
||||
|
||||
case TSurveyQuestionType.MultipleChoiceMulti: {
|
||||
case TSurveyQuestionTypeEnum.MultipleChoiceMulti: {
|
||||
let ansArr = answer.split(",");
|
||||
const hasOthers = question.choices[question.choices.length - 1].id === "other";
|
||||
if (!hasOthers) return ansArr;
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
"lucide-react": "^0.379.0",
|
||||
"mime": "^4.0.3",
|
||||
"next": "15.0.0-rc.0",
|
||||
"nodemailer": "^6.9.13",
|
||||
"optional": "^0.1.4",
|
||||
"otplib": "^12.0.1",
|
||||
"papaparse": "^5.4.1",
|
||||
|
||||
Reference in New Issue
Block a user