Skip to content

Commit

Permalink
chore: Remove allowGrouping checks (#4443)
Browse files Browse the repository at this point in the history
* Remove allowGrouping checks

* unused export
  • Loading branch information
dsamojlenko authored Oct 21, 2024
1 parent b5ba612 commit 87c2157
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 279 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export { RichText } from "./RichText";
export { RichTextLocked } from "./RichTextLocked";
export { Question } from "./question/Question";
export { QuestionInput } from "./question/QuestionInput";
export { QuestionNumber } from "./question/QuestionNumber";
export { AddElementButton } from "./element-dialog/AddElementButton";
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Language,
} from "@lib/types/form-builder-types";
import { useTemplateStore } from "@lib/store/useTemplateStore";
import { QuestionInput, QuestionNumber } from "..";
import { QuestionInput } from "..";

export const Question = ({
item,
Expand All @@ -17,15 +17,10 @@ export const Question = ({
onQuestionChange: (itemId: number, val: string, lang: Language) => void;
describedById?: string;
}) => {
const { localizeField, translationLanguagePriority, getGroupsEnabled } = useTemplateStore(
(s) => ({
localizeField: s.localizeField,
translationLanguagePriority: s.translationLanguagePriority,
getGroupsEnabled: s.getGroupsEnabled,
})
);

const groupsEnabled = getGroupsEnabled();
const { localizeField, translationLanguagePriority } = useTemplateStore((s) => ({
localizeField: s.localizeField,
translationLanguagePriority: s.translationLanguagePriority,
}));

const itemIndex = item.index;
const isRichText = item.type === "richText";
Expand All @@ -35,9 +30,6 @@ export const Question = ({

return isRichText ? null : (
<>
{!groupsEnabled && (
<QuestionNumber index={itemIndex} questionNumber={item.questionNumber || ""} />
)}
<QuestionInput
initialValue={title}
index={itemIndex}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { serverTranslation } from "@i18n";
import { Metadata } from "next";
import { allowGrouping } from "@formBuilder/components/shared/right-panel/treeview/util/allowGrouping";
import { FlowWithProvider } from "./components/flow/FlowWithProvider";
import { Suspense } from "react";
import { Loader } from "@clientComponents/globals/Loader";
Expand All @@ -26,12 +25,6 @@ export default async function Page({
}: {
params: { id: string; locale: string };
}) {
const allowGroups = allowGrouping();

if (!allowGroups) {
return null;
}

const { t } = await serverTranslation("form-builder", { lang: locale });
const Loading = () => (
<div className="flex h-full items-center justify-center ">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { serverTranslation } from "@i18n";
import { Metadata } from "next";
import { Edit } from "./components/Edit";
import { EditNavigation } from "./components/EditNavigation";
import { EditWithGroups } from "./components/EditWithGroups";
import { allowGrouping } from "@formBuilder/components/shared/right-panel/treeview/util/allowGrouping";

export async function generateMetadata({
params: { locale },
Expand All @@ -21,18 +18,5 @@ export default async function Page({
}: {
params: { id: string; locale: string };
}) {
const conditionalLogic = allowGrouping();

return (
<>
{conditionalLogic ? (
<EditWithGroups id={id} locale={locale} />
) : (
<>
<EditNavigation id={id} />
<Edit formId={id} />
</>
)}
</>
);
return <EditWithGroups id={id} locale={locale} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useTemplateStore } from "@lib/store/useTemplateStore";
import { FormElementTypes } from "@lib/types";
import { getTranslatedProperties } from "../../../actions";
import { useGroupStore } from "@formBuilder/components/shared/right-panel/treeview/store/useGroupStore";
import { allowGrouping } from "@formBuilder/components/shared/right-panel/treeview/util/allowGrouping";
import { BoltIcon } from "@serverComponents/icons";
import { ChoiceRule } from "@lib/formContext";

Expand Down Expand Up @@ -53,13 +52,8 @@ export const AddOther = ({
},
};

const allowGroups = allowGrouping();
let itemId = 0;
if (allowGroups) {
itemId = await add(item.index, FormElementTypes.textField, data, groupId);
} else {
itemId = await add(item.index, FormElementTypes.textField, data);
}
itemId = await add(item.index, FormElementTypes.textField, data, groupId);

const newRule = { elementId: `${itemId}`, choiceId: `${item.id}.${lastChoice}` };
onComplete(newRule);
Expand Down
13 changes: 2 additions & 11 deletions components/clientComponents/globals/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { YourAccountDropdown } from "./YourAccountDropdown";
import { LiveMessage } from "@lib/hooks/useLiveMessage";
import Markdown from "markdown-to-jsx";

import { allowGrouping } from "@formBuilder/components/shared/right-panel/treeview/util/allowGrouping";

type HeaderParams = {
context?: "admin" | "formBuilder" | "default";
className?: string;
Expand All @@ -36,15 +34,8 @@ export const Header = ({ context = "default", className }: HeaderParams) => {
async function fetchBannerData() {
const isEnabled = t("campaignBanner.enabled") === "true";
setBannerData(isEnabled);

const isLogicEnabled = allowGrouping();
if (isLogicEnabled) {
setBannerMessage(t("campaignBanner.message2"));
setBannerType(t("campaignBanner.type2"));
} else {
setBannerMessage(t("campaignBanner.message"));
setBannerType(t("campaignBanner.type"));
}
setBannerMessage(t("campaignBanner.message2"));
setBannerType(t("campaignBanner.type2"));
}
fetchBannerData();
}, [t]);
Expand Down

0 comments on commit 87c2157

Please sign in to comment.