1 import type { FC } from 'react';
3 import { c } from 'ttag';
5 import { CircleLoader } from '@proton/atoms';
6 import { Icon, ToolbarButton } from '@proton/components';
7 import useLoading from '@proton/hooks/useLoading';
8 import noop from '@proton/utils/noop';
10 import type { PhotoLink } from '../../../../store';
13 selectedLinks: PhotoLink[];
14 requestDownload: (linkIds: string[]) => Promise<void>;
17 export const PhotosDownloadButton: FC<Props> = ({ requestDownload, selectedLinks }) => {
18 const [loading, withLoading] = useLoading();
20 const onClick = () => {
21 const linkIds = selectedLinks.map((link) => link.linkId);
23 withLoading(requestDownload(linkIds)).catch(noop);
28 title={c('Action').t`Download`}
30 icon={loading ? <CircleLoader /> : <Icon name="arrow-down-line" alt={c('Action').t`Download`} />}
32 data-testid="toolbar-download"