|
@@ -19,8 +19,11 @@ import UserXMark from '../../../../../assets/icons/user-xmark.svg';
|
|
|
import type { MenuButtonType } from '../../../../types/components';
|
|
|
import { StoreType, storage } from 'src/storage';
|
|
|
import { CommonActions, useNavigation } from '@react-navigation/native';
|
|
|
+import { useDeleteUserMutation } from '@api/app';
|
|
|
|
|
|
const Settings = () => {
|
|
|
+ const { mutate: deleteUser } = useDeleteUserMutation();
|
|
|
+ const token = storage.get('token', StoreType.STRING) as string;
|
|
|
const [isSubscribed, setIsSubscribed] = useState(false);
|
|
|
const [shouldOpenWarningModal, setShouldOpenWarningModal] = useState(false);
|
|
|
const navigation = useNavigation();
|
|
@@ -108,7 +111,7 @@ const Settings = () => {
|
|
|
};
|
|
|
|
|
|
const handleDeleteAccount = () => {
|
|
|
- console.log('Account deleted');
|
|
|
+ deleteUser({ token }, { onSuccess: handleLogout });
|
|
|
};
|
|
|
|
|
|
const handleSubscribe = async () => {
|
|
@@ -132,6 +135,7 @@ const Settings = () => {
|
|
|
const toggleSwitch = () => {
|
|
|
if (isSubscribed) {
|
|
|
storage.set('subscribed', false);
|
|
|
+ storage.remove('deviceToken');
|
|
|
setIsSubscribed(false);
|
|
|
} else {
|
|
|
setModalInfo({
|
|
@@ -163,7 +167,7 @@ const Settings = () => {
|
|
|
});
|
|
|
return null;
|
|
|
}
|
|
|
- token = (await Notifications.getExpoPushTokenAsync()).data;
|
|
|
+ token = (await Notifications.getDevicePushTokenAsync()).data;
|
|
|
|
|
|
if (Platform.OS === 'android') {
|
|
|
Notifications.setNotificationChannelAsync('default', {
|
|
@@ -173,6 +177,7 @@ const Settings = () => {
|
|
|
lightColor: '#FF231F7C'
|
|
|
});
|
|
|
}
|
|
|
+ storage.set('deviceToken', token);
|
|
|
|
|
|
return token;
|
|
|
}
|