Skip to content

Commit

Permalink
on fetch submission data display error if there (#608)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Nahum <[email protected]>
  • Loading branch information
chiragchhatrala and JhumanJ authored Nov 13, 2024
1 parent ef12c82 commit 2c8f7d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/app/Http/Controllers/Forms/PublicFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ public function fetchSubmission(Request $request, string $slug, string $submissi
]);
}

$submission = new FormSubmissionResource(FormSubmission::findOrFail($submissionId));
$submission = FormSubmission::find($submissionId);
if (!$submission) {
return $this->error([
'message' => 'Submission not found.',
]);
}

$submission = new FormSubmissionResource($submission);
$submission->publiclyAccessed();

if ($submission->form_id != $form->id) {
Expand Down
3 changes: 3 additions & 0 deletions client/components/open/forms/OpenForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ export default {
await this.recordsStore.loadRecord(
opnFetch('/forms/' + this.form.slug + '/submissions/' + this.form.submission_id).then((data) => {
return {submission_id: this.form.submission_id, id: this.form.submission_id, ...data.data}
}).catch((error) => {
useAlert().error(error?.data?.message || 'Something went wrong')
return null
})
)
return this.recordsStore.getByKey(this.form.submission_id)
Expand Down

0 comments on commit 2c8f7d5

Please sign in to comment.