Skip to content

Commit

Permalink
Merge branch 'delete-account-mobile' into delete-account-backend-inte…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
Andrew Radulescu committed Dec 19, 2023
2 parents 6491c57 + f7189b7 commit a6e26eb
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 5 deletions.
7 changes: 4 additions & 3 deletions mobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const expoConfig: ExpoConfig = {
},
assetBundlePatterns: ['**/*'],
ios: {
buildNumber: '1',
buildNumber: '4',
supportsTablet: true,
bundleIdentifier: 'org.commitglobal.vic',
entitlements: {
Expand All @@ -32,7 +32,7 @@ const expoConfig: ExpoConfig = {
},
},
android: {
versionCode: 1,
versionCode: 3,
adaptiveIcon: {
foregroundImage: './src/assets/images/adaptive-icon.png',
backgroundColor: '#ffffff',
Expand All @@ -55,7 +55,8 @@ const expoConfig: ExpoConfig = {
[
'expo-image-picker',
{
photosPermission: 'The app accesses your photos to let you share them with your friends.',
photosPermission: 'The app accesses your photos to allow you to set a profile picture.',
cameraPermission: 'The app accesses your camera to allow you to set a profile picture.',
},
],
],
Expand Down
9 changes: 8 additions & 1 deletion mobile/src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@
"password": "Change password",
"notification": "Notifications settings",
"information": "Information",
"logout": "Log out"
"logout": "Log out",
"delete": "Delete account"
},
"account_data": {
"title": "Date cont",
Expand Down Expand Up @@ -738,5 +739,11 @@
"rejected": "was rejected"
}
}
},
"delete_account": {
"title": "Confirm account deletion",
"paragraph": "To delete your account on the VIC application, please confirm your decision below. Deleting your account will result in the permanent loss of your data and access to the application. If you are certain about this action, click the 'Confirm Deletion' button. Keep in mind that this process is irreversible, and you will need to create a new account if you wish to use VIC in the future.",
"confirm": "Confirm Deletion",
"error": "Error on account deletion."
}
}
9 changes: 8 additions & 1 deletion mobile/src/assets/locales/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@
"password": "Schimbă parola",
"notification": "Setări notificări",
"information": "Informații",
"logout": "Log out"
"logout": "Log out",
"delete": "Sterge cont"
},
"account_data": {
"title": "Date cont",
Expand Down Expand Up @@ -733,5 +734,11 @@
"rejected": "a fost respinsă"
}
}
},
"delete_account": {
"title": "Confirma ștergerea contului",
"paragraph": "Pentru a șterge contul tău în aplicația VIC, te rugăm să confirmi decizia mai jos. Ștergerea contului va duce la pierderea permanentă a datelor tale și a accesului la aplicație. Dacă ești sigur în privința acestei acțiuni, apasă butonul 'Confirmă Ștergerea'. Menționează că acest proces este ireversibil și va trebui să creezi un cont nou dacă dorești să utilizezi VIC în viitor.",
"confirm": "Confirmă Ștergerea",
"error": "Eroare la stergerea contului"
}
}
3 changes: 3 additions & 0 deletions mobile/src/assets/svg/trash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19 7L18.1327 19.1425C18.0579 20.1891 17.187 21 16.1378 21H7.86224C6.81296 21 5.94208 20.1891 5.86732 19.1425L5 7M10 11V17M14 11V17M15 7V4C15 3.44772 14.5523 3 14 3H10C9.44772 3 9 3.44772 9 4V7M4 7H20" stroke="#6B7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`;
2 changes: 2 additions & 0 deletions mobile/src/routes/Private.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ContractRejectedReason from '../screens/ContractRejectedReason';
import PendingContracts from '../screens/PendingContracts';
import ContractHistory from '../screens/ContractHistory';
import RequestRejectedReason from '../screens/RequestRejectedReason';
import DeleteAccount from '../screens/DeleteAccount';

const { Navigator, Screen, Group } = createNativeStackNavigator();

