Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Sep 18, 2024
1 parent 8f7e5e5 commit 23b633a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ interface ExplicitNamingFilterFormProps {
sourceFilterForExplicitNamingConversion?: FilterForExplicitConversionProps;
}

function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion }: ExplicitNamingFilterFormProps) {
function ExplicitNamingFilterForm({
sourceFilterForExplicitNamingConversion,
}: Readonly<ExplicitNamingFilterFormProps>) {
const intl = useIntl();
const { snackError } = useSnackMessage();

Expand Down Expand Up @@ -166,9 +168,9 @@ function ExplicitNamingFilterForm({ sourceFilterForExplicitNamingConversion }: E
return newCsvFileHeaders;
}, [intl, forGeneratorOrLoad]);

const getDataFromCsvFile = useCallback((csvData: any) => {
const getDataFromCsvFile = useCallback((csvData: string[][]) => {
if (csvData) {
return csvData.map((value: any) => {
return csvData.map((value) => {
return {
[FieldConstants.AG_GRID_ROW_UUID]: uuid4(),
[FieldConstants.EQUIPMENT_ID]: value[0]?.trim(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function BottomRightButtons({
}: Readonly<BottomRightButtonsProps>) {
const [uploaderOpen, setUploaderOpen] = useState(false);
const intl = useIntl();
const onClose = useCallback(() => setUploaderOpen(false), []);

return (
<>
Expand Down Expand Up @@ -88,7 +89,7 @@ function BottomRightButtons({
</Grid>
<CsvUploader
open={uploaderOpen}
onClose={useCallback(() => setUploaderOpen(false), [])}
onClose={onClose}
name={name}
useFieldArrayOutput={useFieldArrayOutput}
{...csvProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useCSVReader } from 'react-papaparse';
import { ReactNode, useMemo, useState } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import CsvDownloader from 'react-csv-downloader';
import { FieldValues, UseFieldArrayReturn, useWatch } from 'react-hook-form';
import { FieldValues, UseFieldArrayAppend, UseFieldArrayReturn, useWatch } from 'react-hook-form';
import { RECORD_SEP, UNIT_SEP } from 'papaparse';
import FieldConstants from '../../../../../utils/constants/fieldConstants';
import CancelButton from '../../utils/CancelButton';
Expand All @@ -33,7 +33,7 @@ export interface CsvUploaderProps {
fileName: string;
csvData?: Array<string[] | Record<string, string | null | undefined>>;
validateData?: (rows: string[][]) => boolean;
getDataFromCsv: any;
getDataFromCsv: (csvData: string[][]) => Parameters<UseFieldArrayAppend<FieldValues, string>>[0]; // keep generics in sync with useFieldArrayOutput field
useFieldArrayOutput: UseFieldArrayReturn<FieldValues, string, 'id'>;
}

Expand Down

0 comments on commit 23b633a

Please sign in to comment.