Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.2 KB
Raw Blame
'use client'
import type { FC } from 'react'
import { Button } from '@langgenius/dify-ui/button'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { RiDownloadLine } from '@remixicon/react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { useCSVDownloader } from 'react-papaparse'

type IResDownloadProps = {
  compact: boolean
  values: Record<string, string>[]
}

const ResDownload: FC<IResDownloadProps> = ({ compact, values }) => {
  const { t } = useTranslation(['common'])
  const { CSVDownloader, Type } = useCSVDownloader()

  return (
    <CSVDownloader
      className="block cursor-pointer"
      type={Type.Link}
      filename="result"
      bom={true}
      config={{
        // delimiter: ';',
      }}
      data={values}
    >
      {compact && (
        <IconButton aria-label={t(($) => $['operation.download'], { ns: 'common' })}>
          <RiDownloadLine aria-hidden="true" className="size-4" />
        </IconButton>
      )}
      {!compact && (
        <Button>
          <RiDownloadLine className="size-4" />
          <span>{t(($) => $['operation.download'], { ns: 'common' })}</span>
        </Button>
      )}
    </CSVDownloader>
  )
}
export default React.memo(ResDownload)