diff --git a/__fixtures__/testDataWithGroupsLayout.json b/__fixtures__/testDataWithGroupsLayout.json new file mode 100644 index 0000000000..712b128abd --- /dev/null +++ b/__fixtures__/testDataWithGroupsLayout.json @@ -0,0 +1,360 @@ +{ + "titleEn": "show-hide-groups-test", + "titleFr": "[FR]show-hide-groups-test", + "introduction": { + "descriptionEn": "", + "descriptionFr": "" + }, + "privacyPolicy": { + "descriptionEn": "Privacy statement", + "descriptionFr": "[FR]Privacy statement" + }, + "confirmation": { + "descriptionEn": "Confirmation message", + "descriptionFr": "[FR]Confirmation message", + "referrerUrlEn": "", + "referrerUrlFr": "" + }, + "layout": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + "elements": [ + { + "id": 8, + "type": "radio", + "properties": { + "choices": [ + { + "en": "A", + "fr": "[FR]A" + }, + { + "en": "B", + "fr": "[FR]B" + } + ], + "titleEn": "P3-Q1", + "titleFr": "[FR]P3-Q1", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [] + } + }, + { + "id": 9, + "type": "textField", + "properties": { + "choices": [ + { + "en": "", + "fr": "" + } + ], + "titleEn": "P3-Q1-A", + "titleFr": "[FR]P3-Q1-A", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [ + { + "choiceId": "8.0" + } + ] + } + }, + { + "id": 10, + "type": "textField", + "properties": { + "choices": [ + { + "en": "", + "fr": "" + } + ], + "titleEn": "P3-Q1-B", + "titleFr": "[FR]P3-Q1-B", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [ + { + "choiceId": "8.1" + } + ] + } + }, + { + "id": 5, + "type": "radio", + "properties": { + "choices": [ + { + "en": "A", + "fr": "[FR]A" + }, + { + "en": "B", + "fr": "[FR]B" + } + ], + "titleEn": "P2-Q1", + "titleFr": "[FR]P2-Q1", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [] + } + }, + { + "id": 6, + "type": "textField", + "properties": { + "choices": [ + { + "en": "", + "fr": "" + } + ], + "titleEn": "P2-Q1-A", + "titleFr": "[FR]P2-Q1-A", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [ + { + "choiceId": "5.0" + } + ] + } + }, + { + "id": 7, + "type": "textField", + "properties": { + "choices": [ + { + "en": "", + "fr": "" + } + ], + "titleEn": "P2-Q1-B", + "titleFr": "[FR]P2-Q1-B", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [ + { + "choiceId": "5.1" + } + ] + } + }, + { + "id": 2, + "type": "radio", + "properties": { + "choices": [ + { + "en": "A", + "fr": "[FR]A" + }, + { + "en": "B", + "fr": "[FR]B" + } + ], + "titleEn": "P1-Q1", + "titleFr": "[FR]P1-Q1", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [] + } + }, + { + "id": 3, + "type": "textField", + "properties": { + "choices": [ + { + "en": "", + "fr": "" + } + ], + "titleEn": "P1-Q1-A", + "titleFr": "[FR]P1-Q1-A", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [ + { + "choiceId": "2.0" + } + ] + } + }, + { + "id": 4, + "type": "textField", + "properties": { + "choices": [ + { + "en": "", + "fr": "" + } + ], + "titleEn": "P1-Q1-B", + "titleFr": "[FR]P1-Q1-B", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [ + { + "choiceId": "2.1" + } + ] + } + }, + { + "id": 1, + "type": "radio", + "properties": { + "choices": [ + { + "en": "A", + "fr": "[FR]A" + }, + { + "en": "B", + "fr": "[FR]B" + }, + { + "en": "C", + "fr": "[FR]C" + } + ], + "titleEn": "Q1", + "titleFr": "[FR]Q1", + "validation": { + "required": false + }, + "subElements": [], + "descriptionEn": "", + "descriptionFr": "", + "placeholderEn": "", + "placeholderFr": "", + "conditionalRules": [] + } + } + ], + "groups": { + "start": { + "name": "Start", + "titleEn": "Beginning", + "titleFr": "Beginning", + "autoFlow": false, + "elements": ["1"], + "nextAction": [ + { + "groupId": "84b36e7b-2c6c-40be-ad22-1abd24c38019", + "choiceId": "1.0" + }, + { + "groupId": "6365ee9b-1caa-4a08-b53d-ecfc2a9dd08f", + "choiceId": "1.1" + }, + { + "groupId": "1231e20c-080e-4119-9774-33d829f290da", + "choiceId": "1.2" + } + ] + }, + "84b36e7b-2c6c-40be-ad22-1abd24c38019": { + "name": "P1", + "titleEn": "P1", + "titleFr": "[FR]P1", + "autoFlow": false, + "elements": ["2", "3", "4"], + "nextAction": "review" + }, + "6365ee9b-1caa-4a08-b53d-ecfc2a9dd08f": { + "name": "P2", + "titleEn": "P2", + "titleFr": "[FR]P2", + "autoFlow": false, + "elements": ["5", "6", "7"], + "nextAction": "review" + }, + "1231e20c-080e-4119-9774-33d829f290da": { + "name": "P3", + "titleEn": "P3", + "titleFr": "[FR]P3", + "autoFlow": true, + "elements": ["8", "9", "10"], + "nextAction": "review" + }, + "review": { + "name": "Review", + "titleEn": "Review", + "titleFr": "Review", + "elements": [], + "nextAction": "end" + }, + "end": { + "name": "End", + "titleEn": "End", + "titleFr": "End", + "elements": [] + } + }, + "groupsLayout": [ + "84b36e7b-2c6c-40be-ad22-1abd24c38019", + "6365ee9b-1caa-4a08-b53d-ecfc2a9dd08f", + "1231e20c-080e-4119-9774-33d829f290da" + ] +} diff --git a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx index f93f96b65f..0ec464b7a7 100644 --- a/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx +++ b/app/(gcforms)/[locale]/(form administration)/form-builder/[id]/preview/Preview.tsx @@ -26,6 +26,7 @@ import { safeJSONParse } from "@lib/utils"; import { ErrorSaving } from "@formBuilder/components/shared/ErrorSaving"; import { toast } from "@formBuilder/components/shared"; import { defaultForm } from "@lib/store/defaults"; +import { showReviewPage } from "@lib/utils/form-builder/showReviewPage"; export const Preview = ({ disableSubmit = true, @@ -94,6 +95,8 @@ export const Preview = ({ const hasHydrated = useRehydrate(); + const isShowReviewPage = showReviewPage(formRecord.form); + if (isPastClosingDate) { return (
@@ -205,7 +208,9 @@ export const Preview = ({ fallBack={() => { return ( <> - {allowGrouping && } + {allowGrouping && isShowReviewPage && ( + + )}