import type { UploadFileDto } from '@/types/user.ts'
import FileThumbnail from '@/components/file/FileThumbnail.vue'
import { NEmpty, NFlex } from 'naive-ui'

export function uploadFilesCom(files: UploadFileDto[]) {
  if (files.length === 0) {
    return <NEmpty description="你还没有上传任何文件。" size="large" />
  }
  return (
    <NFlex>
      {files.map((file: UploadFileDto) => {
        return <FileThumbnail size={120} file={file}></FileThumbnail>
      })}
    </NFlex>
  )
}

export function selectFilesCom(
  files: UploadFileDto[],
  onSelect: (file: UploadFileDto) => boolean,
  onRemove: (file: UploadFileDto) => boolean,
) {
  if (files.length === 0) {
    return <NEmpty description="你还没有上传任何文件。" size="large" />
  }
  return (
    <NFlex>
      {files.map((file: UploadFileDto) => {
        return (
          <FileThumbnail
            size={82}
            file={file}
            enableSelect
            onSelect={onSelect}
            onRemove={onRemove}
          ></FileThumbnail>
        )
      })}
    </NFlex>
  )
}
