1 import React, { useState } from 'react';
3 import { c } from 'ttag';
5 import { Button } from '@proton/atoms';
6 import { Icon } from '@proton/components';
7 import clsx from '@proton/utils/clsx';
9 import { useActiveShare } from '../../../../hooks/drive/useActiveShare';
10 import { useFileDrop } from '../../../../hooks/drive/useFileDrop';
11 import { useFileUploadInput, useFolderUploadInput } from '../../../../store/_uploads/useUploadInput';
12 import { Actions, countActionWithTelemetry } from '../../../../utils/telemetry';
13 import { Container } from '../Container';
14 import type { OnboardingProps } from '../interface';
16 import './UploadStep.scss';
18 export const UploadStep = ({ onNext }: OnboardingProps) => {
19 const { activeFolder } = useActiveShare();
20 const { handleDrop } = useFileDrop({
21 shareId: activeFolder.shareId,
22 linkId: activeFolder.linkId,
23 onFileUpload: () => countActionWithTelemetry(Actions.OnboardingV2UploadFile),
24 onFolderUpload: () => countActionWithTelemetry(Actions.OnboardingV2UploadFolder),
27 const [isDragged, setIsDragged] = useState(false);
29 const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
35 const handleDragLeave = () => {
41 title={c('Onboarding Info').t`Upload your first file`}
42 subtitle={c('Onboarding Info').t`Secure your files`}
47 isDragged && 'bg-weak',
48 'relative ratio-square w-full p-4',
49 'rounded-xl border border-dashed border-strong',
50 'flex flex-column gap-4 justify-center items-center',
52 onDragExit={handleDragLeave}
53 onDragLeave={handleDragLeave}
54 onDragEnter={handleDragOver}
55 onDragOver={handleDragOver}
62 <Icon size={6} name="arrow-up-line" />
63 <span className="text-lg">{c('Onboarding Info').t`Drag and drop your files here`}</span>
65 <div className="absolute bottom-0 mb-8 color-weak">
66 <Icon name="lock-open-check-filled" className="mr-2" />
67 <span>{c('Info').t`End-to-end encrypted`}</span>
74 .t`Protect your financial documents, ID cards, project files, photos, and more with end-to-end encryption.`}
80 export const UploadStepButtons = ({ onNext }: OnboardingProps) => {
81 const { activeFolder } = useActiveShare();
84 handleClick: fileClick,
85 handleChange: fileChange,
86 } = useFileUploadInput(activeFolder.shareId, activeFolder.linkId);
88 inputRef: folderInput,
89 handleClick: folderClick,
90 handleChange: folderChange,
91 } = useFolderUploadInput(activeFolder.shareId, activeFolder.linkId);
94 <div className="w-full flex justify-space-between">
101 countActionWithTelemetry(Actions.OnboardingV2UploadFile);
111 countActionWithTelemetry(Actions.OnboardingV2UploadFolder);
122 countActionWithTelemetry(Actions.OnboardingV2UploadSkip);
126 {c('Onboarding Action').t`Skip for now`}
129 <div className="flex gap-2">
131 className="flex items-center justify-center gap-2"
134 onClick={folderClick}
136 <Icon name="folder-arrow-up" />
137 <span>{c('Onboarding Action').t`Upload folder`}</span>
140 className="flex items-center justify-center gap-2"
145 <Icon name="file-arrow-in-up" />
146 <span>{c('Onboarding Action').t`Upload file`}</span>