import { ReactElement, useState } from 'react' import './DeleteFileModal.scss' import { Button } from '../Button/Button' import { createPortal } from 'react-dom' import TrashIcon from 'remixicon-react/DeleteBin6LineIcon' import AlertIcon from 'remixicon-react/AlertLineIcon' import Radio from '@material-ui/core/Radio' import FormControlLabel from '@material-ui/core/FormControlLabel' import FormControl from '@material-ui/core/FormControl' import { FileAction } from '../../constants/transfers' interface DeleteFileModalProps { name?: string names?: string[] currentDriveName?: string onCancelClick: () => void onProceed: (action: FileAction) => void } export function DeleteFileModal({ name, names, currentDriveName, onCancelClick, onProceed, }: DeleteFileModalProps): ReactElement { const [value, setValue] = useState(FileAction.Trash) const modalRoot = document.querySelector('.fm-main') || document.body const isBulk = Array.isArray(names) && names.length > 0 const count = isBulk ? names.length : 1 const headerText = isBulk ? `Delete ${count} file${count > 1 ? 's' : ''}?` : `Delete ${name}?` const subjectNoun = isBulk ? 'selected file(s)' : 'this file' return createPortal(
{headerText}
{isBulk && (
    {names.map(n => (
  • {n}
  • ))}
)}
setValue(FileAction.Trash)} />} label={
Move to Trash
e.preventDefault()}> Moves {subjectNoun} to the trash. It will still take up space on{' '} {currentDriveName ?? 'this drive'} and expire along with it. You can restore it later.
} />
setValue(FileAction.Forget)} />} label={
Forget
e.preventDefault()}> Removes {subjectNoun} from your view. The data will remain on Swarm until{' '} {currentDriveName ?? 'the drive'} expires. This action cannot be easily undone.
} />
setValue(FileAction.Destroy)} /> } label={
Destroy entire drive {currentDriveName ? `‘${currentDriveName}’` : ''} to delete this{' '} {subjectNoun}
e.preventDefault()}> Warning: This will make all files on this drive inaccessible. This action is irreversible.
} />
, modalRoot, ) }