|
@@ -1,82 +1,28 @@
|
|
|
import React, { useState } from 'react';
|
|
|
import { View, Image, Linking, Text } from 'react-native';
|
|
|
-import { CommonActions, useNavigation } from '@react-navigation/native';
|
|
|
+import { useNavigation } from '@react-navigation/native';
|
|
|
|
|
|
-import { WarningModal } from '../WarningModal';
|
|
|
import { MenuButton } from '../MenuButton';
|
|
|
import { styles } from './styles';
|
|
|
import { StoreType, storage } from 'src/storage';
|
|
|
-import { useDeleteUserMutation } from '@api/app';
|
|
|
import { Colors } from 'src/theme';
|
|
|
import { NAVIGATION_PAGES } from 'src/types';
|
|
|
|
|
|
import MailIcon from '../../../assets/icons/mail.svg';
|
|
|
import DocumentIcon from '../../../assets/icons/document.svg';
|
|
|
-import ExitIcon from '../../../assets/icons/exit.svg';
|
|
|
-import UserXMark from '../../../assets/icons/user-xmark.svg';
|
|
|
import InfoIcon from 'assets/icons/info-solid.svg';
|
|
|
import BellIcon from 'assets/icons/notifications/bell-solid.svg';
|
|
|
import SharingIcon from 'assets/icons/location-sharing.svg';
|
|
|
import BagIcon from 'assets/icons/bag.svg';
|
|
|
import OfflineIcon from 'assets/icons/map-offline.svg';
|
|
|
+import GearIcon from 'assets/icons/gear.svg';
|
|
|
|
|
|
import { APP_VERSION } from 'src/constants';
|
|
|
-import { useMessagesStore } from 'src/stores/unreadMessagesStore';
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
-import { useFriendsNotificationsStore } from 'src/stores/friendsNotificationsStore';
|
|
|
|
|
|
export const MenuDrawer = (props: any) => {
|
|
|
- const { mutate: deleteUser } = useDeleteUserMutation();
|
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
|
const navigation = useNavigation();
|
|
|
- const [modalInfo, setModalInfo] = useState({
|
|
|
- visible: false,
|
|
|
- type: 'confirm',
|
|
|
- message: '',
|
|
|
- action: () => {}
|
|
|
- });
|
|
|
- const updateNotificationStatus = useFriendsNotificationsStore(
|
|
|
- (state) => state.updateNotificationStatus
|
|
|
- );
|
|
|
- const updateUnreadMessagesCount = useMessagesStore((state) => state.updateUnreadMessagesCount);
|
|
|
-
|
|
|
- const openModal = (type: string, message: string, action: any) => {
|
|
|
- setModalInfo({
|
|
|
- visible: true,
|
|
|
- type,
|
|
|
- message,
|
|
|
- action
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- const closeModal = () => {
|
|
|
- setModalInfo({ ...modalInfo, visible: false });
|
|
|
- };
|
|
|
-
|
|
|
- const handleLogout = () => {
|
|
|
- storage.remove('token');
|
|
|
- storage.remove('uid');
|
|
|
- storage.remove('currentUserData');
|
|
|
- storage.remove('showNomads');
|
|
|
- storage.remove('filterSettings');
|
|
|
- storage.remove('visitedRegions');
|
|
|
- storage.remove('visitedCountries');
|
|
|
- storage.remove('visitedDares');
|
|
|
- storage.remove('visitedSeries');
|
|
|
-
|
|
|
- updateNotificationStatus();
|
|
|
- updateUnreadMessagesCount();
|
|
|
- navigation.dispatch(
|
|
|
- CommonActions.reset({
|
|
|
- index: 1,
|
|
|
- routes: [{ name: NAVIGATION_PAGES.WELCOME }]
|
|
|
- })
|
|
|
- );
|
|
|
- };
|
|
|
-
|
|
|
- const handleDeleteAccount = () => {
|
|
|
- deleteUser({ token }, { onSuccess: handleLogout });
|
|
|
- };
|
|
|
|
|
|
return (
|
|
|
<>
|
|
@@ -149,28 +95,24 @@ export const MenuDrawer = (props: any) => {
|
|
|
|
|
|
<View style={styles.bottomMenu}>
|
|
|
{token ? (
|
|
|
- <>
|
|
|
- <MenuButton
|
|
|
- label="Logout"
|
|
|
- icon={<ExitIcon fill={Colors.RED} width={20} height={20} />}
|
|
|
- red={true}
|
|
|
- buttonFn={() =>
|
|
|
- openModal('confirm', 'Are you sure you want to logout?', handleLogout)
|
|
|
- }
|
|
|
- />
|
|
|
- <MenuButton
|
|
|
- label="Delete account"
|
|
|
- icon={<UserXMark fill={Colors.RED} width={20} height={20} />}
|
|
|
- red={true}
|
|
|
- buttonFn={() =>
|
|
|
- openModal(
|
|
|
- 'confirm',
|
|
|
- 'Are you sure you want to delete your account?',
|
|
|
- handleDeleteAccount
|
|
|
- )
|
|
|
- }
|
|
|
- />
|
|
|
- </>
|
|
|
+ <MenuButton
|
|
|
+ label="Manage account"
|
|
|
+ icon={
|
|
|
+ <GearIcon
|
|
|
+ fill={Colors.DARK_BLUE}
|
|
|
+ width={20}
|
|
|
+ height={20}
|
|
|
+ style={{ alignSelf: 'center' }}
|
|
|
+ />
|
|
|
+ }
|
|
|
+ red={false}
|
|
|
+ buttonFn={() =>
|
|
|
+ // @ts-ignore
|
|
|
+ navigation.navigate(NAVIGATION_PAGES.MENU_DRAWER, {
|
|
|
+ screen: NAVIGATION_PAGES.EDIT_PERSONAL_INFO
|
|
|
+ })
|
|
|
+ }
|
|
|
+ />
|
|
|
) : null}
|
|
|
|
|
|
<View style={{ gap: 6, marginTop: 16, marginBottom: 16 }}>
|
|
@@ -178,17 +120,6 @@ export const MenuDrawer = (props: any) => {
|
|
|
</View>
|
|
|
</View>
|
|
|
</SafeAreaView>
|
|
|
-
|
|
|
- <WarningModal
|
|
|
- isVisible={modalInfo.visible}
|
|
|
- onClose={closeModal}
|
|
|
- type={modalInfo.type}
|
|
|
- message={modalInfo.message}
|
|
|
- action={() => {
|
|
|
- modalInfo.action();
|
|
|
- closeModal();
|
|
|
- }}
|
|
|
- />
|
|
|
</>
|
|
|
);
|
|
|
};
|