Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Review - Errors & Warnings - Part 2 #537

Merged
merged 25 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f4aea57
style(single/multi/register errors): 45px margin-bottom
shindigira May 17, 2024
4b3ec07
style(tables): only multifield tables have borders, single/register d…
shindigira May 17, 2024
674c6f7
style(errors/warnings - success): use negative margin only when no er…
shindigira May 17, 2024
fdd60c8
content(errors): there is
shindigira May 17, 2024
94f06b0
style(warnings): restrict header to 670px
shindigira May 17, 2024
ada6c98
enhancement(warnings): reworked warnings alert
shindigira May 17, 2024
66c0de5
style(warnings): no table borders even in multifield
shindigira May 17, 2024
02f735e
WIP: get records affected by errors count
shindigira May 17, 2024
b498687
content(Errors): logic errors intro text
shindigira May 18, 2024
7cbfb69
feat(errors & warnings): Updated the count to be the rows affected by…
shindigira May 20, 2024
ae2d4b9
style(success error/warnings alert): reduced margin-bottom to 30px
shindigira May 20, 2024
ec0e028
style(warnings): multifield warnings now also has table borders
shindigira May 20, 2024
aa31b68
style(verify warnings): verify text limited to 670px
shindigira May 20, 2024
4674173
comment - useisoverflowing
shindigira May 20, 2024
6904f2f
content(errors/warnings): added 'records' word to count
shindigira May 20, 2024
b6ef2f9
style(verify warnings): 670px checkbox text; 770px well
shindigira May 21, 2024
19d24e6
content(errors/warnings): records vs record
shindigira May 21, 2024
ed8b0a1
stylefix(table): hidden table borders are now present again
shindigira May 21, 2024
f641232
content(errors/warnings): error/warnings counts use commas (e.g. 1,000)
shindigira May 21, 2024
3078afd
Merge branch 'main' of github.com:cfpb/sbl-frontend into design-revie…
shindigira May 21, 2024
0872c3d
content(errors/warnings): records changed to found
shindigira May 21, 2024
bf7daf5
stylefix(upload/errors): removed min-h-[80vh]
shindigira May 21, 2024
addc020
Merge branch 'main' of github.com:cfpb/sbl-frontend into design-revie…
shindigira May 21, 2024
7fae3c4
contentfix(errors/warnings): typo -- only one 'found' should be seen
shindigira May 21, 2024
411ec2d
Merge branch 'main' of github.com:cfpb/sbl-frontend into design-revie…
shindigira May 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/components/FormButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import type { ReactNode } from 'react';

