index.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import {
  5. useCSVDownloader,
  6. } from 'react-papaparse'
  7. import { useTranslation } from 'react-i18next'
  8. import cn from '@/utils/classnames'
  9. import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'
  10. import Button from '@/app/components/base/button'
  11. export type IResDownloadProps = {
  12. isMobile: boolean
  13. values: Record<string, string>[]
  14. }
  15. const ResDownload: FC<IResDownloadProps> = ({
  16. isMobile,
  17. values,
  18. }) => {
  19. const { t } = useTranslation()
  20. const { CSVDownloader, Type } = useCSVDownloader()
  21. return (
  22. <CSVDownloader
  23. className="block cursor-pointer"
  24. type={Type.Link}
  25. filename={'result'}
  26. bom={true}
  27. config={{
  28. // delimiter: ';',
  29. }}
  30. data={values}
  31. >
  32. <Button className={cn('space-x-2 bg-white', isMobile ? '!p-0 !w-8 justify-center' : '')}>
  33. <DownloadIcon className='w-4 h-4 text-[#155EEF]' />
  34. {!isMobile && <span className='text-[#155EEF]'>{t('common.operation.download')}</span>}
  35. </Button>
  36. </CSVDownloader>
  37. )
  38. }
  39. export default React.memo(ResDownload)