Skip to content

Commit

Permalink
fix(app-rfi): remove timeout for testing. add prop definition. lintin…
Browse files Browse the repository at this point in the history
…g fixes
  • Loading branch information
mlsamuelson committed Oct 4, 2024
1 parent 39ece80 commit ad7bd44
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 2 additions & 0 deletions packages/app-rfi/src/components/stepper/RfiStepperButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import PropTypes from "prop-types";
import React from "react";
import { Button } from "reactstrap";

import { trackGAEvent } from "../../../../../shared";
// Note on the spans around the FA i tags below:
// When the host site/app deploys FA such that it replaces the i's with svg
Expand Down Expand Up @@ -114,6 +115,7 @@ RfiStepperButtons.propTypes = {
}),
}),
handleBack: PropTypes.func.isRequired,
rfiSubmitting: PropTypes.bool.isRequired,
formik: PropTypes.shape({
isSubmitting: PropTypes.bool.isRequired,
}),
Expand Down
3 changes: 1 addition & 2 deletions packages/app-rfi/src/core/utils/appState.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ export const useRfiState = props => {
if (isLastStep) {
setRfiSubmitting(true);
rfiSubmit(values, submissionUrl, test, () => {

setRfiSubmitting(false);
setRfiSubmitting(false);
setSuccess(true);
});
return;
Expand Down
18 changes: 8 additions & 10 deletions packages/app-rfi/src/core/utils/submission-helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { deepCloner } from "../../../../../shared/utils";
import { KEY } from "./constants";
import { pushDataLayerEventToGa, setClientId } from "./google-analytics";
import { deepCloner } from "../../../../../shared/utils";

/**
* In order to make a field not required, we set the default or blank value
Expand Down Expand Up @@ -95,7 +95,12 @@ function submissionSetHiddenFields(payload, test) {
return output;
}

export const rfiSubmit = async (value, submissionUrl, test, callback = a => ({})) => {
export const rfiSubmit = async (
value,
submissionUrl,
test,
callback = a => ({})
) => {
// MARSHALL FIELDS FOR THE PAYLOAD

let payload = deepCloner(value);
Expand Down Expand Up @@ -130,14 +135,7 @@ export const rfiSubmit = async (value, submissionUrl, test, callback = a => ({})
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
}).then(async (response) => {
await new Promise(resolve => {
setTimeout(() => {
resolve(true);
}, 2000);
});
return response.json();
});
}).then(response => response.json());

// Race the fetch promise against the timeout promise
return Promise.race([fetchPromise, timeoutPromise]).then(response =>
Expand Down

0 comments on commit ad7bd44

Please sign in to comment.