-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathConfirmTurnOnBackupAndSyncModal.tsx
More file actions
74 lines (65 loc) · 2.41 KB
/
Copy pathConfirmTurnOnBackupAndSyncModal.tsx
File metadata and controls
74 lines (65 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React, { useRef } from 'react';
import {
BottomSheet,
IconColor,
IconName,
IconSize,
type BottomSheetRef,
} from '@metamask/design-system-react-native';
import { strings } from '../../../../../locales/i18n';
import ModalContent from '../../Notification/Modal';
import { toggleBasicFunctionality } from '../../../../actions/settings';
import { useParams } from '../../../../util/navigation/navUtils';
import { ConfirmTurnOnBackupAndSyncModalNavigateParams } from '../BackupAndSyncToggle/BackupAndSyncToggle';
import { InteractionManager } from 'react-native';
import useThunkDispatch from '../../../hooks/useThunkDispatch';
const ConfirmTurnOnBackupAndSyncModal = () => {
const bottomSheetRef = useRef<BottomSheetRef>(null);
const { enableBackupAndSync, trackEnableBackupAndSyncEvent } =
useParams<ConfirmTurnOnBackupAndSyncModalNavigateParams>();
const dispatch = useThunkDispatch();
const enableBasicFunctionality = async () => {
await dispatch(toggleBasicFunctionality(true));
};
const handleEnableBackupAndSync = () => {
bottomSheetRef.current?.onCloseBottomSheet(async () => {
InteractionManager.runAfterInteractions(async () => {
trackEnableBackupAndSyncEvent();
await enableBasicFunctionality();
await enableBackupAndSync();
});
});
};
const handleCancel = () => {
bottomSheetRef.current?.onCloseBottomSheet();
};
const turnContent = {
icon: {
name: IconName.Check,
color: IconColor.SuccessDefault,
},
bottomSheetTitle: strings('backupAndSync.enable.title'),
bottomSheetMessage: strings('backupAndSync.enable.confirmation'),
bottomSheetCTA: strings('default_settings.sheet.buttons.turn_on'),
};
return (
<BottomSheet ref={bottomSheetRef}>
<ModalContent
title={turnContent.bottomSheetTitle}
message={turnContent.bottomSheetMessage}
iconName={turnContent.icon.name}
iconColor={turnContent.icon.color}
iconSize={IconSize.Xl}
checkBoxLabel={strings('default_settings.sheet.checkbox_label')}
btnLabelCancel={strings('default_settings.sheet.buttons.cancel')}
btnLabelCta={turnContent.bottomSheetCTA}
isChecked={false}
setIsChecked={() => ({})}
hascheckBox={false}
handleCta={handleEnableBackupAndSync}
handleCancel={handleCancel}
/>
</BottomSheet>
);
};
export default ConfirmTurnOnBackupAndSyncModal;