-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUserLogOut.tsx
110 lines (106 loc) · 3.28 KB
/
UserLogOut.tsx
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import React, { FC, ReactElement, useState } from "react";
import {
Linking,
Modal,
Pressable,
Text,
TouchableOpacity,
View,
} from "react-native";
import Styles from "./Styles";
import { useAuth } from "./context/AuthContext";
export const UserLogOut: FC<{}> = ({}): ReactElement => {
const { logOut, deleteAccount } = useAuth();
const [modalVisible, setModalVisible] = useState(false);
const [loading, setLoading] = useState(false);
const deleteUser = async () => {
setLoading(true);
setModalVisible(false);
await deleteAccount();
setLoading(false);
};
return (
<>
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
onRequestClose={() => {
setModalVisible(!modalVisible);
}}
>
<View style={Styles.centeredView}>
<View style={Styles.modalView}>
<Text style={Styles.modalTitle}>
{
"Are you sure you want to delete your account? You will lose all data"
}
</Text>
<View
style={{
display: "flex",
justifyContent: "center",
flexWrap: "nowrap",
flexDirection: "row",
}}
></View>
<Pressable
style={[Styles.modal_button, Styles.modal_buttonClose]}
onPress={deleteUser}
>
<Text style={Styles.modal_textStyle}>Delete My Account</Text>
</Pressable>
<Pressable
style={[
Styles.modal_button_custom,
Styles.modal_buttonClose_custom,
]}
onPress={() => setModalVisible(!modalVisible)}
>
<Text style={Styles.modal_textStyle}>
{"Return to Home Screen"}
</Text>
</Pressable>
</View>
</View>
</Modal>
{!loading ? (
<>
<View style={Styles.login_wrapper}>
<View style={Styles.form}>
<TouchableOpacity
onPress={() => {
Linking.openURL(
"https://join.slack.com/t/ugahacks8/shared_invite/zt-1o90h2zpt-f9uSUcdVqXHkSx6CJ_bxeg"
);
}}
>
<View style={Styles.button}>
<Text style={Styles.button_label}>{"Open Slack"}</Text>
</View>
</TouchableOpacity>
</View>
</View>
<View style={{ alignItems: "center" }}>
<View style={Styles.form}>
<TouchableOpacity onPress={logOut}>
<View style={Styles.button}>
<Text style={Styles.button_label}>{"Logout"}</Text>
</View>
</TouchableOpacity>
</View>
</View>
<View style={{ alignItems: "center", marginTop: 20 }}>
<View style={Styles.form}>
<TouchableOpacity onPress={() => setModalVisible(true)}>
<View style={Styles.button_delete}>
<Text style={Styles.button_label}>{"Delete My Account"}</Text>
</View>
</TouchableOpacity>
</View>
</View>
</>
) : null}
</>
);
};