Skip to content

Commit 752654e

Browse files
Add language property to CsvUploader component (#840)
Signed-off-by: Franck LECUYER <[email protected]>
1 parent c06e975 commit 752654e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/inputs/reactHookForm/agGridTable/csvUploader/CsvUploader.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import React, { useMemo, useState } from 'react';
2020
import { FormattedMessage, useIntl } from 'react-intl';
2121
import CsvDownloader from 'react-csv-downloader';
2222
import { useWatch } from 'react-hook-form';
23-
import { FieldConstants } from '../../../../../utils/constants/fieldConstants';
24-
import { CancelButton } from '../../utils/CancelButton';
23+
import { FieldConstants, GsLang, LANG_FRENCH } from '../../../../../utils';
24+
import { CancelButton } from '../../utils';
2525

2626
export interface CsvUploaderProps {
2727
name: string;
@@ -34,6 +34,7 @@ export interface CsvUploaderProps {
3434
validateData: (rows: string[][]) => boolean;
3535
getDataFromCsv: any;
3636
useFieldArrayOutput: any;
37+
language: GsLang;
3738
}
3839

3940
export function CsvUploader({
@@ -47,6 +48,7 @@ export function CsvUploader({
4748
validateData = () => true,
4849
getDataFromCsv,
4950
useFieldArrayOutput,
51+
language,
5052
}: Readonly<CsvUploaderProps>) {
5153
const watchTableValues = useWatch({ name });
5254
const { append, replace } = useFieldArrayOutput;
@@ -178,7 +180,11 @@ export function CsvUploader({
178180
<Grid container spacing={2}>
179181
<Grid container item>
180182
<Grid item xs={6}>
181-
<CsvDownloader datas={data} filename={fileName} separator=",">
183+
<CsvDownloader
184+
datas={data}
185+
filename={fileName}
186+
separator={language === LANG_FRENCH ? ';' : ','}
187+
>
182188
<Button variant="contained">
183189
<FormattedMessage id="GenerateCSV" />
184190
</Button>
@@ -194,6 +200,7 @@ export function CsvUploader({
194200
config={{
195201
// We use | for multi values in one cell, then we remove it from the default value for this config, to avoid delimiter autodetection
196202
delimitersToGuess: [',', ' ', ';', RECORD_SEP, UNIT_SEP],
203+
delimiter: language === LANG_FRENCH ? ';' : ',',
197204
}}
198205
>
199206
{({ getRootProps, acceptedFile }: any) => (

0 commit comments

Comments
 (0)