diff --git a/lib/js/actions.js b/lib/js/actions.js index 8ac0a75..29a4b19 100644 --- a/lib/js/actions.js +++ b/lib/js/actions.js @@ -114,7 +114,7 @@ function submitToUrl(body, submitUrl, formConfig) { req.addEventListener('load', function () { if (req.status >= 200 && req.status < 300) { if (formConfig.clientTelemetry) { - formConfig.clientTelemetry("submission-successful", null, null, formConfig); + formConfig.clientTelemetry('submission-successful'); } // got this from the fetch polyfill, keeping it to be safe var responseBody = 'response' in req ? req.response : req.responseText; @@ -164,15 +164,15 @@ function submitToUrl(body, submitUrl, formConfig) { } function submitForm(formConfig, form) { - var telemetry = function telemetry(category, error, errorType) { + var telemetry = function telemetry(category, error) { if (formConfig.clientTelemetry) { - formConfig.clientTelemetry(category, error, errorType, formConfig); + formConfig.clientTelemetry(category, error); } }; return function (dispatch) { dispatch(setSubmission('status', 'submitPending')); - telemetry("submission", null, null); + telemetry('submission'); var promise = void 0; if (formConfig.submit) { @@ -180,7 +180,7 @@ function submitForm(formConfig, form) { } else { var body = formConfig.transformForSubmit ? formConfig.transformForSubmit(formConfig, form) : (0, _helpers.transformForSubmit)(formConfig, form); - promise = submitToUrl(body, formConfig.submitUrl, formConfig.trackingPrefix); + promise = submitToUrl(body, formConfig.submitUrl, formConfig); } return promise.then(function (resp) { @@ -189,14 +189,8 @@ function submitForm(formConfig, form) { // overly cautious var error = errorReceived instanceof Error ? errorReceived : new Error(errorReceived); var errorMessage = String(error.message); - var errorType = 'clientError'; - if (errorMessage.startsWith('vets_throttled_error')) { - errorType = 'throttledError'; - } else if (errorMessage.startsWith('vets_server_error')) { - errorType = 'serverError'; - } - telemetry("error", error, errorType); - dispatch(setSubmission('status', errorType, error.extra)); + telemetry('error', error); + dispatch(setSubmission('status', errorMessage, error.extra)); }); }; } @@ -262,7 +256,6 @@ function uploadFile(file, uiOptions, onProgress, onChange, onError) { name: file.name, errorMessage: errorMessage }); - Raven.captureMessage('vets_upload_error: ' + req.statusText); onError(); } }); @@ -273,11 +266,6 @@ function uploadFile(file, uiOptions, onProgress, onChange, onError) { name: file.name, errorMessage: errorMessage }); - Raven.captureMessage('vets_upload_error: ' + errorMessage, { - extra: { - statusText: req.statusText - } - }); onError(); }); diff --git a/lib/js/actions.js.map b/lib/js/actions.js.map index 62e3244..c7d7cd6 100644 --- a/lib/js/actions.js.map +++ b/lib/js/actions.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/js/actions.js"],"names":["closeReviewChapter","openReviewChapter","setData","setEditMode","setSubmission","setPrivacyAgreement","setSubmitted","setViewedPages","submitForm","uploadFile","SET_EDIT_MODE","SET_DATA","SET_VIEWED_PAGES","SET_PRIVACY_AGREEMENT","SET_SUBMISSION","SET_SUBMITTED","OPEN_REVIEW_CHAPTER","CLOSE_REVIEW_CHAPTER","closedChapter","pageKeys","type","openedChapter","data","page","edit","index","field","value","extra","privacyAgreementAccepted","response","submitToUrl","body","submitUrl","formConfig","Promise","resolve","reject","req","XMLHttpRequest","open","addEventListener","status","clientTelemetry","responseBody","responseText","results","JSON","parse","error","Error","statusText","parseInt","getResponseHeader","setRequestHeader","userToken","_","get","window","send","form","telemetry","category","errorType","dispatch","promise","submit","transformForSubmit","trackingPrefix","then","resp","catch","errorReceived","errorMessage","String","message","startsWith","file","uiOptions","onProgress","onChange","onError","getState","size","maxSize","name","minSize","fileTypes","some","toLowerCase","endsWith","fileType","uploading","payload","createPayload","formId","fileUploadUrl","fileData","parseResponse","moment","unix","Raven","captureMessage","upload","evt","lengthComputable","loaded","total"],"mappings":";;;;;;QAcgBA,kB,GAAAA,kB;QAQAC,iB,GAAAA,iB;QAOAC,O,GAAAA,O;QAOAC,W,GAAAA,W;QAWAC,a,GAAAA,a;QASAC,mB,GAAAA,mB;QAOAC,Y,GAAAA,Y;QAQAC,c,GAAAA,c;QA+DAC,U,GAAAA,U;QA0CAC,U,GAAAA,U;;AAhLhB;;;;AACA;;;;AACA;;AACA;;;;AAEO,IAAMC,wCAAgB,eAAtB;AACA,IAAMC,8BAAW,UAAjB;AAC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FO,SAAT;AAIA4B,cAAMC,cAAN,yBAA2ChE,IAAIa,UAA/C;AACA8B;AACD;AACF,KAlBD;;AAoBA3C,QAAIG,gBAAJ,CAAqB,OAArB,EAA8B,YAAM;AAClC,UAAMgC,eAAe,wBAArB;AACAO,eAAS;AACPK,cAAMR,KAAKQ,IADJ;AAEPZ;AAFO,OAAT;AAIA4B,YAAMC,cAAN,yBAA2C7B,YAA3C,EAA2D;AACzD7C,eAAO;AACLuB,sBAAYb,IAAIa;AADX;AADkD,OAA3D;AAKA8B;AACD,KAZD;;AAcA3C,QAAIiE,MAAJ,CAAW9D,gBAAX,CAA4B,UAA5B,EAAwC,UAAC+D,GAAD,EAAS;AAC/C,UAAIA,IAAIC,gBAAJ,IAAwB1B,UAA5B,EAAwC;AACtC;AACA;AACAA,mBAAYyB,IAAIE,MAAJ,GAAaF,IAAIG,KAAlB,GAA2B,EAAtC;AACD;AACF,KAND;;AAQArE,QAAIgB,gBAAJ,CAAqB,kBAArB,EAAyC,OAAzC;AACAhB,QAAIqB,IAAJ,CAASkC,OAAT;;AAEA,WAAOvD,GAAP;AACD,GAzFD;AA0FD","file":"actions.js","sourcesContent":["import moment from 'moment';\nimport _ from './utilities/data';\nimport { transformForSubmit } from './helpers';\nimport { timeFromNow } from './utilities/date';\n\nexport const SET_EDIT_MODE = 'SET_EDIT_MODE';\nexport const SET_DATA = 'SET_DATA';\nexport const SET_VIEWED_PAGES = 'SET_VIEWED_PAGES';\nexport const SET_PRIVACY_AGREEMENT = 'SET_PRIVACY_AGREEMENT';\nexport const SET_SUBMISSION = 'SET_SUBMISSION';\nexport const SET_SUBMITTED = 'SET_SUBMITTED';\nexport const OPEN_REVIEW_CHAPTER = 'OPEN_REVIEW_CHAPTER';\nexport const CLOSE_REVIEW_CHAPTER = 'CLOSE_REVIEW_CHAPTER';\n\nexport function closeReviewChapter(closedChapter, pageKeys = []) {\n return {\n type: CLOSE_REVIEW_CHAPTER,\n closedChapter,\n pageKeys\n };\n}\n\nexport function openReviewChapter(openedChapter) {\n return {\n type: OPEN_REVIEW_CHAPTER,\n openedChapter\n };\n}\n\nexport function setData(data) {\n return {\n type: SET_DATA,\n data\n };\n}\n\nexport function setEditMode(page, edit, index = null) {\n return {\n type: SET_EDIT_MODE,\n edit,\n page,\n index\n };\n}\n\n// extra is used to pass other information (from a submission error or anything else)\n// into the submission state object\nexport function setSubmission(field, value, extra = null) {\n return {\n type: SET_SUBMISSION,\n field,\n value,\n extra\n };\n}\n\nexport function setPrivacyAgreement(privacyAgreementAccepted) {\n return {\n type: SET_PRIVACY_AGREEMENT,\n privacyAgreementAccepted\n };\n}\n\nexport function setSubmitted(response) {\n return {\n type: SET_SUBMITTED,\n response: typeof response.data !== 'undefined' ? response.data : response\n };\n}\n\n\nexport function setViewedPages(pageKeys) {\n return {\n type: SET_VIEWED_PAGES,\n pageKeys\n };\n}\n\nfunction submitToUrl(body, submitUrl, formConfig) {\n return new Promise((resolve, reject) => {\n const req = new XMLHttpRequest();\n req.open('POST', submitUrl);\n req.addEventListener('load', () => {\n if (req.status >= 200 && req.status < 300) {\n if (formConfig.clientTelemetry) {\n formConfig.clientTelemetry(\"submission-successful\", null, null, formConfig);\n }\n // got this from the fetch polyfill, keeping it to be safe\n const responseBody = 'response' in req ? req.response : req.responseText;\n const results = JSON.parse(responseBody);\n resolve(results);\n } else {\n let error;\n if (req.status === 429) {\n error = new Error(`vets_throttled_error: ${req.statusText}`);\n error.extra = parseInt(req.getResponseHeader('x-ratelimit-reset'), 10);\n } else {\n error = new Error(`vets_server_error: ${req.statusText}`);\n }\n error.statusText = req.statusText;\n reject(error);\n }\n });\n\n req.addEventListener('error', () => {\n const error = new Error('vets_client_error: Network request failed');\n error.statusText = req.statusText;\n reject(error);\n });\n\n req.addEventListener('abort', () => {\n const error = new Error('vets_client_error: Request aborted');\n error.statusText = req.statusText;\n reject(error);\n });\n\n req.addEventListener('timeout', () => {\n const error = new Error('vets_client_error: Request timed out');\n error.statusText = req.statusText;\n reject(error);\n });\n\n req.setRequestHeader('X-Key-Inflection', 'camel');\n req.setRequestHeader('Content-Type', 'application/json');\n\n const userToken = _.get('sessionStorage.userToken', window);\n if (userToken) {\n req.setRequestHeader('Authorization', `Token token=${userToken}`);\n }\n\n req.send(body);\n });\n}\n\nexport function submitForm(formConfig, form) {\n const telemetry = (category, error, errorType) => {\n if (formConfig.clientTelemetry) {\n formConfig.clientTelemetry(\n category, error, errorType, formConfig\n )\n }\n };\n\n return dispatch => {\n dispatch(setSubmission('status', 'submitPending'));\n telemetry(\"submission\", null, null);\n\n let promise;\n if (formConfig.submit) {\n promise = formConfig.submit(form, formConfig);\n } else {\n const body = formConfig.transformForSubmit\n ? formConfig.transformForSubmit(formConfig, form)\n : transformForSubmit(formConfig, form);\n\n promise = submitToUrl(body, formConfig.submitUrl, formConfig.trackingPrefix);\n }\n\n return promise\n .then(resp => dispatch(setSubmitted(resp)))\n .catch(errorReceived => {\n // overly cautious\n const error = errorReceived instanceof Error ? errorReceived : new Error(errorReceived);\n const errorMessage = String(error.message);\n let errorType = 'clientError';\n if (errorMessage.startsWith('vets_throttled_error')) {\n errorType = 'throttledError';\n } else if (errorMessage.startsWith('vets_server_error')) {\n errorType = 'serverError';\n }\n telemetry(\"error\", error, errorType);\n dispatch(setSubmission('status', errorType, error.extra));\n });\n };\n}\n\nexport function uploadFile(file, uiOptions, onProgress, onChange, onError) {\n return (dispatch, getState) => {\n if (file.size > uiOptions.maxSize) {\n onChange({\n name: file.name,\n errorMessage: 'File is too large to be uploaded'\n });\n\n onError();\n return null;\n }\n\n if (file.size < uiOptions.minSize) {\n onChange({\n name: file.name,\n errorMessage: 'File is too small to be uploaded'\n });\n\n onError();\n return null;\n }\n\n // we limit file types, but it’s not respected on mobile and desktop\n // users can bypass it without much effort\n if (!uiOptions.fileTypes.some(fileType => file.name.toLowerCase().endsWith(fileType.toLowerCase()))) {\n onChange({\n name: file.name,\n errorMessage: 'File is not one of the allowed types'\n });\n\n onError();\n return null;\n }\n\n onChange({\n name: file.name,\n uploading: true\n });\n\n const payload = uiOptions.createPayload(file, getState().form.formId);\n\n const req = new XMLHttpRequest();\n\n req.open('POST', uiOptions.fileUploadUrl);\n req.addEventListener('load', () => {\n if (req.status >= 200 && req.status < 300) {\n const body = 'response' in req ? req.response : req.responseText;\n const fileData = uiOptions.parseResponse(JSON.parse(body), file);\n onChange(fileData);\n } else {\n let errorMessage = req.statusText;\n if (req.status === 429) {\n errorMessage = `You’ve reached the limit for the number of submissions we can accept at this time. Please try again in ${timeFromNow(moment.unix(parseInt(req.getResponseHeader('x-ratelimit-reset'), 10)))}.`;\n }\n\n onChange({\n name: file.name,\n errorMessage\n });\n Raven.captureMessage(`vets_upload_error: ${req.statusText}`);\n onError();\n }\n });\n\n req.addEventListener('error', () => {\n const errorMessage = 'Network request failed';\n onChange({\n name: file.name,\n errorMessage\n });\n Raven.captureMessage(`vets_upload_error: ${errorMessage}`, {\n extra: {\n statusText: req.statusText\n }\n });\n onError();\n });\n\n req.upload.addEventListener('progress', (evt) => {\n if (evt.lengthComputable && onProgress) {\n // setting this at 80, because there's some time after we get to 100%\n // where the backend is uploading to s3\n onProgress((evt.loaded / evt.total) * 80);\n }\n });\n\n req.setRequestHeader('X-Key-Inflection', 'camel');\n req.send(payload);\n\n return req;\n };\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../../src/js/actions.js"],"names":["closeReviewChapter","openReviewChapter","setData","setEditMode","setSubmission","setPrivacyAgreement","setSubmitted","setViewedPages","submitForm","uploadFile","SET_EDIT_MODE","SET_DATA","SET_VIEWED_PAGES","SET_PRIVACY_AGREEMENT","SET_SUBMISSION","SET_SUBMITTED","OPEN_REVIEW_CHAPTER","CLOSE_REVIEW_CHAPTER","closedChapter","pageKeys","type","openedChapter","data","page","edit","index","field","value","extra","privacyAgreementAccepted","response","submitToUrl","body","submitUrl","formConfig","Promise","resolve","reject","req","XMLHttpRequest","open","addEventListener","status","clientTelemetry","responseBody","responseText","results","JSON","parse","error","Error","statusText","parseInt","getResponseHeader","setRequestHeader","userToken","_","get","window","send","form","telemetry","category","dispatch","promise","submit","transformForSubmit","then","resp","catch","errorReceived","errorMessage","String","message","file","uiOptions","onProgress","onChange","onError","getState","size","maxSize","name","minSize","fileTypes","some","toLowerCase","endsWith","fileType","uploading","payload","createPayload","formId","fileUploadUrl","fileData","parseResponse","moment","unix","upload","evt","lengthComputable","loaded","total"],"mappings":";;;;;;QAcgBA,kB,GAAAA,kB;QAQAC,iB,GAAAA,iB;QAOAC,O,GAAAA,O;QAOAC,W,GAAAA,W;QAWAC,a,GAAAA,a;QASAC,mB,GAAAA,mB;QAOAC,Y,GAAAA,Y;QAQAC,c,GAAAA,c;QA+DAC,U,GAAAA,U;QAkCAC,U,GAAAA,U;;AAxKhB;;;;AACA;;;;AACA;;AACA;;;;AAEO,IAAMC,wCAAgB,eAAtB;AACA,IAAMC,8BAAW,UAAjB;AACA,IAAMC,8CAAmB,kBAAzB;AACA,IAAMC,wDAAwB,uBAA9B;AACA,IAAMC,0CAAiB,gBAAvB;AACA,IAAMC,wCAAgB,eAAtB;AACA,IAAMC,oDAAsB,qBAA5B;AACA,IAAMC,sDAAuB,sBAA7B;;AAEA,SAASjB,kBAAT,CAA4BkB,aAA5B,EAA0D;AAAA,MAAfC,QAAe,uEAAJ,EAAI;;AAC/D,SAAO;AACLC,UAAMH,oBADD;AAELC,gCAFK;AAGLC;AAHK,GAAP;AAKD;;AAEM,SAASlB,iBAAT,CAA2BoB,aAA3B,EAA0C;AAC/C,SAAO;AACLD,UAAMJ,mBADD;AAELK;AAFK,GAAP;AAID;;AAEM,SAASnB,OAAT,CAAiBoB,IAAjB,EAAuB;AAC5B,SAAO;AACLF,UAAMT,QADD;AAELW;AAFK,GAAP;AAID;;AAEM,SAASnB,WAAT,CAAqBoB,IAArB,EAA2BC,IAA3B,EAA+C;AAAA,MAAdC,KAAc,uEAAN,IAAM;;AACpD,SAAO;AACLL,UAAMV,aADD;AAELc,cAFK;AAGLD,cAHK;AAILE;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AII,MAAJ,KAAe,GAAnB,EAAwB;AACtB6B,0IAAyH,uBAAYyB,iBAAOC,IAAP,CAAY7C,SAASd,IAAIe,iBAAJ,CAAsB,mBAAtB,CAAT,EAAqD,EAArD,CAAZ,CAAZ,CAAzH;AACD;;AAEDwB,iBAAS;AACPK,gBAAMR,KAAKQ,IADJ;AAEPX;AAFO,SAAT;AAIAO;AACD;AACF,KAjBD;;AAmBAxC,QAAIG,gBAAJ,CAAqB,OAArB,EAA8B,YAAM;AAClC,UAAM8B,eAAe,wBAArB;AACAM,eAAS;AACPK,cAAMR,KAAKQ,IADJ;AAEPX;AAFO,OAAT;AAIAO;AACD,KAPD;;AASAxC,QAAI4D,MAAJ,CAAWzD,gBAAX,CAA4B,UAA5B,EAAwC,UAAC0D,GAAD,EAAS;AAC/C,UAAIA,IAAIC,gBAAJ,IAAwBxB,UAA5B,EAAwC;AACtC;AACA;AACAA,mBAAYuB,IAAIE,MAAJ,GAAaF,IAAIG,KAAlB,GAA2B,EAAtC;AACD;AACF,KAND;;AAQAhE,QAAIgB,gBAAJ,CAAqB,kBAArB,EAAyC,OAAzC;AACAhB,QAAIqB,IAAJ,CAAS+B,OAAT;;AAEA,WAAOpD,GAAP;AACD,GAnFD;AAoFD","file":"actions.js","sourcesContent":["import moment from 'moment';\nimport _ from './utilities/data';\nimport { transformForSubmit } from './helpers';\nimport { timeFromNow } from './utilities/date';\n\nexport const SET_EDIT_MODE = 'SET_EDIT_MODE';\nexport const SET_DATA = 'SET_DATA';\nexport const SET_VIEWED_PAGES = 'SET_VIEWED_PAGES';\nexport const SET_PRIVACY_AGREEMENT = 'SET_PRIVACY_AGREEMENT';\nexport const SET_SUBMISSION = 'SET_SUBMISSION';\nexport const SET_SUBMITTED = 'SET_SUBMITTED';\nexport const OPEN_REVIEW_CHAPTER = 'OPEN_REVIEW_CHAPTER';\nexport const CLOSE_REVIEW_CHAPTER = 'CLOSE_REVIEW_CHAPTER';\n\nexport function closeReviewChapter(closedChapter, pageKeys = []) {\n return {\n type: CLOSE_REVIEW_CHAPTER,\n closedChapter,\n pageKeys\n };\n}\n\nexport function openReviewChapter(openedChapter) {\n return {\n type: OPEN_REVIEW_CHAPTER,\n openedChapter\n };\n}\n\nexport function setData(data) {\n return {\n type: SET_DATA,\n data\n };\n}\n\nexport function setEditMode(page, edit, index = null) {\n return {\n type: SET_EDIT_MODE,\n edit,\n page,\n index\n };\n}\n\n// extra is used to pass other information (from a submission error or anything else)\n// into the submission state object\nexport function setSubmission(field, value, extra = null) {\n return {\n type: SET_SUBMISSION,\n field,\n value,\n extra\n };\n}\n\nexport function setPrivacyAgreement(privacyAgreementAccepted) {\n return {\n type: SET_PRIVACY_AGREEMENT,\n privacyAgreementAccepted\n };\n}\n\nexport function setSubmitted(response) {\n return {\n type: SET_SUBMITTED,\n response: typeof response.data !== 'undefined' ? response.data : response\n };\n}\n\n\nexport function setViewedPages(pageKeys) {\n return {\n type: SET_VIEWED_PAGES,\n pageKeys\n };\n}\n\nfunction submitToUrl(body, submitUrl, formConfig) {\n return new Promise((resolve, reject) => {\n const req = new XMLHttpRequest();\n req.open('POST', submitUrl);\n req.addEventListener('load', () => {\n if (req.status >= 200 && req.status < 300) {\n if (formConfig.clientTelemetry) {\n formConfig.clientTelemetry('submission-successful');\n }\n // got this from the fetch polyfill, keeping it to be safe\n const responseBody = 'response' in req ? req.response : req.responseText;\n const results = JSON.parse(responseBody);\n resolve(results);\n } else {\n let error;\n if (req.status === 429) {\n error = new Error(`vets_throttled_error: ${req.statusText}`);\n error.extra = parseInt(req.getResponseHeader('x-ratelimit-reset'), 10);\n } else {\n error = new Error(`vets_server_error: ${req.statusText}`);\n }\n error.statusText = req.statusText;\n reject(error);\n }\n });\n\n req.addEventListener('error', () => {\n const error = new Error('vets_client_error: Network request failed');\n error.statusText = req.statusText;\n reject(error);\n });\n\n req.addEventListener('abort', () => {\n const error = new Error('vets_client_error: Request aborted');\n error.statusText = req.statusText;\n reject(error);\n });\n\n req.addEventListener('timeout', () => {\n const error = new Error('vets_client_error: Request timed out');\n error.statusText = req.statusText;\n reject(error);\n });\n\n req.setRequestHeader('X-Key-Inflection', 'camel');\n req.setRequestHeader('Content-Type', 'application/json');\n\n const userToken = _.get('sessionStorage.userToken', window);\n if (userToken) {\n req.setRequestHeader('Authorization', `Token token=${userToken}`);\n }\n\n req.send(body);\n });\n}\n\nexport function submitForm(formConfig, form) {\n const telemetry = (category, error) => {\n if (formConfig.clientTelemetry) {\n formConfig.clientTelemetry(category, error);\n }\n };\n\n return dispatch => {\n dispatch(setSubmission('status', 'submitPending'));\n telemetry('submission');\n\n let promise;\n if (formConfig.submit) {\n promise = formConfig.submit(form, formConfig);\n } else {\n const body = formConfig.transformForSubmit\n ? formConfig.transformForSubmit(formConfig, form)\n : transformForSubmit(formConfig, form);\n\n promise = submitToUrl(body, formConfig.submitUrl, formConfig);\n }\n\n return promise\n .then(resp => dispatch(setSubmitted(resp)))\n .catch(errorReceived => {\n // overly cautious\n const error = errorReceived instanceof Error ? errorReceived : new Error(errorReceived);\n const errorMessage = String(error.message);\n telemetry('error', error);\n dispatch(setSubmission('status', errorMessage, error.extra));\n });\n };\n}\n\nexport function uploadFile(file, uiOptions, onProgress, onChange, onError) {\n return (dispatch, getState) => {\n if (file.size > uiOptions.maxSize) {\n onChange({\n name: file.name,\n errorMessage: 'File is too large to be uploaded'\n });\n\n onError();\n return null;\n }\n\n if (file.size < uiOptions.minSize) {\n onChange({\n name: file.name,\n errorMessage: 'File is too small to be uploaded'\n });\n\n onError();\n return null;\n }\n\n // we limit file types, but it’s not respected on mobile and desktop\n // users can bypass it without much effort\n if (!uiOptions.fileTypes.some(fileType => file.name.toLowerCase().endsWith(fileType.toLowerCase()))) {\n onChange({\n name: file.name,\n errorMessage: 'File is not one of the allowed types'\n });\n\n onError();\n return null;\n }\n\n onChange({\n name: file.name,\n uploading: true\n });\n\n const payload = uiOptions.createPayload(file, getState().form.formId);\n\n const req = new XMLHttpRequest();\n\n req.open('POST', uiOptions.fileUploadUrl);\n req.addEventListener('load', () => {\n if (req.status >= 200 && req.status < 300) {\n const body = 'response' in req ? req.response : req.responseText;\n const fileData = uiOptions.parseResponse(JSON.parse(body), file);\n onChange(fileData);\n } else {\n let errorMessage = req.statusText;\n if (req.status === 429) {\n errorMessage = `You’ve reached the limit for the number of submissions we can accept at this time. Please try again in ${timeFromNow(moment.unix(parseInt(req.getResponseHeader('x-ratelimit-reset'), 10)))}.`;\n }\n\n onChange({\n name: file.name,\n errorMessage\n });\n onError();\n }\n });\n\n req.addEventListener('error', () => {\n const errorMessage = 'Network request failed';\n onChange({\n name: file.name,\n errorMessage\n });\n onError();\n });\n\n req.upload.addEventListener('progress', (evt) => {\n if (evt.lengthComputable && onProgress) {\n // setting this at 80, because there's some time after we get to 100%\n // where the backend is uploading to s3\n onProgress((evt.loaded / evt.total) * 80);\n }\n });\n\n req.setRequestHeader('X-Key-Inflection', 'camel');\n req.send(payload);\n\n return req;\n };\n}\n"]} \ No newline at end of file diff --git a/lib/js/helpers.js.map b/lib/js/helpers.js.map new file mode 100644 index 0000000..e083297 --- /dev/null +++ b/lib/js/helpers.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/js/helpers.js"],"names":["isActivePage","getActivePages","getActiveProperties","getInactivePages","createFormPageList","createPageListByChapter","createPageList","createRoutes","formatISOPartialDate","formatReviewDate","parseISODate","filterViewFields","filterInactivePageData","stringifyFormReplacer","isInProgress","transformForSubmit","getArrayFields","hasFieldsOtherThanArray","getNonArraySchema","checkValidSchema","setArrayRecordTouched","createUSAStateLabels","expandArrayPages","getPageKeys","getActiveChapters","omitRequired","page","data","depends","index","Array","isArray","some","condition","undefined","pages","filter","activePages","allProperties","forEach","schema","push","Object","keys","properties","formConfig","chapters","reduce","pageList","chapter","chapterTitle","title","map","chapterKey","pageKey","concat","formPages","introduction","path","urlPrefix","routes","component","FormPage","pageConfig","ReviewPage","confirmation","onEnter","nextState","replace","formatDayMonth","val","dayOrMonth","toString","Number","length","formatYear","month","day","year","dateString","monthYear","split","newData","nextProp","field","newArray","item","startsWith","inactivePages","form","activeProperties","formData","currentData","prop","includes","key","value","country","street","city","postalCode","zipcode","fields","every","widget","id","confirmationCode","file","newValues","v","pathName","trimmedPathname","endsWith","replacer","withoutInactivePages","withoutViewFields","JSON","stringify","isHiddenField","findArrays","obj","ui","type","definitions","uiSchema","$ref","newProperties","current","next","newSchema","required","newRequired","pureWithDeepEquals","props","nextProps","errors","join","propName","items","additionalItems","Error","prefix","states","USA","label","generateArrayPages","arrayPages","arrayPath","itemFilter","result","acc","nextPage","lastArrayPath","currentList","showPagePerItem","newList","eligiblePageList","expandedPageList","p"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAUgBA,Y,GAAAA,Y;QAYAC,c,GAAAA,c;QAIAC,mB,GAAAA,mB;QAUAC,gB,GAAAA,gB;QAIAC,kB,GAAAA,kB;QAgBAC,uB,GAAAA,uB;QAcAC,c,GAAAA,c;QA6BAC,Y,GAAAA,Y;QA+DAC,oB,GAAAA,oB;QAQAC,gB,GAAAA,gB;QAWAC,Y,GAAAA,Y;QAqBAC,gB,GAAAA,gB;QAyBAC,sB,GAAAA,sB;QAgBAC,qB,GAAAA,qB;QAmCAC,Y,GAAAA,Y;QAaAC,kB,GAAAA,kB;QAiBAC,c,GAAAA,c;QA4BAC,uB,GAAAA,uB;QAmBAC,iB,GAAAA,iB;QAuDAC,gB,GAAAA,gB;QAkDAC,qB,GAAAA,qB;QAIAC,oB,GAAAA,oB;QAgCAC,gB,GAAAA,gB;QAqCAC,W,GAAAA,W;QAoBAC,iB,GAAAA,iB;QAeAC,Y,GAAAA,Y;;AAvjBhB;;;;AACA;;AAEA;;;;AACA;;;;;;;;;;AAEA;AACA;AACA;AACO,SAASzB,YAAT,CAAsB0B,IAAtB,EAA4BC,IAA5B,EAAkC;AACvC,MAAI,OAAOD,KAAKE,OAAZ,KAAwB,UAA5B,EAAwC;AACtC,WAAOF,KAAKE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mByC,UAAnB,CAAlB;AACA,MAAMG,WAAW1C,eAAeuC,UAAf,EAA2BW,SAA3B,CAAjB;AACA,MAAMoG,mBAAmB3J,eAAe+C,QAAf,EAAyB2C,QAAzB,CAAzB;AACA,MAAMkE,mBAAmBvI,iBAAiBsI,gBAAjB,EAAmCjE,QAAnC,CAAzB;;AAEA,SAAO,oBAAOkE,iBAAiBzG,GAAjB,CAAqB;AAAA,WAAK0G,EAAEzG,UAAP;AAAA,GAArB,EAAwCjB,MAAxC,CAA+C;AAAA,WAAO,CAAC,CAAC2D,GAAF,IAASA,QAAQ,QAAxB;AAAA,GAA/C,CAAP,CAAP;AACD;;AAED;;;;;;AAMO,SAAStE,YAAT,CAAsBe,MAAtB,EAA8B;AACnC,MAAI,QAAOA,MAAP,yCAAOA,MAAP,OAAkB,QAAlB,IAA8BV,MAAMC,OAAN,CAAcS,MAAd,CAAlC,EAAyD;AACvD,WAAOA,MAAP;AACD;;AAED,MAAMyF,YAAY,oBAAO,UAAP,EAAmBzF,MAAnB,CAAlB;AACAE,SAAOC,IAAP,CAAYsF,SAAZ,EAAuB1F,OAAvB,CAA+B,eAAO;AACpC0F,cAAUlC,GAAV,IAAiBtE,aAAawG,UAAUlC,GAAV,CAAb,CAAjB;AACD,GAFD;;AAIA,SAAOkC,SAAP;AACD","file":"helpers.js","sourcesContent":["import _ from 'lodash/fp';\nimport shouldUpdate from 'recompose/shouldUpdate';\nimport { deepEquals } from '@department-of-veterans-affairs/react-jsonschema-form/lib/utils';\n\nimport FormPage from './containers/FormPage';\nimport ReviewPage from './review/ReviewPage';\n\n// An active page is one that will be shown to the user.\n// Pages become inactive if they are conditionally shown based\n// on answers to previous questions.\nexport function isActivePage(page, data) {\n if (typeof page.depends === 'function') {\n return page.depends(data, page.index);\n }\n\n if (Array.isArray(page.depends)) {\n return page.depends.some(condition => _.matches(condition)(data));\n }\n\n return page.depends === undefined || _.matches(page.depends)(data);\n}\n\nexport function getActivePages(pages, data) {\n return pages.filter(page => isActivePage(page, data));\n}\n\nexport function getActiveProperties(activePages) {\n const allProperties = [];\n activePages.forEach(page => {\n if (page.schema) {\n allProperties.push(...Object.keys(page.schema.properties));\n }\n });\n return _.uniq(allProperties);\n}\n\nexport function getInactivePages(pages, data) {\n return pages.filter(page => !isActivePage(page, data));\n}\n\nexport function createFormPageList(formConfig) {\n return Object.keys(formConfig.chapters)\n .reduce((pageList, chapter) => {\n const chapterTitle = formConfig.chapters[chapter].title;\n const pages = Object.keys(formConfig.chapters[chapter].pages)\n .map(page => {\n return _.assign(formConfig.chapters[chapter].pages[page], {\n chapterTitle,\n chapterKey: chapter,\n pageKey: page\n });\n });\n return pageList.concat(pages);\n }, []);\n}\n\nexport function createPageListByChapter(formConfig) {\n return Object.keys(formConfig.chapters)\n .reduce((chapters, chapter) => {\n const pages = Object.keys(formConfig.chapters[chapter].pages)\n .map(page => {\n return _.assign(formConfig.chapters[chapter].pages[page], {\n pageKey: page,\n chapterKey: chapter\n });\n });\n return _.set(chapter, pages, chapters);\n }, {});\n}\n\nexport function createPageList(formConfig, formPages) {\n let pageList = formPages;\n if (formConfig.introduction) {\n pageList = [\n {\n pageKey: 'introduction',\n path: 'introduction'\n }\n ].concat(pageList);\n }\n\n return pageList\n .concat([\n {\n pageKey: 'review-and-submit',\n path: 'review-and-submit',\n chapterKey: 'review'\n }\n ])\n .map(page => {\n return _.set('path', `${formConfig.urlPrefix || ''}${page.path}`, page);\n });\n}\n\n/*\n * Create the routes based on a form config. This goes through each chapter in a form\n * config, pulls out the config for each page, then generates a list of Route components with the\n * config as props\n */\nexport function createRoutes(formConfig) {\n const formPages = createFormPageList(formConfig);\n const pageList = createPageList(formConfig, formPages);\n let routes = formPages\n .map(page => {\n return {\n path: page.path,\n component: page.component || FormPage,\n pageConfig: page,\n pageList,\n urlPrefix: formConfig.urlPrefix\n };\n });\n if (formConfig.introduction) {\n routes = [\n {\n path: 'introduction',\n component: formConfig.introduction,\n formConfig,\n pageList\n }\n ].concat(routes);\n }\n\n return routes.concat([\n {\n path: 'review-and-submit',\n formConfig,\n component: ReviewPage,\n pageList\n },\n {\n path: 'confirmation',\n component: formConfig.confirmation\n },\n {\n path: '*',\n onEnter: (nextState, replace) => replace(formConfig.urlPrefix || '/')\n }\n ]);\n}\n\nfunction formatDayMonth(val) {\n if (val) {\n const dayOrMonth = val.toString();\n if (Number(dayOrMonth) && dayOrMonth.length === 1) {\n return `0${val}`;\n } else if (Number(dayOrMonth)) {\n return dayOrMonth;\n }\n }\n\n return 'XX';\n}\n\nfunction formatYear(val) {\n if (!val || !val.length) {\n return 'XXXX';\n }\n\n return val;\n}\n\nexport function formatISOPartialDate({ month, day, year }) {\n if (month || day || year) {\n return `${formatYear(year)}-${formatDayMonth(month)}-${formatDayMonth(day)}`;\n }\n\n return undefined;\n}\n\nexport function formatReviewDate(dateString, monthYear = false) {\n if (dateString) {\n const [year, month, day] = dateString.split('-', 3);\n\n return monthYear\n ? `${formatDayMonth(month)}/${formatYear(year)}`\n : `${formatDayMonth(month)}/${formatDayMonth(day)}/${formatYear(year)}`;\n }\n\n return undefined;\n}\nexport function parseISODate(dateString) {\n if (typeof dateString === 'string') {\n const [year, month, day] = dateString.split('-', 3);\n\n return {\n month: month === 'XX' ? '' : Number(month).toString(),\n day: day === 'XX' ? '' : Number(day).toString(),\n year: year === 'XXXX' ? '' : year\n };\n }\n\n return {\n month: '',\n day: '',\n year: ''\n };\n}\n\n/*\n * Removes 'view:' fields from data object\n */\nexport function filterViewFields(data) {\n return Object.keys(data).reduce((newData, nextProp) => {\n const field = data[nextProp];\n\n if (Array.isArray(field)) {\n const newArray = field.map((item) => filterViewFields(item));\n\n return _.set(nextProp, newArray, newData);\n }\n\n if (typeof field === 'object') {\n if (nextProp.startsWith('view:')) {\n return _.assign(newData, filterViewFields(field));\n }\n return _.set(nextProp, filterViewFields(field), newData);\n }\n\n if (!nextProp.startsWith('view:')) {\n return _.set(nextProp, field, newData);\n }\n\n return newData;\n }, {});\n}\n\nexport function filterInactivePageData(inactivePages, activePages, form) {\n const activeProperties = getActiveProperties(activePages);\n let newData;\n\n return inactivePages.reduce((formData, page) => {\n return Object.keys(page.schema.properties)\n .reduce((currentData, prop) => {\n newData = currentData;\n if (!activeProperties.includes(prop)) {\n delete newData[prop];\n }\n return newData;\n }, formData);\n }, form.data);\n}\n\nexport function stringifyFormReplacer(key, value) {\n // an object with country is an address\n if (value && typeof value.country !== 'undefined' &&\n (!value.street || !value.city || (!value.postalCode && !value.zipcode))) {\n return undefined;\n }\n\n // clean up empty objects, which we have no reason to send\n if (typeof value === 'object') {\n const fields = Object.keys(value);\n if (fields.length === 0 || fields.every(field => value[field] === undefined)) {\n return undefined;\n }\n\n // autosuggest widgets save value and label info, but we should just return the value\n if (value.widget === 'autosuggest') {\n return value.id;\n }\n\n // Exclude file data\n if (value.confirmationCode && value.file) {\n return _.omit('file', value);\n }\n }\n\n // Clean up empty objects in arrays\n if (Array.isArray(value)) {\n const newValues = value.filter(v => !!stringifyFormReplacer(key, v));\n // If every item in the array is cleared, remove the whole array\n return newValues.length > 0 ? newValues : undefined;\n }\n\n return value;\n}\n\nexport function isInProgress(pathName) {\n const trimmedPathname = pathName.replace(/\\/$/, '');\n return !(\n trimmedPathname.endsWith('introduction')\n || trimmedPathname.endsWith('confirmation')\n || trimmedPathname.endsWith('form-saved')\n || trimmedPathname.endsWith('error')\n );\n}\n\n/*\n * Normal transform for schemaform data\n */\nexport function transformForSubmit(formConfig, form, replacer = stringifyFormReplacer) {\n const activePages = getActivePages(createFormPageList(formConfig), form.data);\n const inactivePages = getInactivePages(createFormPageList(formConfig), form.data);\n const withoutInactivePages = filterInactivePageData(inactivePages, activePages, form);\n const withoutViewFields = filterViewFields(withoutInactivePages);\n\n return JSON.stringify(withoutViewFields, replacer) || '{}';\n}\n\nfunction isHiddenField(schema) {\n return !!schema['ui:collapsed'] || !!schema['ui:hidden'];\n}\n\n/*\n * Pull the array fields from a schema. Used to separate out array fields\n * from the rest of page to be displayed on the review page\n */\nexport function getArrayFields(data) {\n const fields = [];\n const findArrays = (obj, ui, path = []) => {\n if (obj.type === 'array' && !isHiddenField(obj) && !_.get('ui:options.keepInPageOnReview', ui)) {\n fields.push({\n path,\n schema: _.set('definitions', data.schema.definitions, obj),\n uiSchema: _.get(path, data.uiSchema) || data.uiSchema\n });\n }\n\n if (obj.type === 'object' && !isHiddenField(obj)) {\n Object.keys(obj.properties).forEach(prop => {\n findArrays(obj.properties[prop], ui[prop], path.concat(prop));\n });\n }\n };\n\n findArrays(data.schema, data.uiSchema);\n\n return fields;\n}\n\n/*\n * Checks to see if there are non array fields in a page schema, so that\n * we don’t show a blank page header on the review page if a page is just\n * a growable table\n */\nexport function hasFieldsOtherThanArray(schema) {\n if (schema.$ref || (schema.type !== 'object' && schema.type !== 'array')) {\n return true;\n }\n\n if (schema.type === 'object') {\n return Object.keys(schema.properties).some(nextProp => {\n return hasFieldsOtherThanArray(schema.properties[nextProp]);\n });\n }\n\n return false;\n}\n\n/*\n * Return a schema without array fields. If the schema has only array fields,\n * then return undefined (because there’s no reason to use an object schema with\n * no properties)\n */\nexport function getNonArraySchema(schema, uiSchema = {}) {\n if (schema.type === 'array' && !_.get('ui:options.keepInPageOnReview', uiSchema)) {\n return undefined;\n }\n\n if (schema.type === 'object') {\n const newProperties = Object.keys(schema.properties).reduce((current, next) => {\n const newSchema = getNonArraySchema(schema.properties[next], uiSchema[next]);\n\n if (typeof newSchema === 'undefined') {\n return _.unset(next, current);\n }\n\n if (newSchema !== schema.properties[next]) {\n return _.set(next, newSchema, current);\n }\n\n return current;\n }, schema.properties);\n\n if (Object.keys(newProperties).length === 0) {\n return undefined;\n }\n\n if (newProperties !== schema.properties) {\n let newSchema = _.set('properties', newProperties, schema);\n if (newSchema.required) {\n const newRequired = _.intersection(Object.keys(newSchema.properties), newSchema.required);\n if (newRequired.length !== newSchema.required.length) {\n newSchema = _.set('required', newRequired, newSchema);\n }\n }\n\n return newSchema;\n }\n }\n\n return schema;\n}\n\n\nexport const pureWithDeepEquals = shouldUpdate((props, nextProps) => {\n return !deepEquals(props, nextProps);\n});\n\n/**\n * Recursively checks to see if the schema is valid.\n *\n * Note: This only returns true. If the schema is invalid, an error is thrown to\n * stop everything.\n *\n * @param {Object} schema - The schema in question\n * @return {bool} - true if we succeed\n * @throws {Error} - If the schema is invalid\n */\nexport function checkValidSchema(schema, errors = [], path = ['root']) {\n if (typeof schema.type !== 'string') {\n errors.push(`Missing type in ${path.join('.')} schema.`);\n }\n\n if (schema.type === 'object') {\n if (typeof schema.properties !== 'object') {\n errors.push(`Missing object properties in ${path.join('.')} schema.`);\n } else {\n Object.keys(schema.properties).forEach((propName) => {\n checkValidSchema(schema.properties[propName], errors, [...path, propName]);\n });\n }\n }\n\n if (schema.type === 'array') {\n // We check this both before items is turned into additionalItems and after,\n // so we need to account for it being both an object and an array.\n if (Array.isArray(schema.items)) {\n if (!schema.additionalItems) {\n errors.push(`${path.join('.')} should contain additionalItems when items is an array.`);\n }\n schema.items.forEach((item, index) => {\n checkValidSchema(item, errors, [...path, 'items', index]);\n });\n } else if (typeof schema.items === 'object') {\n if (schema.additionalItems) {\n errors.push(`${path.join('.')} should not contain additionalItems when items is an object.`);\n }\n checkValidSchema(schema.items, errors, [...path, 'items']);\n } else {\n errors.push(`Missing items schema in ${path.join('.')}.`);\n }\n\n // Check additionalItems\n if (schema.additionalItems) {\n checkValidSchema(schema.additionalItems, errors, [...path, 'additionalItems']);\n }\n }\n\n // We’ve recursed all the way back down to ['root']; throw an error containing\n // all the error messages.\n if (path.length === 1 && errors.length > 0) {\n // console.log(`Error${errors.length > 1 ? 's' : ''} found in schema: ${errors.join(' ')} -- ${path.join('.')}`);\n throw new Error(`Error${errors.length > 1 ? 's' : ''} found in schema: ${errors.join(' ')}`);\n } else {\n return true;\n }\n}\n\nexport function setArrayRecordTouched(prefix, index) {\n return { [`${prefix}_${index}`]: true };\n}\n\nexport function createUSAStateLabels(states) {\n return states.USA.reduce((current, { label, value }) => {\n return _.merge(current, { [value]: label });\n }, {});\n}\n\n/*\n * Take a list of pages and create versions of them\n * for each item in an array\n */\nfunction generateArrayPages(arrayPages, data) {\n const items = _.get(arrayPages[0].arrayPath, data) || [];\n return items\n .reduce((pages, item, index) =>\n pages.concat(arrayPages.map(page =>\n _.assign(page, {\n path: page.path.replace(':index', index),\n index\n })\n )),\n []\n )\n // doing this after the map so that we don’t change indexes\n .filter(page => !page.itemFilter || page.itemFilter(items[page.index]));\n}\n\n/*\n * We want to generate the pages we need for each item in the array\n * being used by an array page. We also want to group those pages by item.\n * So, this grabs contiguous sections of array pages and at the end generates\n * the right number of pages based on the items in the array\n */\nexport function expandArrayPages(pageList, data) {\n const result = pageList.reduce((acc, nextPage) => {\n const { lastArrayPath, arrayPages, currentList } = acc;\n // If we see an array page and we’re starting a section or in the middle of one, just add it\n // to the temporary array\n if (nextPage.showPagePerItem && (!lastArrayPath || nextPage.arrayPath === lastArrayPath)) {\n arrayPages.push(nextPage);\n return acc;\n // Now we’ve hit the end of a section of array pages using the same array, so\n // actually generate the pages now\n } else if (nextPage.arrayPath !== lastArrayPath && !!arrayPages.length) {\n const newList = currentList.concat(generateArrayPages(arrayPages, data), nextPage);\n return _.assign(acc, {\n lastArrayPath: null,\n arrayPages: [],\n currentList: newList\n });\n }\n\n return _.set('currentList', currentList.concat(nextPage), acc);\n }, { lastArrayPath: null, arrayPages: [], currentList: [] });\n\n if (result.arrayPages.length > 0) {\n return result.currentList.concat(generateArrayPages(result.arrayPages, data));\n }\n\n return result.currentList;\n}\n\n/**\n * getPageKeys returns a list of keys for the currently active pages\n *\n * @param pages {Array} List of page configs\n * @param formData {Object} Current form data\n * @returns {Array} A list of page keys from the page config\n * and the index if it’s a pagePerItem page\n */\nexport function getPageKeys(pages, formData) {\n const eligiblePageList = getActivePages(pages, formData);\n const expandedPageList = expandArrayPages(eligiblePageList, formData);\n\n return expandedPageList.map(page => {\n let pageKey = page.pageKey;\n if (typeof page.index !== 'undefined') {\n pageKey += page.index;\n }\n return pageKey;\n });\n}\n\n/**\n * getActiveChapters returns the list of chapter keys with active pages\n *\n * @param formConfig {Object} The form config object\n * @param formData {Object} The current form data\n * @returns {Array} The list of chapter key strings for active chapters\n */\nexport function getActiveChapters(formConfig, formData) {\n const formPages = createFormPageList(formConfig);\n const pageList = createPageList(formConfig, formPages);\n const eligiblePageList = getActivePages(pageList, formData);\n const expandedPageList = expandArrayPages(eligiblePageList, formData);\n\n return _.uniq(expandedPageList.map(p => p.chapterKey).filter(key => !!key && key !== 'review'));\n}\n\n/**\n * Returns the schema, omitting all `required` arrays.\n *\n * @param schema {Object}\n * @returns {Object} The schema without any `required` arrays\n */\nexport function omitRequired(schema) {\n if (typeof schema !== 'object' || Array.isArray(schema)) {\n return schema;\n }\n\n const newSchema = _.omit('required', schema);\n Object.keys(newSchema).forEach(key => {\n newSchema[key] = omitRequired(newSchema[key]);\n });\n\n return newSchema;\n}\n"]} \ No newline at end of file diff --git a/lib/js/review/SubmitController.js b/lib/js/review/SubmitController.js index fa6789a..860a729 100644 --- a/lib/js/review/SubmitController.js +++ b/lib/js/review/SubmitController.js @@ -71,8 +71,7 @@ var SubmitController = function (_React$Component) { form = _this$props2.form, formConfig = _this$props2.formConfig, pagesByChapter = _this$props2.pagesByChapter, - privacyAgreementAccepted = _this$props2.privacyAgreementAccepted, - trackingPrefix = _this$props2.trackingPrefix; + privacyAgreementAccepted = _this$props2.privacyAgreementAccepted; var _isValidForm = (0, _validation.isValidForm)(form, pagesByChapter), isValid = _isValidForm.isValid, @@ -85,7 +84,7 @@ var SubmitController = function (_React$Component) { // like to know if they’re common if (privacyAgreementAccepted) { if (formConfig.clientTelemetry) { - formConfig.clientTelemetry("validation-failed", null, null, formConfig); + formConfig.clientTelemetry('validation-failed', errors); } _this.props.setSubmission('status', 'validationError'); } diff --git a/lib/js/review/SubmitController.js.map b/lib/js/review/SubmitController.js.map index 7559be2..47d7793 100644 --- a/lib/js/review/SubmitController.js.map +++ b/lib/js/review/SubmitController.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/js/review/SubmitController.jsx"],"names":["SubmitController","goBack","props","form","pageList","router","eligiblePageList","data","expandedPageList","push","length","path","handleSubmit","formConfig","pagesByChapter","privacyAgreementAccepted","trackingPrefix","isValid","errors","submitForm","clientTelemetry","setSubmission","nextProps","nextStatus","submission","status","previousStatus","newRoute","urlPrefix","renderErrorMessage","showPrivacyAgreementError","setPrivacyAgreement","React","Component","mapStateToProps","state","ownProps","hasAttemptedSubmit","mapDispatchToProps","propTypes","PropTypes","object","isRequired","array","bool","func","string"],"mappings":";;;;;;;;;AAAA;;;;AACA;;;;AACA;;AACA;;AAEA;;;;AACA;;;;AACA;;AACA;;AAKA;;;;;;;;;;IAMMA,gB;;;;;;;;;;;;;;0MAWJC,M,GAAS,YAAM;AAAA,wBAKT,MAAKC,KALI;AAAA,UAEXC,IAFW,eAEXA,IAFW;AAAA,UAGXC,QAHW,eAGXA,QAHW;AAAA,UAIXC,MAJW,eAIXA,MAJW;;;AAOb,UAAMC,mBAAmB,6BAAeF,QAAf,EAAyBD,KAAKI,IAA9B,CAAzB;AACA,UAAMC,mBAAmB,+BAAiBF,gBAAjB,EAAmC,MAAKJ,KAAL,CAAWC,IAAX,CAAgBI,IAAnD,CAAzB;;AAEAF,aAAOI,IAAP,CAAYD,iBAAiBA,iBAAiBE,MAAjB,GAA0B,CAA3C,EAA8CC,IAA1D;AACD,K,QAEDC,Y,GAAe,YAAM;AAAA,yBAOf,MAAKV,KAPU;AAAA,UAEjBC,IAFiB,gBAEjBA,IAFiB;AAAA,UAGjBU,UAHiB,gBAGjBA,UAHiB;AAAA,UAIjBC,cAJiB,gBAIjBA,cAJiB;AAAA,UAKjBC,wBALiB,gBAKjBA,wBALiB;AAAA,UAMjBC,cANiB,gBAMjBA,cANiB;;AAAA,yBAYf,6BAAYb,IAAZ,EAAkBW,cAAlB,CAZe;AAAA,UAUjBG,OAViB,gBAUjBA,OAViB;AAAA,UAWjBC,MAXiB,gBAWjBA,MAXiB;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,iBAAemB,oBAAUK,IAAV,CAAeH,UATH;AAU3BvB,cAAYqB,oBAAUK,IAAV,CAAeH,UAVA;AAW3BlB,cAAYgB,oBAAUC,MAAV,CAAiBC,UAXF;AAY3B1B,kBAAgBwB,oBAAUM,MAAV,CAAiBJ;AAZN,CAA7B;;kBAee,6BAAW,yBAAQR,eAAR,EAAyBI,kBAAzB,EAA6CtC,gBAA7C,CAAX,C;;AAEf;;QACSA,gB,GAAAA,gB","file":"SubmitController.js","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { connect } from 'react-redux';\nimport { withRouter } from 'react-router';\n\nimport SubmitButtons from './SubmitButtons';\nimport PrivacyAgreement from '../components/PrivacyAgreement';\nimport { isValidForm } from '../validation';\nimport {\n createPageListByChapter,\n expandArrayPages,\n getActivePages,\n} from '../helpers';\nimport {\n setPrivacyAgreement,\n setSubmission,\n submitForm\n} from '../actions';\n\nclass SubmitController extends React.Component {\n\n componentWillReceiveProps(nextProps) {\n const nextStatus = nextProps.form.submission.status;\n const previousStatus = this.props.form.submission.status;\n if (nextStatus !== previousStatus && nextStatus === 'applicationSubmitted') {\n const newRoute = `${nextProps.formConfig.urlPrefix}confirmation`;\n this.props.router.push(newRoute);\n }\n }\n\n goBack = () => {\n const {\n form,\n pageList,\n router\n } = this.props;\n\n const eligiblePageList = getActivePages(pageList, form.data);\n const expandedPageList = expandArrayPages(eligiblePageList, this.props.form.data);\n\n router.push(expandedPageList[expandedPageList.length - 2].path);\n }\n\n handleSubmit = () => {\n const {\n form,\n formConfig,\n pagesByChapter,\n privacyAgreementAccepted,\n trackingPrefix\n } = this.props;\n\n const {\n isValid,\n errors\n } = isValidForm(form, pagesByChapter);\n\n if (isValid) {\n this.props.submitForm(formConfig, form);\n } else {\n // validation errors in this situation are not visible, so we’d\n // like to know if they’re common\n if (privacyAgreementAccepted) {\n if (formConfig.clientTelemetry) {\n formConfig.clientTelemetry(\"validation-failed\", null, null, formConfig);\n }\n this.props.setSubmission('status', 'validationError');\n }\n this.props.setSubmission('hasAttemptedSubmit', true);\n }\n }\n\n render() {\n const {\n privacyAgreementAccepted,\n renderErrorMessage,\n showPrivacyAgreementError,\n submission\n } = this.props;\n return (\n
\n

Note: According to federal law, there are criminal penalties, including a fine and/or imprisonment for up to 5 years, for withholding information or for providing incorrect information. (See 18 U.S.C. 1001)

\n \n \n
\n );\n }\n}\n\nfunction mapStateToProps(state, ownProps) {\n const {\n formConfig,\n pageList,\n renderErrorMessage\n } = ownProps;\n const router = ownProps.router;\n\n const form = state.form;\n const pagesByChapter = createPageListByChapter(formConfig);\n const trackingPrefix = formConfig.trackingPrefix;\n const submission = form.submission;\n const showPrivacyAgreementError = submission.hasAttemptedSubmit;\n const privacyAgreementAccepted = form.data.privacyAgreementAccepted;\n\n return {\n form,\n formConfig,\n pagesByChapter,\n pageList,\n privacyAgreementAccepted,\n renderErrorMessage,\n router,\n submission,\n showPrivacyAgreementError,\n trackingPrefix\n };\n}\n\nconst mapDispatchToProps = {\n setPrivacyAgreement,\n setSubmission,\n submitForm\n};\n\nSubmitController.propTypes = {\n form: PropTypes.object.isRequired,\n formConfig: PropTypes.object.isRequired,\n pagesByChapter: PropTypes.object.isRequired,\n pageList: PropTypes.array.isRequired,\n privacyAgreementAccepted: PropTypes.bool.isRequired,\n renderErrorMessage: PropTypes.func,\n router: PropTypes.object.isRequired,\n setPrivacyAgreement: PropTypes.func.isRequired,\n setSubmission: PropTypes.func.isRequired,\n submitForm: PropTypes.func.isRequired,\n submission: PropTypes.object.isRequired,\n trackingPrefix: PropTypes.string.isRequired\n};\n\nexport default withRouter(connect(mapStateToProps, mapDispatchToProps)(SubmitController));\n\n// for tests\nexport { SubmitController };\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/js/review/SubmitController.jsx"],"names":["SubmitController","goBack","props","form","pageList","router","eligiblePageList","data","expandedPageList","push","length","path","handleSubmit","formConfig","pagesByChapter","privacyAgreementAccepted","isValid","errors","submitForm","clientTelemetry","setSubmission","nextProps","nextStatus","submission","status","previousStatus","newRoute","urlPrefix","renderErrorMessage","showPrivacyAgreementError","setPrivacyAgreement","React","Component","mapStateToProps","state","ownProps","trackingPrefix","hasAttemptedSubmit","mapDispatchToProps","propTypes","PropTypes","object","isRequired","array","bool","func","string"],"mappings":";;;;;;;;;AAAA;;;;AACA;;;;AACA;;AACA;;AAEA;;;;AACA;;;;AACA;;AACA;;AAKA;;;;;;;;;;IAMMA,gB;;;;;;;;;;;;;;0MAWJC,M,GAAS,YAAM;AAAA,wBAKT,MAAKC,KALI;AAAA,UAEXC,IAFW,eAEXA,IAFW;AAAA,UAGXC,QAHW,eAGXA,QAHW;AAAA,UAIXC,MAJW,eAIXA,MAJW;;;AAOb,UAAMC,mBAAmB,6BAAeF,QAAf,EAAyBD,KAAKI,IAA9B,CAAzB;AACA,UAAMC,mBAAmB,+BAAiBF,gBAAjB,EAAmC,MAAKJ,KAAL,CAAWC,IAAX,CAAgBI,IAAnD,CAAzB;;AAEAF,aAAOI,IAAP,CAAYD,iBAAiBA,iBAAiBE,MAAjB,GAA0B,CAA3C,EAA8CC,IAA1D;AACD,K,QAEDC,Y,GAAe,YAAM;AAAA,yBAMf,MAAKV,KANU;AAAA,UAEjBC,IAFiB,gBAEjBA,IAFiB;AAAA,UAGjBU,UAHiB,gBAGjBA,UAHiB;AAAA,UAIjBC,cAJiB,gBAIjBA,cAJiB;AAAA,UAKjBC,wBALiB,gBAKjBA,wBALiB;;AAAA,yBAWf,6BAAYZ,IAAZ,EAAkBW,cAAlB,CAXe;AAAA,UASjBE,OATiB,gBASjBA,OATiB;AAAA,UAUjBC,MAViB,gBAUjBA,MAViB;;AAanB,UAAID,OAAJ,EAAa;AACX,cAAKd,KAAL,CAAWgB,UAAX,CAAsBL,UAAtB,EAAkCV,IAAlC;AACD,OAFD,MAEO;AACL;AACA;AACA,YAAIY,wBAAJ,EAA8B;AAC5B,cAAIF,WAAWM,eAAf,EAAgC;AAC9BN,uBAAWM,eAAX,CAA2B,mBAA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AA7C,CAAX,C;;AAEf;;QACSA,gB,GAAAA,gB","file":"SubmitController.js","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { connect } from 'react-redux';\nimport { withRouter } from 'react-router';\n\nimport SubmitButtons from './SubmitButtons';\nimport PrivacyAgreement from '../components/PrivacyAgreement';\nimport { isValidForm } from '../validation';\nimport {\n createPageListByChapter,\n expandArrayPages,\n getActivePages\n} from '../helpers';\nimport {\n setPrivacyAgreement,\n setSubmission,\n submitForm\n} from '../actions';\n\nclass SubmitController extends React.Component {\n\n componentWillReceiveProps(nextProps) {\n const nextStatus = nextProps.form.submission.status;\n const previousStatus = this.props.form.submission.status;\n if (nextStatus !== previousStatus && nextStatus === 'applicationSubmitted') {\n const newRoute = `${nextProps.formConfig.urlPrefix}confirmation`;\n this.props.router.push(newRoute);\n }\n }\n\n goBack = () => {\n const {\n form,\n pageList,\n router\n } = this.props;\n\n const eligiblePageList = getActivePages(pageList, form.data);\n const expandedPageList = expandArrayPages(eligiblePageList, this.props.form.data);\n\n router.push(expandedPageList[expandedPageList.length - 2].path);\n }\n\n handleSubmit = () => {\n const {\n form,\n formConfig,\n pagesByChapter,\n privacyAgreementAccepted\n } = this.props;\n\n const {\n isValid,\n errors\n } = isValidForm(form, pagesByChapter);\n\n if (isValid) {\n this.props.submitForm(formConfig, form);\n } else {\n // validation errors in this situation are not visible, so we’d\n // like to know if they’re common\n if (privacyAgreementAccepted) {\n if (formConfig.clientTelemetry) {\n formConfig.clientTelemetry('validation-failed', errors);\n }\n this.props.setSubmission('status', 'validationError');\n }\n this.props.setSubmission('hasAttemptedSubmit', true);\n }\n }\n\n render() {\n const {\n privacyAgreementAccepted,\n renderErrorMessage,\n showPrivacyAgreementError,\n submission\n } = this.props;\n return (\n
\n

Note: According to federal law, there are criminal penalties, including a fine and/or imprisonment for up to 5 years, for withholding information or for providing incorrect information. (See 18 U.S.C. 1001)

\n \n \n
\n );\n }\n}\n\nfunction mapStateToProps(state, ownProps) {\n const {\n formConfig,\n pageList,\n renderErrorMessage\n } = ownProps;\n const router = ownProps.router;\n\n const form = state.form;\n const pagesByChapter = createPageListByChapter(formConfig);\n const trackingPrefix = formConfig.trackingPrefix;\n const submission = form.submission;\n const showPrivacyAgreementError = submission.hasAttemptedSubmit;\n const privacyAgreementAccepted = form.data.privacyAgreementAccepted;\n\n return {\n form,\n formConfig,\n pagesByChapter,\n pageList,\n privacyAgreementAccepted,\n renderErrorMessage,\n router,\n submission,\n showPrivacyAgreementError,\n trackingPrefix\n };\n}\n\nconst mapDispatchToProps = {\n setPrivacyAgreement,\n setSubmission,\n submitForm\n};\n\nSubmitController.propTypes = {\n form: PropTypes.object.isRequired,\n formConfig: PropTypes.object.isRequired,\n pagesByChapter: PropTypes.object.isRequired,\n pageList: PropTypes.array.isRequired,\n privacyAgreementAccepted: PropTypes.bool.isRequired,\n renderErrorMessage: PropTypes.func,\n router: PropTypes.object.isRequired,\n setPrivacyAgreement: PropTypes.func.isRequired,\n setSubmission: PropTypes.func.isRequired,\n submitForm: PropTypes.func.isRequired,\n submission: PropTypes.object.isRequired,\n trackingPrefix: PropTypes.string.isRequired\n};\n\nexport default withRouter(connect(mapStateToProps, mapDispatchToProps)(SubmitController));\n\n// for tests\nexport { SubmitController };\n"]} \ No newline at end of file