Skip to content

Commit

Permalink
Merge pull request #78 from cfpb/meissadia/ffvt-fix-2017
Browse files Browse the repository at this point in the history
Tools: Add 2017 error rendering logic back in to FFVT
  • Loading branch information
wpears authored Dec 19, 2019
2 parents 0b8e2de + 412676c commit d1f71f1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
73 changes: 52 additions & 21 deletions src/tools/file-format-verification/components/ParseErrors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { ERRORS_PER_PAGE } from '../constants'

import './ParseErrors.css'

const renderLarErrors = (larErrors, pagination) => {
const renderLarErrors = (larErrors, pagination, period) => {
if (larErrors.length === 0) return null
const currentErrs = []
const is2017 = period === '2017'

//don't move to the next page until fading in
const end =
Expand All @@ -22,7 +23,7 @@ const renderLarErrors = (larErrors, pagination) => {

currentErrs.push(
<tr key={i}>
{renderErrorColumns(err)}
{is2017 ? renderErrorColumns2017(err) : renderErrorColumns(err)}
</tr>
)
}
Expand All @@ -37,21 +38,16 @@ const renderLarErrors = (larErrors, pagination) => {
<p>Formatting errors in loan application records, arranged by row.</p>
</caption>
<thead>
<tr>
<th>Row</th>
<th>ULI</th>
<th>LAR Data Field</th>
<th>Found Value</th>
<th>Valid Value</th>
</tr>
<tr>{getHeaders(is2017)}</tr>
</thead>
<tbody>{currentErrs}</tbody>
</table>
)
}

const renderTSErrors = transmittalSheetErrors => {
const renderTSErrors = (transmittalSheetErrors, period) => {
if (transmittalSheetErrors.length === 0) return null
const is2017 = period === '2017'
return (
<table className="margin-bottom-0" width="100%">
<caption>
Expand All @@ -62,19 +58,14 @@ const renderTSErrors = transmittalSheetErrors => {
</p>
</caption>
<thead>
<tr>
<th>Row</th>
<th>TS Data Field</th>
<th>Found Value</th>
<th>Valid Value</th>
</tr>
<tr>{getHeaders(is2017, true)}</tr>
</thead>
<tbody>
{transmittalSheetErrors.map((tsError, i) => {
return (
<tr key={i}>
<td>1</td>
{renderErrorColumns(tsError)}
{is2017 ? renderErrorColumns2017(tsError) : renderErrorColumns(tsError)}
</tr>
)
})}
Expand Down Expand Up @@ -126,14 +117,53 @@ function renderErrorColumns(err){
return columns
}

function renderErrorColumns2017(err){
// TS Error
if(!err.row && !err.error)
return <td>{err}</td>

// LAR Error
return (
<>
<td>{err.row}</td>
<td>{err.error}</td>
</>
)
}

function getHeaders(is2017, isTs) {
const headers = ['Row']

if (is2017) {
// 2017 TS & LAR
headers.push('Errors')
} else {
if (isTs) {
// 2018+ TS
headers.push('TS Data Field')
headers.push('Found Value')
headers.push('Valid Value')
} else {
// 2018+ LAR
headers.push('ULI')
headers.push('LAR Data Field')
headers.push('Found Value')
headers.push('Valid Value')
}
}

return headers.map((label, idx) => <th key={idx}>{label}</th>)
}

const ParseErrors = props => {
const {
parsed,
isParsing,
transmittalSheetErrors,
larErrors,
pagination,
errors
errors,
filingPeriod
} = props
const count = transmittalSheetErrors.length + larErrors.length

Expand All @@ -143,16 +173,17 @@ const ParseErrors = props => {
return (
<div className="ParseErrors usa-grid-full" id="parseErrors">
{renderParseResults(count, errors)}
{renderTSErrors(transmittalSheetErrors)}
{renderLarErrors(larErrors, pagination)}
{renderTSErrors(transmittalSheetErrors, filingPeriod)}
{renderLarErrors(larErrors, pagination, filingPeriod)}
<Pagination />
</div>
)
}

ParseErrors.propTypes = {
transmittalSheetErrors: PropTypes.array,
larErrors: PropTypes.array
larErrors: PropTypes.array,
period: PropTypes.string
}

export default ParseErrors
5 changes: 3 additions & 2 deletions src/tools/file-format-verification/containers/ParseErrors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ function mapStateToProps(state) {

const { errors } = state.app.upload

const { pagination } = state.app
const { pagination, filingPeriod } = state.app

return {
isParsing,
parsed,
transmittalSheetErrors,
larErrors,
pagination,
errors
errors,
filingPeriod
}
}

Expand Down

0 comments on commit d1f71f1

Please sign in to comment.