From 0f06c11bf4181b74dd8e88ac9fb1c47dd46bc530 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Thu, 12 Sep 2024 18:29:16 -0700 Subject: [PATCH 1/5] Add card component and use default buttons --- .../Tool/Import/Csv/CsvHeaders.test.tsx | 11 ++-- src/components/Tool/Import/Csv/CsvHeaders.tsx | 58 ++++++++++--------- src/components/Tool/Import/Csv/CsvPreview.tsx | 46 ++++++--------- src/components/Tool/Import/Csv/CsvUpload.tsx | 33 ++++++----- src/components/Tool/Import/Csv/CsvValues.tsx | 37 +++++------- 5 files changed, 88 insertions(+), 97 deletions(-) diff --git a/src/components/Tool/Import/Csv/CsvHeaders.test.tsx b/src/components/Tool/Import/Csv/CsvHeaders.test.tsx index 272e2998d..e21d0e78b 100644 --- a/src/components/Tool/Import/Csv/CsvHeaders.test.tsx +++ b/src/components/Tool/Import/Csv/CsvHeaders.test.tsx @@ -118,7 +118,10 @@ describe('CsvHeaders', () => { }); it('should allow the user to map every header', async () => { - uploadData.fileHeaders = { first_name: 'Test1', custom_header: 'Wee' }; + uploadData.fileHeaders = { + first_name: 'First Name', + custom_header: 'Wee', + }; const { findByRole } = render( { ); expect( - await findByRole('cell', { name: 'first_name' }), - ).toBeInTheDocument(); - expect( - await findByRole('cell', { name: 'custom_header' }), + await findByRole('cell', { name: 'First Name' }), ).toBeInTheDocument(); + expect(await findByRole('cell', { name: 'Wee' })).toBeInTheDocument(); }); }); diff --git a/src/components/Tool/Import/Csv/CsvHeaders.tsx b/src/components/Tool/Import/Csv/CsvHeaders.tsx index 992f500bf..77ae7f343 100644 --- a/src/components/Tool/Import/Csv/CsvHeaders.tsx +++ b/src/components/Tool/Import/Csv/CsvHeaders.tsx @@ -3,6 +3,10 @@ import { Alert, Box, Button, + Card, + CardHeader, + List, + ListItem, MenuItem, Select, Table, @@ -10,20 +14,19 @@ import { TableCell, TableHead, TableRow, - Typography, } from '@mui/material'; import { cloneDeep } from 'lodash/fp'; import { useTranslation } from 'react-i18next'; import { useApiConstants } from 'src/components/Constants/UseApiConstants'; import { Confirmation } from 'src/components/common/Modal/Confirmation/Confirmation'; import useGetAppSettings from 'src/hooks/useGetAppSettings'; +import theme from 'src/theme'; import { CsvImportContext, CsvImportType, CsvImportValue, CsvImportViewStepEnum, } from './CsvImportContext'; -import { HeaderBox } from './HeaderBox'; import { get, save } from './csvImportService'; import { useRequiredHeaders, useSupportedHeaders } from './uploadCsvFile'; @@ -208,15 +211,21 @@ const CsvHeaders: React.FC = ({ )} - -
    -
  • + + + {t( 'Columns with duplicate or empty headers are ignored. Please ensure your CSV does not have any such headers!', )} -
  • -
  • {t('Street is required to import any address information.')}
  • -
+ + + {t('Street is required to import any address information.')} + +
{showBackWarningModal && ( @@ -233,10 +242,13 @@ const CsvHeaders: React.FC = ({ > )} - - - {t('Map your headers')} - + + @@ -248,15 +260,16 @@ const CsvHeaders: React.FC = ({ - {Object.keys(importHeaders).map((header) => { + {Object.entries(importHeaders).map(([header, headerName]) => { return ( - {header} + {headerName}
@@ -152,6 +156,7 @@ const CsvValues: React.FC = ({ handleUpdateHeaders(e, header)} value={fileHeadersMappings[header] || -1}