-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cd097a
commit 03c4345
Showing
4 changed files
with
46 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use server'; | ||
|
||
import BackendApiClient from 'core/api/client/BackendApiClient'; | ||
import prepareSurveyApiSubmission from 'features/surveys/utils/prepareSurveyApiSubmission'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export async function submit(formData: FormData) { | ||
const data = Object.fromEntries([...formData.entries()]); | ||
const submission = prepareSurveyApiSubmission(data, false); | ||
const apiClient = new BackendApiClient({}); | ||
await apiClient.post( | ||
`/api/orgs/${data.orgId}/surveys/${data.surveyId}/submissions`, | ||
submission | ||
); | ||
redirect(`/o/${data.orgId}/surveys/${data.surveyId}/submitted`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters