Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: shows Review page and related for multi-group forms #4091

Merged
merged 8 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
360 changes: 360 additions & 0 deletions __fixtures__/testDataWithGroupsLayout.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -94,6 +95,8 @@ export const Preview = ({

const hasHydrated = useRehydrate();

const isShowReviewPage = showReviewPage(formRecord.form);

if (isPastClosingDate) {
return (
<div className="max-w-4xl">
Expand Down Expand Up @@ -205,7 +208,9 @@ export const Preview = ({
fallBack={() => {
return (
<>
{allowGrouping && <BackButton language={language} />}
{allowGrouping && isShowReviewPage && (
<BackButton language={language} />
)}
<Button
type="submit"
id="SubmitButton"
Expand Down
Loading
Loading