interface Properties {
interface FormButtonGroupProperties {
children: ReactNode;
isFilingStep?: boolean;
}

function FormButtonGroup({ isFilingStep, children }: Properties): JSX.Element {
function FormButtonGroup({
className,
isFilingStep,
children,
}: FormButtonGroupProperties & JSX.IntrinsicElements['div']): JSX.Element {
return (
<div
className={`mt-[1.875rem] flex ${
isFilingStep ? 'gap-[1.125rem]' : 'gap-[0.625rem]'
}`}
} ${className}`}
>
{children}
</div>
Expand Down
31 changes: 24 additions & 7 deletions src/pages/Filing/FilingApp/FieldEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ const wordBreakTestRows = [

interface FieldEntryProperties {
fieldObject: Detail;
showTableBorders?: boolean;
}

function FieldEntry({ fieldObject }: FieldEntryProperties): JSX.Element {
function FieldEntry({
fieldObject,
showTableBorders,
}: FieldEntryProperties): JSX.Element {
// TODO: selectively enable borders based on if the table is overflowing
// Issue: https://github.com/cfpb/sbl-frontend/issues/547
// const [multiTableReference, isMultiTableOverflowing] = useIsOverflowing();

const validationId = fieldObject.validation.id;
const validationLink = fieldObject.validation.fig_link;
const validationName = fieldObject.validation.name;
Expand Down Expand Up @@ -59,7 +67,11 @@ function FieldEntry({ fieldObject }: FieldEntryProperties): JSX.Element {
],
[],
);
return [object.record_no + One, object.uid, ...fieldValues];
return [
(object.record_no + One).toLocaleString(),
object.uid,
...fieldValues,
];
});

const totalItems = rows.length;
Expand All @@ -74,9 +86,7 @@ function FieldEntry({ fieldObject }: FieldEntryProperties): JSX.Element {
const itemsToShow = rows.slice(startIndex, endIndex);
const previousItemsToShow = rows
.slice(startIndex - ITEMS_PER_PAGE, startIndex - itemsToShow.length)
.map(array =>
array.map(charNumber => (typeof charNumber === 'number' ? 0 : '')),
);
.map(array => array.map((charNumber, index) => (index === 0 ? index : '')));
const isHiddenTableAdded =
showPagination && ITEMS_PER_PAGE > itemsToShow.length;

Expand Down Expand Up @@ -110,17 +120,20 @@ function FieldEntry({ fieldObject }: FieldEntryProperties): JSX.Element {
</div>
<div className='mb-[0.9375rem]'>
<Table
className='w-full max-w-full table-auto'
className={`w-full max-w-full table-auto ${
showTableBorders ? '' : '!border-0'
}`}
columns={columns}
// @ts-expect-error TypeScript error needs to be resolved within DSR
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
rows={itemsToShow}
isScrollableHorizontal
// ref={multiTableReference}
/>
{/* NOTE: Table used to create space */}
{isHiddenTableAdded ? (
<Table
className='w-full max-w-full table-auto border-separate !border-t-0 outline-none [&>tbody>tr:not(:last-child)]:border-b-transparent [&_thead]:hidden [&_tr]:invisible'
className='w-full max-w-full table-auto !border-t-0 outline-none [&>tbody>tr:not(:last-child)]:border-b-transparent [&_thead]:hidden [&_tr]:invisible'
aria-hidden='true'
columns={columns}
// @ts-expect-error TypeScript error needs to be resolved within DSR
Expand All @@ -142,4 +155,8 @@ function FieldEntry({ fieldObject }: FieldEntryProperties): JSX.Element {
);
}

FieldEntry.defaultProps = {
showTableBorders: false,
};

export default FieldEntry;
21 changes: 17 additions & 4 deletions src/pages/Filing/FilingApp/FieldSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface FieldProperties {
bottomMargin?: boolean;
children: ReactNode;
id: string;
showTableBorders?: boolean;
}

function FieldSummary({
Expand All @@ -17,19 +18,31 @@ function FieldSummary({
bottomMargin,
children,
id,
}: FieldProperties): JSX.Element {
className = '',
showTableBorders,
}: FieldProperties & JSX.IntrinsicElements['div']): JSX.Element {
return (
<div id={id} className={bottomMargin ? 'mb-[3.75rem]' : ''}>
<SectionIntro heading={heading}>{children}</SectionIntro>
<div
id={id}
className={`${bottomMargin ? 'mb-[3.75rem]' : ''} ${className}`}
>
<SectionIntro className='mb-[2.8125rem]' heading={heading}>
{children}
</SectionIntro>
{fieldArray.map(fieldObject => (
<FieldEntry key={fieldObject.validation.id} fieldObject={fieldObject} />
<FieldEntry
key={fieldObject.validation.id}
fieldObject={fieldObject}
showTableBorders={showTableBorders}
/>
))}
</div>
);
}

FieldSummary.defaultProps = {
bottomMargin: false,
showTableBorders: false,
};

export default FieldSummary;
4 changes: 2 additions & 2 deletions src/pages/Filing/FilingApp/FileSubmission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function FileSubmission(): JSX.Element {
const onPreviousClick = (): void => navigate(`/filing`);

return (
<div id='file-submission' className='min-h-[80vh]'>
<div id='file-submission'>
<FilingSteps />
<FormWrapper>
<FormHeaderWrapper>
Expand Down Expand Up @@ -532,7 +532,7 @@ export function FileSubmission(): JSX.Element {
) : null}
</FieldGroup>
</FormMain>
<FormButtonGroup>
<FormButtonGroup isFilingStep>
<FilingNavButtons
classNameButtonContainer='u-mb0'
onNextClick={onNextClick}
Expand Down
12 changes: 12 additions & 0 deletions src/pages/Filing/FilingApp/FilingErrors/FilingErrors.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ export const getErrorsWarningsSummary = (
logicWarningsMulti,
};
};

export const getRecordsAffected = (
validationDetails: Detail[],
): Set<number> => {
const setRecords = new Set<number>();
for (const detail of validationDetails) {
for (const record of detail.records) {
setRecords.add(record.record_no);
}
}
return setRecords;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { dataValidationLink } from 'utils/common';
function SuccessAlert({ isStep2 }: { isStep2: boolean }): JSX.Element {
return (
<Alert
className='mb-[2.8125rem] [&_div]:max-w-[41.875rem] [&_p]:max-w-[41.875rem]'
className='mb-[1.875rem] [&_div]:max-w-[41.875rem] [&_p]:max-w-[41.875rem]'
message={`Your register contains no ${
isStep2 ? 'logic' : 'syntax'
} errors`}
Expand Down Expand Up @@ -43,7 +43,7 @@ function LogicErrorsAlert(): JSX.Element {
status='error'
>
<Paragraph>
There may be missing data, incorrect data, or conflicting information in
There is missing data, incorrect data, or conflicting information in
your file. Make sure your register meets the requirements detailed in
the filing instructions guide (
<Link target='_blank' href={dataValidationLink}>
Expand Down
53 changes: 21 additions & 32 deletions src/pages/Filing/FilingApp/FilingErrors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import FormButtonGroup from 'components/FormButtonGroup';
import FormHeaderWrapper from 'components/FormHeaderWrapper';
import FormWrapper from 'components/FormWrapper';
import { LoadingContent } from 'components/Loading';
import {
Alert,
AlertFieldLevel,
Paragraph,
TextIntroduction,
} from 'design-system-react';
import { Paragraph, TextIntroduction } from 'design-system-react';
import FieldSummary from 'pages/Filing/FilingApp/FieldSummary';
import { getErrorsWarningsSummary } from 'pages/Filing/FilingApp/FilingErrors/FilingErrors.helpers';
import {
getErrorsWarningsSummary,
getRecordsAffected,
} from 'pages/Filing/FilingApp/FilingErrors/FilingErrors.helpers';
import FilingErrorsAlerts from 'pages/Filing/FilingApp/FilingErrors/FilingErrorsAlerts';
import { FilingSteps } from 'pages/Filing/FilingApp/FilingSteps';
import InstitutionHeading from 'pages/Filing/FilingApp/InstitutionHeading';
Expand All @@ -19,7 +17,7 @@ import { useNavigate, useParams } from 'react-router-dom';
import useGetSubmissionLatest from 'utils/useGetSubmissionLatest';
import useInstitutionDetails from 'utils/useInstitutionDetails';
import FilingFieldLinks from '../FilingFieldLinks';
import FilingNavButtons from '../FilingNavButtons';
import { FilingNavButtons } from '../FilingNavButtons';
import { InstitutionFetchFailAlert } from '../FilingWarnings/FilingWarningsAlerts';

function FilingErrors(): JSX.Element {
Expand Down Expand Up @@ -64,6 +62,13 @@ function FilingErrors(): JSX.Element {
? logicErrorsSingle
: syntaxErrorsSingle;

// Count rows with errors per type (not total errors)
const singleFieldRowErrorsCount = getRecordsAffected(
singleFieldErrorsUsed,
).size;
const multiFieldRowErrorsCount = getRecordsAffected(logicErrorsMulti).size;
const registerLevelRowErrorsCount = getRecordsAffected(registerErrors).size;

if (isFetchingGetSubmissionLatest || isLoadingInstitution)
return <LoadingContent />;

Expand All @@ -84,7 +89,7 @@ function FilingErrors(): JSX.Element {
};

return (
<div id='resolve-errors' className='min-h-[80vh]'>
<div id='resolve-errors'>
<FilingSteps />
<FormWrapper>
<FormHeaderWrapper>
Expand All @@ -102,8 +107,8 @@ function FilingErrors(): JSX.Element {
isStep2 ? (
<>
Your register successfully passed syntax checks. If
applicable, review and correct errors related to inconsistent
or inaccurate values in your register. Your register must pass
applicable, review and correct errors in your register related
to inconsistent or inaccurate values. Your register must pass
these logic checks to continue to the next step.
</>
) : (
Expand Down Expand Up @@ -161,9 +166,9 @@ function FilingErrors(): JSX.Element {
{errorState ? (
<FieldSummary
id='single-field-errors'
heading={`Single-field errors found: ${singleFieldErrorsUsed.length}`}
heading={`Single-field errors: ${singleFieldRowErrorsCount.toLocaleString()} found`}
fieldArray={singleFieldErrorsUsed}
bottomMargin={!!isStep2}
bottomMargin={Boolean(isStep2)}
>
Each single-field validation pertains to only one specific field
in each record. These validations check that the data held in an
Expand All @@ -175,8 +180,9 @@ function FilingErrors(): JSX.Element {
{/* MULTI-FIELD ERRORS */}
<FieldSummary
id='multi-field-errors'
heading={`Multi-field errors found: ${logicErrorsMulti.length}`}
heading={`Multi-field errors: ${multiFieldRowErrorsCount.toLocaleString()} found`}
fieldArray={logicErrorsMulti}
showTableBorders
bottomMargin
>
Multi-field validations check that the values of certain
Expand All @@ -186,7 +192,7 @@ function FilingErrors(): JSX.Element {
{/* REGISTER-LEVEL ERRORS */}
<FieldSummary
id='register-level-errors'
heading={`Register-level errors found: ${registerErrors.length}`}
heading={`Register-level errors: ${registerLevelRowErrorsCount.toLocaleString()} found`}
fieldArray={registerErrors}
>
This validation checks that the register does not contain
Expand Down Expand Up @@ -215,23 +221,6 @@ function FilingErrors(): JSX.Element {
) : null}
</>
)}
{errorState ? (
<>
<AlertFieldLevel
message={`You must resolve ${
isStep2 ? 'logic errors' : 'syntax errors'
} to continue with the filing process`}
status='error'
/>
<Alert
className='mb-[2.8125rem] [&_div]:max-w-[41.875rem] [&_p]:max-w-[41.875rem]'
message={`You must resolve ${
isStep2 ? 'logic errors' : 'syntax errors'
} to continue with the filing process`}
status='error'
/>
</>
) : null}
</FormWrapper>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Alert, Paragraph } from 'design-system-react';
import { ValidationInitialFetchFailAlert } from 'pages/Filing/FilingApp/FileSubmission.data';
import { dataValidationLink } from 'utils/common';

function SuccessWarningsAlert(): JSX.Element {
function SuccessVerifiedWarningsAlert(): JSX.Element {
return (
<Alert
className='mb-[2.8125rem] [&_div]:max-w-[41.875rem] [&_p]:max-w-[41.875rem]'
Expand All @@ -14,6 +14,16 @@ function SuccessWarningsAlert(): JSX.Element {
);
}

function SuccessWarningsAlert(): JSX.Element {
return (
<Alert
className='mb-[1.875rem] [&_div]:max-w-[41.875rem] [&_p]:max-w-[41.875rem]'
message='Your register contains no warnings'
status='success'
/>
);
}

function WarningsAlert(): JSX.Element {
return (
<Alert
Expand Down Expand Up @@ -51,16 +61,22 @@ export function InstitutionFetchFailAlert({
interface FilingWarningsAlertsProperties {
hasWarnings: boolean;
hasSubmissionError: unknown;
hasSubmissionAccepted: boolean;
}

function FilingWarningsAlerts({
hasWarnings,
hasSubmissionError,
hasSubmissionAccepted,
}: FilingWarningsAlertsProperties): JSX.Element {
return hasSubmissionError ? (
<ValidationInitialFetchFailAlert />
) : hasWarnings ? (
<WarningsAlert />
hasSubmissionAccepted ? (
<SuccessVerifiedWarningsAlert />
) : (
<WarningsAlert />
)
) : (
<SuccessWarningsAlert />
);
Expand Down
Loading