diff --git a/api/app/Http/Controllers/Forms/PublicFormController.php b/api/app/Http/Controllers/Forms/PublicFormController.php index 059b829e..0110ab82 100644 --- a/api/app/Http/Controllers/Forms/PublicFormController.php +++ b/api/app/Http/Controllers/Forms/PublicFormController.php @@ -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) { diff --git a/client/components/open/forms/OpenForm.vue b/client/components/open/forms/OpenForm.vue index 6e06072e..2569ca42 100644 --- a/client/components/open/forms/OpenForm.vue +++ b/client/components/open/forms/OpenForm.vue @@ -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)