'use client' import type { FC } from 'react' import React, { useState } from 'react' import { useCSVReader, } from 'react-papaparse' import { useTranslation } from 'react-i18next' import s from './style.module.css' import cn from '@/utils/classnames' import { Csv as CSVIcon } from '@/app/components/base/icons/src/public/files' export type Props = { onParsed: (data: string[][]) => void } const CSVReader: FC = ({ onParsed, }) => { const { t } = useTranslation() const { CSVReader } = useCSVReader() const [zoneHover, setZoneHover] = useState(false) return ( { onParsed(results.data) setZoneHover(false) }} onDragOver={(event: DragEvent) => { event.preventDefault() setZoneHover(true) }} onDragLeave={(event: DragEvent) => { event.preventDefault() setZoneHover(false) }} > {({ getRootProps, acceptedFile, }: any) => ( <>
{ acceptedFile ? (
{acceptedFile.name.replace(/.csv$/, '')} .csv
) : (
{t('share.generation.csvUploadTitle')}{t('share.generation.browse')}
)}
)}
) } export default React.memo(CSVReader)