Expand Down Expand Up @@ -60,6 +61,7 @@ const Private = () => (
<Screen name="create-volunteer" component={CreateVolunteer} />
<Screen name="rejected-contract" component={ContractRejectedReason} />
<Screen name="rejected-request" component={RequestRejectedReason} />
<Screen name="delete-account" component={DeleteAccount} />
</Group>
</Navigator>
);
Expand Down
59 changes: 59 additions & 0 deletions mobile/src/screens/DeleteAccount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import ModalLayout from '../layouts/ModalLayout';
import { Text, useTheme } from '@ui-kitten/components';
import { ALLOW_FONT_SCALLING } from '../common/constants/constants';
import { ButtonType } from '../common/enums/button-type.enum';
import { useTranslation } from 'react-i18next';
import FormLayout from '../layouts/FormLayout';
import { useDeleteAccountMutation } from '../services/user/user.service';
import { useAuth } from '../hooks/useAuth';

const DeleteAccount = ({ navigation }: any) => {
const { t } = useTranslation('delete_account');
const { logout } = useAuth();
const theme = useTheme();

const {
mutate: deleteAccount,
isLoading: isDeletingAccount,
error: deleteAccountError,
} = useDeleteAccountMutation();

const onConfirmDeleteAccount = () => {
deleteAccount(undefined, {
onSuccess: () => {
logout();
},
});
};

return (
<ModalLayout
title={t('title')}
actionsOptions={{
buttonType: ButtonType.DANGER,
onActionButtonClick: onConfirmDeleteAccount,
actionLabel: t('confirm'),
loading: isDeletingAccount,
}}
onDismiss={navigation.goBack}
>
<FormLayout>
<Text allowFontScaling={ALLOW_FONT_SCALLING} category="p1">
{`${t('paragraph')}`}
</Text>
{!!deleteAccountError && (
<Text
allowFontScaling={ALLOW_FONT_SCALLING}
style={{ color: theme['color-danger-500'] }}
category="p1"
>
{`${t('error')}`}
</Text>
)}
</FormLayout>
</ModalLayout>
);
};

export default DeleteAccount;
3 changes: 3 additions & 0 deletions mobile/src/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import bell from '../assets/svg/bell';
import identification from '../assets/svg/identification';
import information from '../assets/svg/information';
import key from '../assets/svg/key';
import trash from '../assets/svg/trash';
import logoutIcon from '../assets/svg/logout';
import user from '../assets/svg/user';
import PageLayout from '../layouts/PageLayout';
Expand All @@ -27,6 +28,7 @@ export enum SETTINGS_ROUTES {
NOTIFICATIONS_SETTINGS = 'notifications-settings',
INFORMATION = 'information',
LOGOUT = 'logout',
DELETE_ACCOUNT = 'delete-account',
}

export const SETTING_SCREENS = [
Expand All @@ -43,6 +45,7 @@ export const SETTING_SCREENS = [
route: SETTINGS_ROUTES.NOTIFICATIONS_SETTINGS,
},
{ icon: information, label: i18n.t('settings:information'), route: SETTINGS_ROUTES.INFORMATION },
{ icon: trash, label: i18n.t('settings:delete'), route: SETTINGS_ROUTES.DELETE_ACCOUNT },
{ icon: logoutIcon, label: i18n.t('settings:logout'), route: SETTINGS_ROUTES.LOGOUT },
];

Expand Down
4 changes: 4 additions & 0 deletions mobile/src/services/user/user.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ export const updateUserProfile = async (
headers: { 'Content-Type': 'multipart/form-data' },
}).then((res) => res.data);
};

export const deleteAccount = async () => {
return API.delete('/mobile/user').then((res) => res.data);
};
5 changes: 5 additions & 0 deletions mobile/src/services/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMutation, useQuery } from 'react-query';
import {
createUserProfile,
deleteAccount,
getUserProfile,
updateUserPersonalData,
updateUserProfile,
Expand Down Expand Up @@ -64,3 +65,7 @@ export const useUpdateUserProfileMutation = () => {
{ onSuccess: (data) => setUserProfile({ ...oldProfile, ...data }) },
);
};

export const useDeleteAccountMutation = () => {
return useMutation(['delete-account'], () => deleteAccount());
};

0 comments on commit a6e26eb

Please sign in to comment.