Skip to content

Commit

Permalink
Update handling of fetched form data to properly handle when user doe…
Browse files Browse the repository at this point in the history
…sn't have access to a form submission (resolves infinite loading spinner, and properly displays message to user, as intented)
  • Loading branch information
courtneymyers committed Nov 4, 2022
1 parent 717156a commit 3275824
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions app/client/src/routes/applicationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,16 @@ function ApplicationFormContent({ email }: { email: string }) {

getData(`${serverUrl}/api/formio-application-submission/${mongoId}`)
.then((res: FormioFetchedResponse) => {
if (!res.submission) return;

// set up s3 re-route to wrapper app
const s3Provider = Formio.Providers.providers.storage.s3;
Formio.Providers.providers.storage.s3 = function (formio: any) {
const s3Formio = cloneDeep(formio);
const comboKey = res.submission.data.bap_hidden_entity_combo_key;
const comboKey = res.submission?.data.bap_hidden_entity_combo_key;
s3Formio.formUrl = `${serverUrl}/api/s3/application/${mongoId}/${comboKey}`;
return s3Provider(s3Formio);
};

const data = { ...res.submission.data };
const data = { ...res.submission?.data };

// remove `ncesDataSource` and `ncesDataLookup` fields
if (data.hasOwnProperty("ncesDataSource")) delete data.ncesDataSource;
Expand Down
8 changes: 3 additions & 5 deletions app/client/src/routes/paymentRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,17 @@ function PaymentRequestFormContent({ email }: { email: string }) {

getData(`${serverUrl}/api/formio-payment-request-submission/${rebateId}`)
.then((res: FormioFetchedResponse) => {
if (!res.submission) return;

// set up s3 re-route to wrapper app
const s3Provider = Formio.Providers.providers.storage.s3;
Formio.Providers.providers.storage.s3 = function (formio: any) {
const s3Formio = cloneDeep(formio);
const mongoId = res.submission._id;
const comboKey = res.submission.data.bap_hidden_entity_combo_key;
const mongoId = res.submission?._id;
const comboKey = res.submission?.data.bap_hidden_entity_combo_key;
s3Formio.formUrl = `${serverUrl}/api/s3/payment-request/${mongoId}/${comboKey}`;
return s3Provider(s3Formio);
};

const data = { ...res.submission.data };
const data = { ...res.submission?.data };

setStoredSubmissionData((_prevData) => {
storedSubmissionDataRef.current = cloneDeep(data);
Expand Down

0 comments on commit 3275824

Please sign in to comment.