1 import { useState } from 'react';
3 import { c, msgid } from 'ttag';
5 import { Button } from '@proton/atoms';
6 import type { ModalStateProps } from '@proton/components';
15 } from '@proton/components';
16 import { useLoading } from '@proton/hooks';
17 import { DRIVE_APP_NAME } from '@proton/shared/lib/constants';
18 import noop from '@proton/utils/noop';
22 onSubmit: () => Promise<unknown>;
26 const DeleteLockedVolumesConfirmModal = ({
31 }: Props & ModalStateProps) => {
32 const [isChecked, setIsChecked] = useState(false);
33 const [isLoading, withLoading] = useLoading();
35 const modalTitle = c('Label').ngettext(msgid`Delete drive?`, `Delete drives?`, volumeCount);
37 const warningTitle = c('Label').t`This will permanently delete all files in your locked drive.`;
38 const warningInfo = c('Info')
39 .t`Note: data may still be available locally on devices where you have installed ${DRIVE_APP_NAME}.`;
40 const confirmationText = c('Label').t`Yes, I want to permanently delete my old files`;
42 const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
43 setIsChecked(e.target.checked);
46 const handleSubmit = (e: React.FormEvent) => {
48 return withLoading(onSubmit());
55 disableCloseOnEscape={isLoading}
56 onSubmit={handleSubmit}
59 <ModalTwoHeader title={modalTitle} />
61 <Alert type="warning" className="mb-8">
63 <strong>{warningTitle}</strong>
67 <Checkbox onChange={handleChange}>{confirmationText}</Checkbox>
70 <Button type="button" onClick={onClose}>
73 <Button color="danger" type="submit" disabled={!isChecked} loading={isLoading}>
74 {c('Action').t`Delete`}
81 export default DeleteLockedVolumesConfirmModal;
83 export const useDeleteLockedVolumesConfirmModal = () => {
84 return useModalTwoStatic(DeleteLockedVolumesConfirmModal);