import Upload from "zy-react-library/components/Upload";
import { parseUploadFileList, resolveUploadFileId } from "~/utils/mockUpload";

export default function FilingUpload({
  value,
  onChange,
  disabled,
  maxCount = 1,
  accept,
}) {
  const fileList = Array.isArray(value) ? value : parseUploadFileList(value);

  return (
    <Upload
      maxCount={maxCount}
      accept={accept}
      disabled={disabled}
      fileList={fileList}
      onChange={(files) => {
        if (disabled) {
          return;
        }
        onChange?.(files);
      }}
    />
  );
}

export function resolveFilingUploadUrl(files) {
  return resolveUploadFileId(files);
}
