Skip to content

Commit 4a9f5e8

Browse files
authored
Merge branch 'main' into feat/implement_axios_retry_hCaptcha
2 parents 3ab19aa + 7846cb3 commit 4a9f5e8

File tree

107 files changed

+4831
-2574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4831
-2574
lines changed

app/(gcforms)/[locale]/(app administration)/admin/(with nav)/accounts/[id]/manage-user-features/components/client/AddUserFeatureModal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useTranslation } from "@i18n/client";
44
import { useState } from "react";
55
import { AppUser } from "@lib/types/user-types";
66
import { setUserFlags } from "../../actions";
7-
7+
import { useSession } from "next-auth/react";
88
import { UserFeatureFlags, UserFeatureFlagKeys } from "@lib/cache/types";
99

1010
export const AddUserFeatureModal = ({
@@ -19,6 +19,7 @@ export const AddUserFeatureModal = ({
1919
const { t } = useTranslation("admin-flags");
2020
const [showModal, setShowModal] = useState(false);
2121
const [selectedFlags, setSelectedFlags] = useState<string[]>([]);
22+
const { update: updateSession } = useSession();
2223

2324
// Filter the list of flags to only include user level feature flags
2425
const availableFeatureFlags = flags.filter((flag) =>
@@ -31,10 +32,11 @@ export const AddUserFeatureModal = ({
3132
);
3233
};
3334

34-
const handleAdd = () => {
35-
setUserFlags(formUser.id, selectedFlags);
35+
const handleAdd = async () => {
36+
await setUserFlags(formUser.id, selectedFlags);
3637
setShowModal(false);
3738
setSelectedFlags([]);
39+
await updateSession();
3840
};
3941

4042
const handleCancel = () => {

app/(gcforms)/[locale]/(app administration)/admin/(with nav)/accounts/[id]/manage-user-features/components/client/RemoveFeatureButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { Button } from "@clientComponents/globals";
33
import { AppUser } from "@lib/types/user-types";
44
import { useTranslation } from "@i18n/client";
55
import { removeUserFlag } from "../../actions";
6+
import { useSession } from "next-auth/react";
67

78
export const RemoveFeatureButton = ({ formUser, flag }: { formUser: AppUser; flag: string }) => {
89
const { t } = useTranslation("admin-flags");
10+
const { update: updateSession } = useSession();
911

1012
const handleRemove = async () => {
1113
await removeUserFlag(formUser.id, flag);
14+
await updateSession();
1215
};
1316

1417
return (

app/(gcforms)/[locale]/(form administration)/form-builder/Start.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { validateTemplateSize } from "@lib/utils/validateTemplateSize";
1313
import { ga } from "@lib/client/clientHelpers";
1414
import { validateUniqueQuestionIds } from "@lib/utils/validateUniqueQuestionIds";
1515
import { transformFormProperties } from "@lib/store/helpers/elements/transformFormProperties";
16+
import { BetaComponentsError, checkForBetaComponents } from "@lib/validation/betaCheck";
17+
import { useFeatureFlags } from "@lib/hooks/useFeatureFlags";
1618

1719
export const Start = () => {
1820
const {
@@ -26,6 +28,7 @@ export const Start = () => {
2628
}));
2729

2830
const [errors, setErrors] = useState<errorMessage[]>();
31+
const { getFlag } = useFeatureFlags();
2932

3033
// Prevent prototype pollution in JSON.parse https://stackoverflow.com/a/63927372
3134
const cleaner = (key: string, value: string) =>
@@ -78,10 +81,18 @@ export const Start = () => {
7881
return;
7982
}
8083

81-
importTemplate(data);
84+
try {
85+
checkForBetaComponents(data.elements, getFlag);
8286

83-
ga("open_form_file");
84-
router.push(`/${language}/form-builder/0000/preview`);
87+
importTemplate(data);
88+
89+
ga("open_form_file");
90+
router.push(`/${language}/form-builder/0000/preview`);
91+
} catch (e) {
92+
if (e instanceof BetaComponentsError) {
93+
setErrors([{ message: t("beta.loadingError") }]);
94+
}
95+
}
8596
};
8697
} catch (e) {
8798
if (e instanceof Error) {
@@ -99,9 +110,11 @@ export const Start = () => {
99110
<div role="alert">
100111
{errors && (
101112
<div className="m-auto mb-8 flex w-5/12 bg-red-100 p-6">
102-
<WarningIcon />
103113
<div>
104-
<h3 className="mb-2 ml-6 mt-1">{t("failedToReadFormFile")}</h3>
114+
<WarningIcon className="mt-1" />
115+
</div>
116+
<div>
117+
<h3 className="mb-2 ml-6">{t("failedToReadFormFile")}</h3>
105118
<ul className="mb-4 list-none pl-6">
106119
{errors.map((error, index) => {
107120
return (

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/components/dialogs/RulesDialog/RulesDialog.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ import { useTreeRef } from "@formBuilder/components/shared/right-panel/treeview/
99
import { useRouter } from "next/navigation";
1010
import { FormElementWithIndex } from "@lib/types/form-builder-types";
1111
import { Button } from "@clientComponents/globals/Buttons/Button";
12-
import {
13-
ChoiceRule,
14-
choiceRulesToConditonalRules,
15-
cleanChoiceIdsFromRules,
16-
} from "@lib/formContext";
12+
import { type ChoiceRule } from "@gcforms/types";
13+
import { choiceRulesToConditonalRules, cleanChoiceIdsFromRules } from "@gcforms/core";
1714
import { getPathString } from "@lib/utils/form-builder/getPath";
1815
import { useRefsContext } from "@formBuilder/[id]/edit/components/RefsContext";
1916

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/components/dialogs/RulesDialog/RulesForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { useTranslation } from "@i18n/client";
44

55
import { Button } from "@clientComponents/globals";
66
import { useTemplateStore } from "@lib/store/useTemplateStore";
7-
import { ChoiceRule, getElementsWithRuleForChoice } from "@lib/formContext";
7+
import { type ChoiceRule } from "@gcforms/types";
8+
import { getElementsWithRuleForChoice } from "@gcforms/core";
89
import { ConditionalSelector } from "@formBuilder/components/shared/conditionals/ConditionalSelector";
910
import { sortByGroups, sortByLayout } from "@lib/utils/form-builder";
1011
import { AddOther } from "@formBuilder/components/shared/conditionals/AddOther";

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/components/elements/element-dialog/descriptions/FileInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export const FileInputTrialDescription = () => {
5353
<li>
5454
<Link href={link}>{t("addElementDialog.fileInputWithApi.trialFeature.bullet1")}</Link>
5555
</li>
56+
<li>{t("addElementDialog.fileInputWithApi.trialFeature.bullet2")}</li>
5657
<li>{t("addElementDialog.fileInputWithApi.trialFeature.bullet3")}</li>
57-
<li>{t("addElementDialog.fileInputWithApi.trialFeature.bullet4")}</li>
5858
</ul>
5959
</div>
6060
);

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/logic/components/LogicNavigation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { toast } from "@formBuilder/components/shared/Toast";
55
import { Tooltip } from "@formBuilder/components/shared/Tooltip";
66
import { useGroupStore } from "@formBuilder/components/shared/right-panel/treeview/store/useGroupStore";
77
import { autoFlowAllNextActions } from "@formBuilder/components/shared/right-panel/treeview/util/setNextAction";
8-
import { GroupsType } from "@lib/formContext";
8+
import { type GroupsType } from "@gcforms/types";
99
import { SortIcon } from "@serverComponents/icons";
1010
import { useTranslation } from "@i18n/client";
1111
import { useFlowRef } from "@formBuilder/[id]/edit/logic/components/flow/provider/FlowRefProvider";

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/logic/components/flow/useFlowData.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { TreeItem, TreeItemIndex } from "react-complex-tree";
44

55
import { useGroupStore } from "@formBuilder/components/shared/right-panel/treeview/store/useGroupStore";
66
import { useTemplateStore } from "@lib/store/useTemplateStore";
7-
import { Group, GroupsType, NextActionRule } from "@lib/formContext";
7+
import { Group, GroupsType } from "@gcforms/types";
8+
import { type NextActionRule } from "@gcforms/types";
89
import { Language } from "@lib/types/form-builder-types";
910
import { getReviewNode, getStartElements, getEndNode } from "@lib/utils/form-builder/i18nHelpers";
1011
import { getStartLabels } from "@lib/utils/form-builder/i18nHelpers";

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/translate/components/ExitUrl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { LocalizedElementProperties } from "@lib/types/form-builder-types";
88
import { FieldsetLegend } from "./FieldsetLegend";
99
import { useTranslation } from "@i18n/client";
1010

11-
import { type Group } from "@lib/formContext";
11+
import { type Group } from "@gcforms/types";
1212

1313
const FieldInput = ({ groupId, val, lang }: { groupId: string; val: string; lang: Language }) => {
1414
const setExitButtonUrl = useGroupStore((state) => state.setExitButtonUrl);

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/translate/components/TranslateWithGroups.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { SaveButton } from "@formBuilder/components/shared/SaveButton";
2121
import { FormElement, FormElementTypes } from "@lib/types";
2222
import { SkipLinkReusable } from "@clientComponents/globals/SkipLinkReusable";
2323
import { sortGroup } from "@lib/utils/form-builder/groupedFormHelpers";
24-
import { Group } from "@lib/formContext";
24+
import { Group } from "@gcforms/types";
2525
import { TranslateCustomizeSet } from "./TranslateCustomizeSet";
2626

2727
import { ExitUrl } from "./ExitUrl";

0 commit comments

Comments
 (0)