From 9cabe84b26d5a0b2f5e29460d743e3cd50c7f924 Mon Sep 17 00:00:00 2001 From: timwis Date: Sun, 9 Sep 2018 19:02:53 -0400 Subject: [PATCH] Build --- lib/js/actions.js | 7 +--- lib/js/actions.js.map | 2 +- lib/js/review/SubmitButtons.js | 6 +-- lib/js/review/SubmitButtons.js.map | 2 +- lib/js/utilities/date/index.js | 29 ++++---------- lib/js/utilities/date/index.js.map | 2 +- lib/js/utilities/validations/index.js | 48 ++++++++++++----------- lib/js/utilities/validations/index.js.map | 2 +- 8 files changed, 40 insertions(+), 58 deletions(-) diff --git a/lib/js/actions.js b/lib/js/actions.js index a3dc902..0f5aa79 100644 --- a/lib/js/actions.js +++ b/lib/js/actions.js @@ -15,10 +15,6 @@ exports.setViewedPages = setViewedPages; exports.submitForm = submitForm; exports.uploadFile = uploadFile; -var _moment = require('moment'); - -var _moment2 = _interopRequireDefault(_moment); - var _data = require('./utilities/data'); var _data2 = _interopRequireDefault(_data); @@ -251,7 +247,8 @@ function uploadFile(file, uiOptions, onProgress, onChange, onError) { } else { var errorMessage = req.statusText; if (req.status === 429) { - errorMessage = 'You\u2019ve reached the limit for the number of submissions we can accept at this time. Please try again in ' + (0, _date.timeFromNow)(_moment2.default.unix(parseInt(req.getResponseHeader('x-ratelimit-reset'), 10))) + '.'; + var resetDate = new Date(req.getResponseHeader('x-ratelimit-reset') * 1000); + errorMessage = 'You\u2019ve reached the limit for the number of submissions we can accept at this time. Please try again in ' + (0, _date.timeFromNow)(resetDate) + '.'; } onChange({ diff --git a/lib/js/actions.js.map b/lib/js/actions.js.map index d269517..26eddea 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","setPreSubmit","setSubmitted","setViewedPages","submitForm","uploadFile","SET_EDIT_MODE","SET_DATA","SET_VIEWED_PAGES","SET_PRE_SUBMIT","SET_SUBMISSION","SET_SUBMITTED","OPEN_REVIEW_CHAPTER","CLOSE_REVIEW_CHAPTER","closedChapter","pageKeys","type","openedChapter","data","page","edit","index","field","value","extra","preSubmitField","preSubmitAccepted","response","submitToUrl","body","submitUrl","recordEvent","Promise","resolve","reject","req","XMLHttpRequest","open","addEventListener","status","event","responseBody","responseText","results","JSON","parse","error","Error","statusText","parseInt","getResponseHeader","setRequestHeader","userToken","_","get","window","send","formConfig","form","console","log","bind","dispatch","promise","submit","transformForSubmit","then","resp","catch","errorReceived","errorMessage","String","message","errorType","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","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,Y,GAAAA,Y;QAQAC,Y,GAAAA,Y;QAQAC,c,GAAAA,c;QA8DAC,U,GAAAA,U;QAsCAC,U,GAAAA,U;;AA5KhB;;;;AACA;;;;AACA;;AACA;;;;AAEO,IAAMC,wCAAgB,eAAtB;AACA,IAAMC,8BAAW,UAAjB;AACA,IAAMC,8CAAmB,kBAAzB;AACA,IAAMC,0CAAiB,gBAAvB;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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GAAP;AACD,GA3FD;AA4FD","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_PRE_SUBMIT = 'SET_PRE_SUBMIT';\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 setPreSubmit(preSubmitField, preSubmitAccepted) {\n return {\n type: SET_PRE_SUBMIT,\n preSubmitField,\n preSubmitAccepted\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, recordEvent) {\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 recordEvent({ event: 'form-submit-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 recordEvent = formConfig.recordEvent ?\n formConfig.recordEvent :\n console.log.bind(console); // eslint-disable-line no-console\n\n return dispatch => {\n dispatch(setSubmission('status', 'submitPending'));\n recordEvent({ event: 'form-submit-pending' });\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, recordEvent);\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 recordEvent({ event: 'form-submit-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 // Commenting until this is removed by a PR for #211\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 // Commenting until this is removed by a PR for #211\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","setPreSubmit","setSubmitted","setViewedPages","submitForm","uploadFile","SET_EDIT_MODE","SET_DATA","SET_VIEWED_PAGES","SET_PRE_SUBMIT","SET_SUBMISSION","SET_SUBMITTED","OPEN_REVIEW_CHAPTER","CLOSE_REVIEW_CHAPTER","closedChapter","pageKeys","type","openedChapter","data","page","edit","index","field","value","extra","preSubmitField","preSubmitAccepted","response","submitToUrl","body","submitUrl","recordEvent","Promise","resolve","reject","req","XMLHttpRequest","open","addEventListener","status","event","responseBody","responseText","results","JSON","parse","error","Error","statusText","parseInt","getResponseHeader","setRequestHeader","userToken","_","get","window","send","formConfig","form","console","log","bind","dispatch","promise","submit","transformForSubmit","then","resp","catch","errorReceived","errorMessage","String","message","errorType","startsWith","file","uiOptions","onProgress","onChange","onError","getState","size","maxSize","name","minSize","fileTypes","some","toLowerCase","endsWith","fileType","uploading","payload","createPayload","formId","fileUploadUrl","fileData","parseResponse","resetDate","Date","upload","evt","lengthComputable","loaded","total"],"mappings":";;;;;;QAagBA,kB,GAAAA,kB;QAQAC,iB,GAAAA,iB;QAOAC,O,GAAAA,O;QAOAC,W,GAAAA,W;QAWAC,a,GAAAA,a;QASAC,Y,GAAAA,Y;QAQAC,Y,GAAAA,Y;QAQAC,c,GAAAA,c;QA8DAC,U,GAAAA,U;QAsCAC,U,GAAAA,U;;AA3KhB;;;;AACA;;AACA;;;;AAEO,IAAMC,wCAAgB,eAAtB;AACA,IAAMC,8BAAW,UAAjB;AACA,IAAMC,8CAAmB,kBAAzB;AACA,IAAMC,0CAAiB,gBAAvB;AACA,IAAMC,0CAAiB,gBAAvB;AACA,IAAMC,wCAAgB,eAAtB;AACA,IAA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QAAIgE,MAAJ,CAAW7D,gBAAX,CAA4B,UAA5B,EAAwC,UAAC8D,GAAD,EAAS;AAC/C,UAAIA,IAAIC,gBAAJ,IAAwBxB,UAA5B,EAAwC;AACtC;AACA;AACAA,mBAAYuB,IAAIE,MAAJ,GAAaF,IAAIG,KAAlB,GAA2B,EAAtC;AACD;AACF,KAND;;AAQApE,QAAIgB,gBAAJ,CAAqB,kBAArB,EAAyC,OAAzC;AACAhB,QAAIqB,IAAJ,CAASmC,OAAT;;AAEA,WAAOxD,GAAP;AACD,GA5FD;AA6FD","file":"actions.js","sourcesContent":["import _ 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_PRE_SUBMIT = 'SET_PRE_SUBMIT';\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 setPreSubmit(preSubmitField, preSubmitAccepted) {\n return {\n type: SET_PRE_SUBMIT,\n preSubmitField,\n preSubmitAccepted\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, recordEvent) {\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 recordEvent({ event: 'form-submit-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 recordEvent = formConfig.recordEvent ?\n formConfig.recordEvent :\n console.log.bind(console); // eslint-disable-line no-console\n\n return dispatch => {\n dispatch(setSubmission('status', 'submitPending'));\n recordEvent({ event: 'form-submit-pending' });\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, recordEvent);\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 recordEvent({ event: 'form-submit-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 const resetDate = new Date(req.getResponseHeader('x-ratelimit-reset') * 1000);\n errorMessage = `You’ve reached the limit for the number of submissions we can accept at this time. Please try again in ${timeFromNow(resetDate)}.`;\n }\n\n onChange({\n name: file.name,\n errorMessage\n });\n // Commenting until this is removed by a PR for #211\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 // Commenting until this is removed by a PR for #211\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 diff --git a/lib/js/review/SubmitButtons.js b/lib/js/review/SubmitButtons.js index ec8ca7e..d8ad9a9 100644 --- a/lib/js/review/SubmitButtons.js +++ b/lib/js/review/SubmitButtons.js @@ -9,10 +9,6 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); -var _moment = require('moment'); - -var _moment2 = _interopRequireDefault(_moment); - var _ProgressButton = require('../components/ProgressButton'); var _ProgressButton2 = _interopRequireDefault(_ProgressButton); @@ -98,7 +94,7 @@ function SubmitButtons(props) { 'p', null, 'We\u2019re sorry. Your submission didn\u2019t go through because we received too many requests from you. Please wait ', - (0, _date.timeFromNow)(_moment2.default.unix(submission.extra)), + (0, _date.timeFromNow)(new Date(submission.extra * 1000)), ' and submit your request again.' ) ) diff --git a/lib/js/review/SubmitButtons.js.map b/lib/js/review/SubmitButtons.js.map index fcf2884..6acc547 100644 --- a/lib/js/review/SubmitButtons.js.map +++ b/lib/js/review/SubmitButtons.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/js/review/SubmitButtons.jsx"],"names":["SubmitButtons","props","onBack","onSubmit","submission","renderErrorMessage","submitButton","submitMessage","status","moment","unix","extra","process","env","NODE_ENV"],"mappings":";;;;;kBAKwBA,a;;AALxB;;;;AACA;;;;AACA;;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AAf;AACE;AAAA;AAAA,YAAK,WAAU,4BAAf;AACGI;AADH;AADF,OADF;AAME;AAAA;AAAA,UAAK,WAAU,mDAAf;AACE;AAAA;AAAA,YAAK,WAAU,6CAAf;AACE;AAAA;AAAA,cAAG,MAAK,GAAR;AACE;AAAA;AAAA,gBAAQ,WAAU,oBAAlB;AAAA;AAAA;AADF;AADF,SADF;AAMGD;AANH;AANF,KADF;AAiBD;AACD,SACE;AAAA;AAAA;AACE;AAAA;AAAA,QAAK,WAAU,2BAAf;AACE;AAAA;AAAA,UAAK,WAAU,0BAAf;AACE,sCAAC,wBAAD;AACE,yBAAeJ,MADjB;AAEE,sBAAW,MAFb;AAGE,uBAAY,sBAHd;AAIE,sBAAW,MAJb;AADF,OADF;AAQE;AAAA;AAAA,UAAK,WAAU,0BAAf;AACGI;AADH,OARF;AAWE;AAAA;AAAA,UAAK,WAAU,8BAAf;AACE;AAAA;AAAA,YAAK,WAAU,QAAf;AAAA;AAAA;AADF;AAXF,KADF;AAgBE;AAAA;AAAA,QAAK,WAAU,KAAf;AACE;AAAA;AAAA,UAAK,WAAU,SAAf;AACGC;AADH;AADF;AAhBF,GADF;AAwBD","file":"SubmitButtons.js","sourcesContent":["import React from 'react';\nimport moment from 'moment';\nimport ProgressButton from '../components/ProgressButton';\nimport { timeFromNow } from '../utilities/date';\n\nexport default function SubmitButtons(props) {\n const {\n onBack,\n onSubmit,\n submission,\n renderErrorMessage\n } = props;\n let submitButton;\n let submitMessage;\n if (submission.status === false) {\n submitButton = (\n \n );\n } else if (submission.status === 'submitPending') {\n submitButton = (\n \n );\n } else if (submission.status === 'applicationSubmitted') {\n submitButton = (\n \n );\n } else if (submission.status === 'clientError') {\n submitButton = (\n \n );\n submitMessage = (\n
\n
\n

We’re sorry, there was an error connecting to Vets.gov.

\n

Please check your Internet connection and try again. If the problem persists, please contact the Vets.gov Help Desk.

\n
\n
\n );\n } else if (submission.status === 'throttledError') {\n submitButton = (\n \n );\n submitMessage = (\n
\n
\n

We’ve run into a problem

\n

We’re sorry. Your submission didn’t go through because we received too many requests from you. Please wait {timeFromNow(moment.unix(submission.extra))} and submit your request again.

\n
\n
\n );\n } else if (submission.status === 'validationError') {\n submitButton = (\n \n );\n submitMessage = (\n
\n
\n

We’re sorry. Some information in your application is missing or not valid.

\n

Please check each section of your application to make sure you’ve filled out all the information that is required.

\n
\n
\n );\n } else {\n if (renderErrorMessage) {\n submitMessage = renderErrorMessage();\n } else {\n submitMessage = (\n
\n
\n

We’re sorry, the application didn’t go through.

\n

You’ll have to start over. We suggest you wait 1 day while we fix this problem.

\n
\n
\n );\n }\n\n if (process.env.NODE_ENV !== 'production') {\n submitButton = (\n \n );\n }\n\n return (\n
\n
\n
\n {submitMessage}\n
\n
\n
\n \n {submitButton}\n
\n
\n );\n }\n return (\n
\n
\n
\n \n
\n
\n {submitButton}\n
\n
\n
 
\n
\n
\n
\n
\n {submitMessage}\n
\n
\n
\n );\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/js/review/SubmitButtons.jsx"],"names":["SubmitButtons","props","onBack","onSubmit","submission","renderErrorMessage","submitButton","submitMessage","status","Date","extra","process","env","NODE_ENV"],"mappings":";;;;;kBAIwBA,a;;AAJxB;;;;AACA;;;;AACA;;;;AAEe,SAASA,aAAT,CAAuBC,KAAvB,EAA8B;AAAA,MAEzCC,MAFyC,GAMvCD,KANuC,CAEzCC,MAFyC;AAAA,MAGzCC,QAHyC,GAMvCF,KANuC,CAGzCE,QAHyC;AAAA,MAIzCC,UAJyC,GAMvCH,KANuC,CAIzCG,UAJyC;AAAA,MAKzCC,kBALyC,GAMvCJ,KANuC,CAKzCI,kBALyC;;AAO3C,MAAIC,qBAAJ;AACA,MAAIC,sBAAJ;AACA,MAAIH,WAAWI,MAAX,KAAsB,KAA1B,EAAiC;AAC/BF,mBACE,8BAAC,wBAAD;AACE,qBAAeH,QADjB;AAEE,kBAAW,oBAFb;AAGE,mBAAY,oBAHd,GADF;AAMD,GAPD,MAOO,IAAI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F,OADF;AAQE;AAAA;AAAA,UAAK,WAAU,0BAAf;AACGI;AADH,OARF;AAWE;AAAA;AAAA,UAAK,WAAU,8BAAf;AACE;AAAA;AAAA,YAAK,WAAU,QAAf;AAAA;AAAA;AADF;AAXF,KADF;AAgBE;AAAA;AAAA,QAAK,WAAU,KAAf;AACE;AAAA;AAAA,UAAK,WAAU,SAAf;AACGC;AADH;AADF;AAhBF,GADF;AAwBD","file":"SubmitButtons.js","sourcesContent":["import React from 'react';\nimport ProgressButton from '../components/ProgressButton';\nimport { timeFromNow } from '../utilities/date';\n\nexport default function SubmitButtons(props) {\n const {\n onBack,\n onSubmit,\n submission,\n renderErrorMessage\n } = props;\n let submitButton;\n let submitMessage;\n if (submission.status === false) {\n submitButton = (\n \n );\n } else if (submission.status === 'submitPending') {\n submitButton = (\n \n );\n } else if (submission.status === 'applicationSubmitted') {\n submitButton = (\n \n );\n } else if (submission.status === 'clientError') {\n submitButton = (\n \n );\n submitMessage = (\n
\n
\n

We’re sorry, there was an error connecting to Vets.gov.

\n

Please check your Internet connection and try again. If the problem persists, please contact the Vets.gov Help Desk.

\n
\n
\n );\n } else if (submission.status === 'throttledError') {\n submitButton = (\n \n );\n submitMessage = (\n
\n
\n

We’ve run into a problem

\n

We’re sorry. Your submission didn’t go through because we received too many requests from you. Please wait {timeFromNow(new Date(submission.extra * 1000))} and submit your request again.

\n
\n
\n );\n } else if (submission.status === 'validationError') {\n submitButton = (\n \n );\n submitMessage = (\n
\n
\n

We’re sorry. Some information in your application is missing or not valid.

\n

Please check each section of your application to make sure you’ve filled out all the information that is required.

\n
\n
\n );\n } else {\n if (renderErrorMessage) {\n submitMessage = renderErrorMessage();\n } else {\n submitMessage = (\n
\n
\n

We’re sorry, the application didn’t go through.

\n

You’ll have to start over. We suggest you wait 1 day while we fix this problem.

\n
\n
\n );\n }\n\n if (process.env.NODE_ENV !== 'production') {\n submitButton = (\n \n );\n }\n\n return (\n
\n
\n
\n {submitMessage}\n
\n
\n
\n \n {submitButton}\n
\n
\n );\n }\n return (\n
\n
\n
\n \n
\n
\n {submitButton}\n
\n
\n
 
\n
\n
\n
\n
\n {submitMessage}\n
\n
\n
\n );\n}\n"]} \ No newline at end of file diff --git a/lib/js/utilities/date/index.js b/lib/js/utilities/date/index.js index af76ffd..c7cae05 100644 --- a/lib/js/utilities/date/index.js +++ b/lib/js/utilities/date/index.js @@ -4,14 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.days = exports.months = undefined; -exports.dateToMoment = dateToMoment; exports.timeFromNow = timeFromNow; -var _moment = require('moment'); - -var _moment2 = _interopRequireDefault(_moment); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var _dateFns = require('date-fns'); var months = exports.months = [{ label: 'Jan', value: 1 }, { label: 'Feb', value: 2 }, { label: 'Mar', value: 3 }, { label: 'Apr', value: 4 }, { label: 'May', value: 5 }, { label: 'Jun', value: 6 }, { label: 'Jul', value: 7 }, { label: 'Aug', value: 8 }, { label: 'Sep', value: 9 }, { label: 'Oct', value: 10 }, { label: 'Nov', value: 11 }, { label: 'Dec', value: 12 }]; @@ -38,21 +33,13 @@ function formatDiff(diff, desc) { return diff + ' ' + desc + (diff === 1 ? '' : 's'); } -function dateToMoment(dateField) { - return (0, _moment2.default)({ - year: dateField.year.value, - month: dateField.month.value ? parseInt(dateField.month.value, 10) - 1 : '', - day: dateField.day ? dateField.day.value : null - }); -} - /** * timeFromNow returns the number of days, hours, or minutes until * the provided date occurs. It’s meant to be less fuzzy than moment’s * timeFromNow so it can be used for expiration dates * - * @param date {Moment Date} The future date to check against - * @param userFromDate {Moment Date} The earlier date in the range. Defaults to today. + * @param date {Date} The future date to check against + * @param userFromDate {Date} The earlier date in the range. Defaults to today. * @returns {string} The string description of how long until date occurs */ function timeFromNow(date) { @@ -60,26 +47,26 @@ function timeFromNow(date) { // Not using defaulting because we want today to be when this function // is called, not when the file is parsed and run - var fromDate = userFromDate || (0, _moment2.default)(); - var dayDiff = date.diff(fromDate, 'days'); + var fromDate = userFromDate || new Date(); + var dayDiff = (0, _dateFns.differenceInDays)(date, fromDate); if (dayDiff >= 1) { return formatDiff(dayDiff, 'day'); } - var hourDiff = date.diff(fromDate, 'hours'); + var hourDiff = (0, _dateFns.differenceInHours)(date, fromDate); if (hourDiff >= 1) { return formatDiff(hourDiff, 'hour'); } - var minuteDiff = date.diff(fromDate, 'minutes'); + var minuteDiff = (0, _dateFns.differenceInMinutes)(fromDate); if (minuteDiff >= 1) { return formatDiff(minuteDiff, 'minute'); } - var secondDiff = date.diff(fromDate, 'seconds'); + var secondDiff = (0, _dateFns.differenceInSeconds)(fromDate); if (secondDiff >= 1) { return formatDiff(secondDiff, 'second'); diff --git a/lib/js/utilities/date/index.js.map b/lib/js/utilities/date/index.js.map index 87fae0b..b39d992 100644 --- a/lib/js/utilities/date/index.js.map +++ b/lib/js/utilities/date/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../../src/js/utilities/date/index.js"],"names":["dateToMoment","timeFromNow","months","label","value","twentyNineDays","thirtyDays","thirtyOneDays","days","formatDiff","diff","desc","dateField","year","month","parseInt","day","date","userFromDate","fromDate","dayDiff","hourDiff","minuteDiff","secondDiff"],"mappings":";;;;;;QAwCgBA,Y,GAAAA,Y;QAiBAC,W,GAAAA,W;;AAzDhB;;;;;;AAEO,IAAMC,0BAAS,CACpB,EAAEC,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EADoB,EAEpB,EAAED,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EAFoB,EAGpB,EAAED,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EAHoB,EAIpB,EAAED,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EAJoB,EAKpB,EAAED,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EALoB,EAMpB,EAAED,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EANoB,EAOpB,EAAED,OAAO,KAAT,EAAgBC,OAAO,CAAvB,EAPoB,EAQpB,EAAED,O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,gBAAgB,uBAAjC;AACA,MAAME,UAAUH,KAAKP,IAAL,CAAUS,QAAV,EAAoB,MAApB,CAAhB;;AAEA,MAAIC,WAAW,CAAf,EAAkB;AAChB,WAAOX,WAAWW,OAAX,EAAoB,KAApB,CAAP;AACD;;AAED,MAAMC,WAAWJ,KAAKP,IAAL,CAAUS,QAAV,EAAoB,OAApB,CAAjB;;AAEA,MAAIE,YAAY,CAAhB,EAAmB;AACjB,WAAOZ,WAAWY,QAAX,EAAqB,MAArB,CAAP;AACD;;AAED,MAAMC,aAAaL,KAAKP,IAAL,CAAUS,QAAV,EAAoB,SAApB,CAAnB;;AAEA,MAAIG,cAAc,CAAlB,EAAqB;AACnB,WAAOb,WAAWa,UAAX,EAAuB,QAAvB,CAAP;AACD;;AAED,MAAMC,aAAaN,KAAKP,IAAL,CAAUS,QAAV,EAAoB,SAApB,CAAnB;;AAEA,MAAII,cAAc,CAAlB,EAAqB;AACnB,WAAOd,WAAWc,UAAX,EAAuB,QAAvB,CAAP;AACD;;AAED,SAAO,UAAP;AACD","file":"index.js","sourcesContent":["import moment from 'moment';\n\nexport const months = [\n { label: 'Jan', value: 1 },\n { label: 'Feb', value: 2 },\n { label: 'Mar', value: 3 },\n { label: 'Apr', value: 4 },\n { label: 'May', value: 5 },\n { label: 'Jun', value: 6 },\n { label: 'Jul', value: 7 },\n { label: 'Aug', value: 8 },\n { label: 'Sep', value: 9 },\n { label: 'Oct', value: 10 },\n { label: 'Nov', value: 11 },\n { label: 'Dec', value: 12 }\n];\n\nconst twentyNineDays = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29'];\nconst thirtyDays = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'];\nconst thirtyOneDays = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'];\n\nexport const days = {\n 1: thirtyOneDays,\n 2: twentyNineDays,\n 3: thirtyOneDays,\n 4: thirtyDays,\n 5: thirtyOneDays,\n 6: thirtyDays,\n 7: thirtyOneDays,\n 8: thirtyOneDays,\n 9: thirtyDays,\n 10: thirtyOneDays,\n 11: thirtyDays,\n 12: thirtyOneDays\n};\n\nfunction formatDiff(diff, desc) {\n return `${diff} ${desc}${diff === 1 ? '' : 's'}`;\n}\n\nexport function dateToMoment(dateField) {\n return moment({\n year: dateField.year.value,\n month: dateField.month.value ? parseInt(dateField.month.value, 10) - 1 : '',\n day: dateField.day ? dateField.day.value : null\n });\n}\n\n/**\n * timeFromNow returns the number of days, hours, or minutes until\n * the provided date occurs. It’s meant to be less fuzzy than moment’s\n * timeFromNow so it can be used for expiration dates\n *\n * @param date {Moment Date} The future date to check against\n * @param userFromDate {Moment Date} The earlier date in the range. Defaults to today.\n * @returns {string} The string description of how long until date occurs\n */\nexport function timeFromNow(date, userFromDate = null) {\n // Not using defaulting because we want today to be when this function\n // is called, not when the file is parsed and run\n const fromDate = userFromDate || moment();\n const dayDiff = date.diff(fromDate, 'days');\n\n if (dayDiff >= 1) {\n return formatDiff(dayDiff, 'day');\n }\n\n const hourDiff = date.diff(fromDate, 'hours');\n\n if (hourDiff >= 1) {\n return formatDiff(hourDiff, 'hour');\n }\n\n const minuteDiff = date.diff(fromDate, 'minutes');\n\n if (minuteDiff >= 1) {\n return formatDiff(minuteDiff, 'minute');\n }\n\n const secondDiff = date.diff(fromDate, 'seconds');\n\n if (secondDiff >= 1) {\n return formatDiff(secondDiff, 'second');\n }\n\n return 'a moment';\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../../../../src/js/utilities/date/index.js"],"names":["timeFromNow","months","label","value","twentyNineDays","thirtyDays","thirtyOneDays","days","formatDiff","diff","desc","date","userFromDate","fromDate","Date","dayD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AT,GAAa,EAAb,GAAkB,GAA3C;AACD;;AAED;;;;;;;;;AASO,SAAST,WAAT,CAAqBW,IAArB,EAAgD;AAAA,MAArBC,YAAqB,uEAAN,IAAM;;AACrD;AACA;AACA,MAAMC,WAAWD,gBAAgB,IAAIE,IAAJ,EAAjC;AACA,MAAMC,UAAU,+BAAiBJ,IAAjB,EAAuBE,QAAvB,CAAhB;;AAEA,MAAIE,WAAW,CAAf,EAAkB;AAChB,WAAOP,WAAWO,OAAX,EAAoB,KAApB,CAAP;AACD;;AAED,MAAMC,WAAW,gCAAkBL,IAAlB,EAAwBE,QAAxB,CAAjB;;AAEA,MAAIG,YAAY,CAAhB,EAAmB;AACjB,WAAOR,WAAWQ,QAAX,EAAqB,MAArB,CAAP;AACD;;AAED,MAAMC,aAAa,kCAAoBJ,QAApB,CAAnB;;AAEA,MAAII,cAAc,CAAlB,EAAqB;AACnB,WAAOT,WAAWS,UAAX,EAAuB,QAAvB,CAAP;AACD;;AAED,MAAMC,aAAa,kCAAoBL,QAApB,CAAnB;;AAEA,MAAIK,cAAc,CAAlB,EAAqB;AACnB,WAAOV,WAAWU,UAAX,EAAuB,QAAvB,CAAP;AACD;;AAED,SAAO,UAAP;AACD","file":"index.js","sourcesContent":["import {\n differenceInDays,\n differenceInHours,\n differenceInMinutes,\n differenceInSeconds\n} from 'date-fns';\n\nexport const months = [\n { label: 'Jan', value: 1 },\n { label: 'Feb', value: 2 },\n { label: 'Mar', value: 3 },\n { label: 'Apr', value: 4 },\n { label: 'May', value: 5 },\n { label: 'Jun', value: 6 },\n { label: 'Jul', value: 7 },\n { label: 'Aug', value: 8 },\n { label: 'Sep', value: 9 },\n { label: 'Oct', value: 10 },\n { label: 'Nov', value: 11 },\n { label: 'Dec', value: 12 }\n];\n\nconst twentyNineDays = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29'];\nconst thirtyDays = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30'];\nconst thirtyOneDays = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'];\n\nexport const days = {\n 1: thirtyOneDays,\n 2: twentyNineDays,\n 3: thirtyOneDays,\n 4: thirtyDays,\n 5: thirtyOneDays,\n 6: thirtyDays,\n 7: thirtyOneDays,\n 8: thirtyOneDays,\n 9: thirtyDays,\n 10: thirtyOneDays,\n 11: thirtyDays,\n 12: thirtyOneDays\n};\n\nfunction formatDiff(diff, desc) {\n return `${diff} ${desc}${diff === 1 ? '' : 's'}`;\n}\n\n/**\n * timeFromNow returns the number of days, hours, or minutes until\n * the provided date occurs. It’s meant to be less fuzzy than moment’s\n * timeFromNow so it can be used for expiration dates\n *\n * @param date {Date} The future date to check against\n * @param userFromDate {Date} The earlier date in the range. Defaults to today.\n * @returns {string} The string description of how long until date occurs\n */\nexport function timeFromNow(date, userFromDate = null) {\n // Not using defaulting because we want today to be when this function\n // is called, not when the file is parsed and run\n const fromDate = userFromDate || new Date();\n const dayDiff = differenceInDays(date, fromDate);\n\n if (dayDiff >= 1) {\n return formatDiff(dayDiff, 'day');\n }\n\n const hourDiff = differenceInHours(date, fromDate);\n\n if (hourDiff >= 1) {\n return formatDiff(hourDiff, 'hour');\n }\n\n const minuteDiff = differenceInMinutes(fromDate);\n\n if (minuteDiff >= 1) {\n return formatDiff(minuteDiff, 'minute');\n }\n\n const secondDiff = differenceInSeconds(fromDate);\n\n if (secondDiff >= 1) {\n return formatDiff(secondDiff, 'second');\n }\n\n return 'a moment';\n}\n"]} \ No newline at end of file diff --git a/lib/js/utilities/validations/index.js b/lib/js/utilities/validations/index.js index e2b475c..46e9718 100644 --- a/lib/js/utilities/validations/index.js +++ b/lib/js/utilities/validations/index.js @@ -16,15 +16,13 @@ exports.isValidPartialDate = isValidPartialDate; exports.isValidCurrentOrPastDate = isValidCurrentOrPastDate; exports.isValidCurrentOrPastYear = isValidCurrentOrPastYear; exports.isValidCurrentOrFutureMonthYear = isValidCurrentOrFutureMonthYear; -exports.dateToMoment = dateToMoment; +exports.parseDateField = parseDateField; exports.isValidDateRange = isValidDateRange; exports.isValidRoutingNumber = isValidRoutingNumber; exports.isValidPartialMonthYear = isValidPartialMonthYear; exports.isValidPartialMonthYearInPast = isValidPartialMonthYearInPast; -var _moment = require('moment'); - -var _moment2 = _interopRequireDefault(_moment); +var _dateFns = require('date-fns'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -60,7 +58,7 @@ function isValidSSN(value) { } function isValidYear(value) { - return Number(value) >= 1900 && Number(value) <= (0, _moment2.default)().add(100, 'year').year(); + return Number(value) >= 1900 && Number(value) <= (0, _dateFns.getYear)((0, _dateFns.addYears)(new Date(), 100)); } function isValidPartialDate(day, month, year) { @@ -72,17 +70,20 @@ function isValidPartialDate(day, month, year) { } function isValidCurrentOrPastDate(day, month, year) { - var momentDate = (0, _moment2.default)({ day: day, month: parseInt(month, 10) - 1, year: year }); - return momentDate.isSameOrBefore((0, _moment2.default)().endOf('day'), 'day'); + var date = new Date(year, month - 1, day); + var today = new Date(); + return (0, _dateFns.isSameDay)(date, today) || (0, _dateFns.isBefore)(date, today); } function isValidCurrentOrPastYear(value) { - return Number(value) >= 1900 && Number(value) < (0, _moment2.default)().year() + 1; + var currentYear = (0, _dateFns.getYear)(new Date()); + return Number(value) >= 1900 && Number(value) <= currentYear; } function isValidCurrentOrFutureMonthYear(month, year) { - var momentDate = (0, _moment2.default)({ month: parseInt(month, 10) - 1, year: year }); - return momentDate.isSameOrAfter((0, _moment2.default)(), 'month'); + var date = new Date(year, month - 1); + var today = new Date(); + return (0, _dateFns.isSameMonth)(date, today) || (0, _dateFns.isAfter)(date, today); } function isBlank(value) { @@ -93,21 +94,20 @@ function isBlankDateField(field) { return isBlank(field.day.value) && isBlank(field.month.value) && isBlank(field.year.value); } -function dateToMoment(dateField) { - return (0, _moment2.default)({ - year: dateField.year.value, - month: dateField.month.value ? parseInt(dateField.month.value, 10) - 1 : '', - day: dateField.day ? dateField.day.value : null - }); +function parseDateField(dateField) { + var year = dateField.year.value; + var month = dateField.month.value || null; + var day = dateField.day.value || null; + return new Date(year, month - 1, day); } -function isValidDateRange(fromDate, toDate) { - if (isBlankDateField(toDate) || isBlankDateField(fromDate)) { +function isValidDateRange(fromDateField, toDateField) { + if (isBlankDateField(toDateField) || isBlankDateField(fromDateField)) { return true; } - var momentStart = dateToMoment(fromDate); - var momentEnd = dateToMoment(toDate); - return momentStart.isSameOrBefore(momentEnd); + var fromDate = parseDateField(fromDateField); + var toDate = parseDateField(toDateField); + return fromDate <= toDate; } // Pulled from https://en.wikipedia.org/wiki/Routing_transit_number#Check_digit @@ -138,7 +138,9 @@ function isValidPartialMonthYearInPast(month, year) { if ((typeof month === 'undefined' ? 'undefined' : _typeof(month)) === 'object') { throw new Error('Pass a month and a year to function'); } - var momentDate = (0, _moment2.default)({ year: year, month: month ? parseInt(month, 10) - 1 : null }); - return !year || isValidPartialMonthYear(month, year) && momentDate.isValid() && momentDate.isSameOrBefore((0, _moment2.default)().startOf('month')); + var date = new Date(year, month, null); + var today = new Date(); + var isSameOrBefore = (0, _dateFns.isSameMonth)(date, today) || (0, _dateFns.isBefore)(date, today); + return !year || isValidPartialMonthYear(month, year) && isSameOrBefore; } //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/js/utilities/validations/index.js.map b/lib/js/utilities/validations/index.js.map index 00602fe..7055d69 100644 --- a/lib/js/utilities/validations/index.js.map +++ b/lib/js/utilities/validations/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../../src/js/utilities/validations/index.js"],"names":["isValidSSN","isValidYear","isValidPartialDate","isValidCurrentOrPastDate","isValidCurrentOrPastYear","isValidCurrentOrFutureMonthYear","dateToMoment","isValidDateRange","isValidRoutingNumber","isValidPartialMonthYear","isValidPartialMonthYearInPast","value","test","noBadSameDigitNumber","every","sameDigitRegex","RegExp","i","Number","add","year","day","month","momentDate","parseInt","isSameOrBefore","endOf","isSameOrAfter","isBlank","isBlankDateField","field","dateField","fromDate","toDate","momentStart","momentEnd","digits","split","map","val","weighted","Error","isValid","startOf"],"mappings":";;;;;;;;;;;;QAUgBA,U,GAAAA,U;QAwBAC,W,GAAAA,W;QAIAC,kB,GAAAA,kB;QAQAC,wB,GAAAA,wB;QAKAC,wB,GAAAA,wB;QAIAC,+B,GAAAA,+B;QAaAC,Y,GAAAA,Y;QAQAC,gB,GAAAA,gB;QAUAC,oB,GAAAA,oB;QAaAC,uB,GAAAA,uB;QAWAC,6B,GAAAA,6B;;AA7GhB;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASV,UAAT,CAAoBW,KAApB,EAA2B;AAChC,MAAIA,UAAU,WAAV,IAAyBA,UAAU,aAAvC,EAAsD;AACpD,WAAO,KAAP;AACD,GAFD,MAEO,IAAI,uBAAuBC,IAAvB,CAA4BD,KAA5B,CAAJ,EAAwC;AAC7C,WAAO,KAAP;AACD,GAFM,MAEA,IAAI,uBAAuBC,IAAvB,CAA4BD,KAA5B,CAAJ,EAAwC;AAC7C,WAAO,KAAP;AACD,GAFM,MAEA,IAAI,uBAAuBC,IAAvB,CAA4BD,KAA5B,CAAJ,EAAwC;AAC7C,WAAO,KAAP;AACD;;AAED,MAAME,uBAAuB,qBAAQ,CAAR,EAAW,EAAX,EAC1BC,KAD0B,CACpB,aAAK;AACV,QAAMC,iBAAiB,IAAIC,MAAJ,CAAcC,CAAd,aAAuBA,CAAvB,aAAgCA,CAAhC,SAAvB;AACA,WAAO,CAACF,eAAeH,IAAf,CAAoBD,KAApB,CAAR;AACD,GAJ0B,CAA7B;;AAMA,MAAI,CAACE,oBAAL,EAA2B;AACzB,WAAO,KAAP;AACD;;AAED,SAAO,WAAUD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AAO,CAAP,CAFzB,CADF;;AAKA,WAAQI,WAAW,EAAZ,KAAoB,CAA3B;AACD;AACD,SAAO,KAAP;AACD;;AAEM,SAAS/B,uBAAT,CAAiCa,KAAjC,EAAwCF,IAAxC,EAA8C;AACnD,MAAI,QAAOE,KAAP,yCAAOA,KAAP,OAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAImB,KAAJ,CAAU,qCAAV,CAAN;AACD;AACD,MAAInB,UAAUJ,OAAOI,KAAP,IAAgB,EAAhB,IAAsBJ,OAAOI,KAAP,IAAgB,CAAhD,CAAJ,EAAwD;AACtD,WAAO,KAAP;AACD;;AAED,SAAOpB,mBAAmB,IAAnB,EAAyB,IAAzB,EAA+BkB,IAA/B,CAAP;AACD;;AAEM,SAASV,6BAAT,CAAuCY,KAAvC,EAA8CF,IAA9C,EAAoD;AACzD,MAAI,QAAOE,KAAP,yCAAOA,KAAP,OAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAImB,KAAJ,CAAU,qCAAV,CAAN;AACD;AACD,MAAMlB,aAAa,sBAAO,EAAEH,UAAF,EAAQE,OAAOA,QAAQE,SAASF,KAAT,EAAgB,EAAhB,IAAsB,CAA9B,GAAkC,IAAjD,EAAP,CAAnB;AACA,SAAO,CAACF,IAAD,IAASX,wBAAwBa,KAAxB,EAA+BF,IAA/B,KAAwCG,WAAWmB,OAAX,EAAxC,IAAgEnB,WAAWE,cAAX,CAA0B,wBAASkB,OAAT,CAAiB,OAAjB,CAA1B,CAAhF;AACD","file":"index.js","sourcesContent":["import _ from 'lodash';\nimport moment from 'moment';\n\n// Conditions for valid SSN from the original 1010ez pdf form:\n// '123456789' is not a valid SSN\n// A value where the first 3 digits are 0 is not a valid SSN\n// A value where the 4th and 5th digits are 0 is not a valid SSN\n// A value where the last 4 digits are 0 is not a valid SSN\n// A value with 3 digits, an optional -, 2 digits, an optional -, and 4 digits is a valid SSN\n// 9 of the same digits (e.g., '111111111') is not a valid SSN\nexport function isValidSSN(value) {\n if (value === '123456789' || value === '123-45-6789') {\n return false;\n } else if (/^0{3}-?\\d{2}-?\\d{4}$/.test(value)) {\n return false;\n } else if (/^\\d{3}-?0{2}-?\\d{4}$/.test(value)) {\n return false;\n } else if (/^\\d{3}-?\\d{2}-?0{4}$/.test(value)) {\n return false;\n }\n\n const noBadSameDigitNumber = _.range(0, 10)\n .every(i => {\n const sameDigitRegex = new RegExp(`${i}{3}-?${i}{2}-?${i}{4}`);\n return !sameDigitRegex.test(value);\n });\n\n if (!noBadSameDigitNumber) {\n return false;\n }\n\n return /^\\d{9}$/.test(value) || /^\\d{3}-\\d{2}-\\d{4}$/.test(value);\n}\n\nexport function isValidYear(value) {\n return Number(value) >= 1900 && Number(value) <= moment().add(100, 'year').year();\n}\n\nexport function isValidPartialDate(day, month, year) {\n if (year && !isValidYear(year)) {\n return false;\n }\n\n return true;\n}\n\nexport function isValidCurrentOrPastDate(day, month, year) {\n const momentDate = moment({ day, month: parseInt(month, 10) - 1, year });\n return momentDate.isSameOrBefore(moment().endOf('day'), 'day');\n}\n\nexport function isValidCurrentOrPastYear(value) {\n return Number(value) >= 1900 && Number(value) < moment().year() + 1;\n}\n\nexport function isValidCurrentOrFutureMonthYear(month, year) {\n const momentDate = moment({ month: parseInt(month, 10) - 1, year });\n return momentDate.isSameOrAfter(moment(), 'month');\n}\n\nfunction isBlank(value) {\n return value === '';\n}\n\nfunction isBlankDateField(field) {\n return isBlank(field.day.value) && isBlank(field.month.value) && isBlank(field.year.value);\n}\n\nexport function dateToMoment(dateField) {\n return moment({\n year: dateField.year.value,\n month: dateField.month.value ? parseInt(dateField.month.value, 10) - 1 : '',\n day: dateField.day ? dateField.day.value : null\n });\n}\n\nexport function isValidDateRange(fromDate, toDate) {\n if (isBlankDateField(toDate) || isBlankDateField(fromDate)) {\n return true;\n }\n const momentStart = dateToMoment(fromDate);\n const momentEnd = dateToMoment(toDate);\n return momentStart.isSameOrBefore(momentEnd);\n}\n\n// Pulled from https://en.wikipedia.org/wiki/Routing_transit_number#Check_digit\nexport function isValidRoutingNumber(value) {\n if (/^\\d{9}$/.test(value)) {\n const digits = value.split('').map(val => parseInt(val, 10));\n const weighted =\n 3 * (digits[0] + digits[3] + digits[6]) +\n 7 * (digits[1] + digits[4] + digits[7]) +\n (digits[2] + digits[5] + digits[8]);\n\n return (weighted % 10) === 0;\n }\n return false;\n}\n\nexport function isValidPartialMonthYear(month, year) {\n if (typeof month === 'object') {\n throw new Error('Pass a month and a year to function');\n }\n if (month && (Number(month) > 12 || Number(month) < 1)) {\n return false;\n }\n\n return isValidPartialDate(null, null, year);\n}\n\nexport function isValidPartialMonthYearInPast(month, year) {\n if (typeof month === 'object') {\n throw new Error('Pass a month and a year to function');\n }\n const momentDate = moment({ year, month: month ? parseInt(month, 10) - 1 : null });\n return !year || isValidPartialMonthYear(month, year) && momentDate.isValid() && momentDate.isSameOrBefore(moment().startOf('month'));\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../../../../src/js/utilities/validations/index.js"],"names":["isValidSSN","isValidYear","isValidPartialDate","isValidCurrentOrPastDate","isValidCurrentOrPastYear","isValidCurrentOrFutureMonthYear","parseDateField","isValidDateRange","isValidRoutingNumber","isValidPartialMonthYear","isValidPartialMonthYearInPast","value","test","noBadSameDigitNumber","every","sameDigitRegex","RegExp","i","Number","Date","day","month","year","date","today","currentYear","isBlank","isBlankDateField","field","dateField","fromDateField","toDateField","fromDate","toDate","digits","split","map","parseInt","val","weighted","Error","isSameOrBefore"],"mappings":";;;;;;;;;;;;QAiBgBA,U,GAAAA,U;QAwBAC,W,GAAAA,W;QAIAC,kB,GAAAA,kB;QAQAC,wB,GAAAA,wB;QAMAC,wB,GAAAA,wB;QAKAC,+B,GAAAA,+B;QAcAC,c,GAAAA,c;QAOAC,gB,GAAAA,gB;QAUAC,oB,GAAAA,oB;QAaAC,uB,GAAAA,uB;QAWAC,6B,GAAAA,6B;;AAtHhB;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASV,UAAT,CAAo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AP,OAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAImB,KAAJ,CAAU,qCAAV,CAAN;AACD;AACD,MAAMjB,OAAO,IAAIJ,IAAJ,CAASG,IAAT,EAAeD,KAAf,EAAsB,IAAtB,CAAb;AACA,MAAMG,QAAQ,IAAIL,IAAJ,EAAd;AACA,MAAMsB,iBAAkB,0BAAYlB,IAAZ,EAAkBC,KAAlB,KAA4B,uBAASD,IAAT,EAAeC,KAAf,CAApD;AACA,SAAO,CAACF,IAAD,IAASb,wBAAwBY,KAAxB,EAA+BC,IAA/B,KAAwCmB,cAAxD;AACD","file":"index.js","sourcesContent":["import _ from 'lodash';\nimport {\n addYears,\n isSameDay,\n isBefore,\n isSameMonth,\n isAfter,\n getYear\n} from 'date-fns';\n\n// Conditions for valid SSN from the original 1010ez pdf form:\n// '123456789' is not a valid SSN\n// A value where the first 3 digits are 0 is not a valid SSN\n// A value where the 4th and 5th digits are 0 is not a valid SSN\n// A value where the last 4 digits are 0 is not a valid SSN\n// A value with 3 digits, an optional -, 2 digits, an optional -, and 4 digits is a valid SSN\n// 9 of the same digits (e.g., '111111111') is not a valid SSN\nexport function isValidSSN(value) {\n if (value === '123456789' || value === '123-45-6789') {\n return false;\n } else if (/^0{3}-?\\d{2}-?\\d{4}$/.test(value)) {\n return false;\n } else if (/^\\d{3}-?0{2}-?\\d{4}$/.test(value)) {\n return false;\n } else if (/^\\d{3}-?\\d{2}-?0{4}$/.test(value)) {\n return false;\n }\n\n const noBadSameDigitNumber = _.range(0, 10)\n .every(i => {\n const sameDigitRegex = new RegExp(`${i}{3}-?${i}{2}-?${i}{4}`);\n return !sameDigitRegex.test(value);\n });\n\n if (!noBadSameDigitNumber) {\n return false;\n }\n\n return /^\\d{9}$/.test(value) || /^\\d{3}-\\d{2}-\\d{4}$/.test(value);\n}\n\nexport function isValidYear(value) {\n return Number(value) >= 1900 && Number(value) <= getYear(addYears(new Date(), 100));\n}\n\nexport function isValidPartialDate(day, month, year) {\n if (year && !isValidYear(year)) {\n return false;\n }\n\n return true;\n}\n\nexport function isValidCurrentOrPastDate(day, month, year) {\n const date = new Date(year, month - 1, day);\n const today = new Date();\n return isSameDay(date, today) || isBefore(date, today);\n}\n\nexport function isValidCurrentOrPastYear(value) {\n const currentYear = getYear(new Date());\n return Number(value) >= 1900 && Number(value) <= currentYear;\n}\n\nexport function isValidCurrentOrFutureMonthYear(month, year) {\n const date = new Date(year, month - 1);\n const today = new Date();\n return isSameMonth(date, today) || isAfter(date, today);\n}\n\nfunction isBlank(value) {\n return value === '';\n}\n\nfunction isBlankDateField(field) {\n return isBlank(field.day.value) && isBlank(field.month.value) && isBlank(field.year.value);\n}\n\nexport function parseDateField(dateField) {\n const year = dateField.year.value;\n const month = dateField.month.value || null;\n const day = dateField.day.value || null;\n return new Date(year, month - 1, day);\n}\n\nexport function isValidDateRange(fromDateField, toDateField) {\n if (isBlankDateField(toDateField) || isBlankDateField(fromDateField)) {\n return true;\n }\n const fromDate = parseDateField(fromDateField);\n const toDate = parseDateField(toDateField);\n return fromDate <= toDate;\n}\n\n// Pulled from https://en.wikipedia.org/wiki/Routing_transit_number#Check_digit\nexport function isValidRoutingNumber(value) {\n if (/^\\d{9}$/.test(value)) {\n const digits = value.split('').map(val => parseInt(val, 10));\n const weighted =\n 3 * (digits[0] + digits[3] + digits[6]) +\n 7 * (digits[1] + digits[4] + digits[7]) +\n (digits[2] + digits[5] + digits[8]);\n\n return (weighted % 10) === 0;\n }\n return false;\n}\n\nexport function isValidPartialMonthYear(month, year) {\n if (typeof month === 'object') {\n throw new Error('Pass a month and a year to function');\n }\n if (month && (Number(month) > 12 || Number(month) < 1)) {\n return false;\n }\n\n return isValidPartialDate(null, null, year);\n}\n\nexport function isValidPartialMonthYearInPast(month, year) {\n if (typeof month === 'object') {\n throw new Error('Pass a month and a year to function');\n }\n const date = new Date(year, month, null);\n const today = new Date();\n const isSameOrBefore = (isSameMonth(date, today) || isBefore(date, today));\n return !year || isValidPartialMonthYear(month, year) && isSameOrBefore;\n}\n"]} \ No newline at end of file