Skip to content

Commit

Permalink
Merge pull request #7414 from opengovsg/hotfix/dupe-form
Browse files Browse the repository at this point in the history
hotfix: dupe form fail
  • Loading branch information
KenLSM authored Jun 19, 2024
2 parents 6c5e836 + aebc91b commit 4cde729
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 24 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.127.0](https://github.com/opengovsg/FormSG/compare/v6.127.0...v6.127.0)
#### [v6.127.1](https://github.com/opengovsg/FormSG/compare/v6.127.0...v6.127.1)

- build: release v6.127.0 [`#7413`](https://github.com/opengovsg/FormSG/pull/7413)
- fix: fix issue where duplicating forms fails [`a66cebf`](https://github.com/opengovsg/FormSG/commit/a66cebf8528675c5153ce9c57fe53bb3e0026fdd)

#### [v6.127.0](https://github.com/opengovsg/FormSG/compare/v6.126.0...v6.127.0)

Expand All @@ -20,7 +23,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: release v6.126.0 [`#7397`](https://github.com/opengovsg/FormSG/pull/7397)
- chore(deps-dev): bump @types/jwk-to-pem from 2.0.1 to 2.0.3 [`#7400`](https://github.com/opengovsg/FormSG/pull/7400)
- feat: email <> storage mode parity (#7350) [`#2264`](https://github.com/opengovsg/FormSG/issues/2264)
- chore: bump version to v6.127.0 [`fefe87b`](https://github.com/opengovsg/FormSG/commit/fefe87b2316523795a4080bc35099f08528154a4)
- chore: bump version to v6.127.0 [`cba2477`](https://github.com/opengovsg/FormSG/commit/cba2477cd464a3a1899d26d1e1df2b7051701b51)

#### [v6.126.0](https://github.com/opengovsg/FormSG/compare/v6.125.0...v6.126.0)

Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-frontend",
"version": "6.127.0",
"version": "6.127.1",
"homepage": ".",
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const useDupeFormWizardContext = (): CreateFormWizardContextReturn => {

const {
dupeEmailModeFormMutation,
dupeStorageModeOrMultirespondentFormMutation,
dupeStorageModeFormMutation,
dupeMultirespondentModeFormMutation,
} = useDuplicateFormMutations()

const { activeWorkspace, isDefaultWorkspace } = useWorkspaceContext()
Expand All @@ -72,23 +73,35 @@ export const useDupeFormWizardContext = (): CreateFormWizardContextReturn => {

const handleCreateStorageModeOrMultirespondentForm = handleSubmit(
({ title, responseMode }) => {
if (
!(
responseMode === FormResponseMode.Encrypt ||
responseMode === FormResponseMode.Multirespondent
) ||
!activeFormMeta?._id
) {
if (!activeFormMeta?._id) {
return
}

return dupeStorageModeOrMultirespondentFormMutation.mutate({
formIdToDuplicate: activeFormMeta._id,
title,
responseMode,
publicKey: keypair.publicKey,
workspaceId,
})
switch (responseMode) {
case FormResponseMode.Encrypt:
return dupeStorageModeFormMutation.mutate({
formIdToDuplicate: activeFormMeta._id,
title,
responseMode,
publicKey: keypair.publicKey,
workspaceId,
})
case FormResponseMode.Email:
return
case FormResponseMode.Multirespondent:
return dupeMultirespondentModeFormMutation.mutate({
formIdToDuplicate: activeFormMeta._id,
title,
responseMode,
publicKey: keypair.publicKey,
workspaceId,
})
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: never = responseMode
throw new Error('Invalid response mode')
}
}
},
)

Expand All @@ -110,7 +123,8 @@ export const useDupeFormWizardContext = (): CreateFormWizardContextReturn => {
isFetching: isWorkspaceLoading || isPreviewFormLoading,
isLoading:
dupeEmailModeFormMutation.isLoading ||
dupeStorageModeOrMultirespondentFormMutation.isLoading,
dupeStorageModeFormMutation.isLoading ||
dupeMultirespondentModeFormMutation.isLoading,
keypair,
currentStep,
direction,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FormSG",
"description": "Form Manager for Government",
"version": "6.127.0",
"version": "6.127.1",
"homepage": "https://form.gov.sg",
"authors": [
"FormSG <[email protected]>"
Expand Down

0 comments on commit 4cde729

Please sign in to comment.