Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added account deletion process in settings #922

Draft
wants to merge 3 commits into
base: master-qa
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.emobility">

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="mailto" />
</intent>
</queries>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
Expand Down
1 change: 1 addition & 0 deletions ios/eMobility/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string>kakaomap</string>
<string>szn-mapy</string>
<string>mapsme</string>
<string>mailto</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
Expand Down
7 changes: 7 additions & 0 deletions src/I18n/languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilometers",
"miles": "Miles",
"automatic": "Automatic"
},
"settingsDeleteAccount": {
"deleteAccount": "Delete account",
"deleteAccountText": "Send an email to {{contactEmail}} to ask for your account to be deleted. The process can take up to five working days. You will be informed by email when your request is completed",
"deleteAccountEmailSubject": "Account deletion request on tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "I would like to request the deletion of my account on the tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Open email app"
}
}
7 changes: 7 additions & 0 deletions src/I18n/languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilometer",
"miles": "Meilen",
"automatic": "Automatik"
},
"settingsDeleteAccount": {
"deleteAccount": "Delete account",
"deleteAccountText": "Send an email to {{contactEmail}} to ask for your account to be deleted. The process can take several working days. You will be informed by email when your request is completed",
"deleteAccountEmailSubject": "Account deletion request on tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "I would like to request the deletion of my account on the tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Open email app"
}
}
7 changes: 7 additions & 0 deletions src/I18n/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilometers",
"miles": "Miles",
"automatic": "Automatic"
},
"settingsDeleteAccount": {
"deleteAccount": "Delete account",
"deleteAccountText": "Send an email to {{contactEmail}} to ask for your account to be deleted. The process can take several working days. You will be informed by email when your request is completed",
"deleteAccountEmailSubject": "Account deletion request on tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "I would like to request the deletion of my account on the tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Open email app"
}
}
7 changes: 7 additions & 0 deletions src/I18n/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilometers",
"miles": "Miles",
"automatic": "Automatic"
},
"settingsDeleteAccount": {
"deleteAccount": "Delete account",
"deleteAccountText": "Send an email to {{contactEmail}} to ask for your account to be deleted. The process can take several working days. You will be informed by email when your request is completed",
"deleteAccountEmailSubject": "Account deletion request on tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "I would like to request the deletion of my account on the tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Open email app"
}
}
7 changes: 7 additions & 0 deletions src/I18n/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilomètres",
"miles": "Miles",
"automatic": "Automatique"
},
"settingsDeleteAccount": {
"deleteAccount": "Supprimer mon compte",
"deleteAccountText": "Envoyez un e-mail à {{contactEmail}} pour demander la suppression de votre compte. La procédure peut prendre plusieurs jours. Vous serez informé(e) par e-mail une fois celle-ci achevée",
"deleteAccountEmailSubject": "Demande de suppression de compte sur le tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "Je souhaite supprimer mon compte sur le tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Ouvrir ma messagerie"
}
}
7 changes: 7 additions & 0 deletions src/I18n/languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilometers",
"miles": "Miles",
"automatic": "Automatic"
},
"settingsDeleteAccount": {
"deleteAccount": "Delete account",
"deleteAccountText": "Send an email to {{contactEmail}} to ask for your account to be deleted. The process can take several working days. You will be informed by email when your request is completed",
"deleteAccountEmailSubject": "Account deletion request on tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "I would like to request the deletion of my account on the tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Open email app"
}
}
7 changes: 7 additions & 0 deletions src/I18n/languages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,5 +548,12 @@
"kilometers": "Kilometers",
"miles": "Miles",
"automatic": "Automatic"
},
"settingsDeleteAccount": {
"deleteAccount": "Delete account",
"deleteAccountText": "Send an email to {{contactEmail}} to ask for your account to be deleted. The process can take several working days. You will be informed by email when your request is completed",
"deleteAccountEmailSubject": "Account deletion request on tenant {{tenantSubdomain}}",
"deleteAccountEmailBody": "I would like to request the deletion of my account on the tenant {{tenantSubdomain}}\nEmail: {{userEmail}}\nuserID: {{userID}}",
"openEmailApp": "Open email app"
}
}
2 changes: 2 additions & 0 deletions src/config/Configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default class Configuration {
public static readonly AWS_REST_ENDPOINT_PROD = `${Configuration.SERVER_URL_PREFIX}e-mobility-group.com`;
public static readonly AWS_REST_ENDPOINT_QA = 'https://qa-e-mobility-group.com';

public static readonly DPO_EMAIL = '[email protected]';

public static readonly CAPTCHA_SITE_KEY = '6Lcmr6EUAAAAAIyn3LasUzk-0MpH2R1COXFYsxNw';
public static readonly DEFAULT_ENDPOINT_CLOUD_ID = 'aws';
public static readonly ENDPOINT_CLOUDS: EndpointCloud[] = [
Expand Down
25 changes: 12 additions & 13 deletions src/provider/CentralServerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { BillingSettings } from '../types/Setting';
import Site from '../types/Site';
import SiteArea from '../types/SiteArea';
import Tag from '../types/Tag';
import { TenantConnection } from '../types/Tenant';
import Tenant, { TenantConnection } from '../types/Tenant';
import Transaction from '../types/Transaction';
import User, { UserDefaultTagCar } from '../types/User';
import UserToken from '../types/UserToken';
Expand Down Expand Up @@ -567,6 +567,17 @@ export default class CentralServerProvider {
return result.data;
}

public async getCurrentTenant(): Promise<Tenant> {
this.debugMethod('getTenant');
const result = await this.axiosInstance.get(
this.buildRestEndpointUrl(RESTServerRoute.REST_TENANT, {id: this.getUserInfo()?.tenantID}),
{
headers: this.buildSecuredHeaders()
}
);
return result?.data;
}

public async getSiteAreas(
params = {},
paging: PagingParams = Constants.DEFAULT_PAGING,
Expand Down Expand Up @@ -623,18 +634,6 @@ export default class CentralServerProvider {
return result.data;
}

public async softStopTransaction(transactionID: number): Promise<ActionResponse> {
this.debugMethod('softStopTransaction');
const result = await this.axiosInstance.put<any>(
this.buildRestEndpointUrl(RESTServerRoute.REST_TRANSACTION_SOFT_STOP, { id: transactionID }),
{},
{
headers: this.buildSecuredHeaders()
}
);
return result.data;
}

public async reset(chargingStationID: string, type: 'Soft' | 'Hard'): Promise<ActionResponse> {
this.debugMethod('reset');
const url = this.buildRestEndpointUrl(RESTServerRoute.REST_CHARGING_STATIONS_RESET, { id: chargingStationID });
Expand Down
61 changes: 54 additions & 7 deletions src/screens/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Text, View } from 'react-native';
import { Linking, SafeAreaView, Text, View } from 'react-native';
import computeStyleSheet from './SettingsStyles';
import HeaderComponent from '../../components/header/HeaderComponent';
import BaseScreen from '../base-screen/BaseScreen';
Expand All @@ -9,20 +9,31 @@ import SelectDropdown from 'react-native-select-dropdown';
import I18n from 'i18n-js';
import SecuredStorage from '../../utils/SecuredStorage';
import I18nManager from '../../I18n/I18nManager';
import { Button } from 'react-native-elements';
import { Icon } from 'native-base';
import Entypo from 'react-native-vector-icons/Entypo';
import { scale } from 'react-native-size-matters';
import UserToken from '../../types/UserToken';

export interface Props extends BaseProps{}

interface State {
distanceUnit: DistanceUnit;
canHandleEmailURL: boolean;
tenantEmail: string;
}

export default class Settings extends BaseScreen<Props, State> {
public state: State;
private tenantSubdomain: string;
private user: UserToken;

public constructor(props: Props) {
super(props);
this.state = {
distanceUnit: null
distanceUnit: null,
canHandleEmailURL: false,
tenantEmail: null
};
}

Expand All @@ -31,15 +42,26 @@ export default class Settings extends BaseScreen<Props, State> {
const settings = await SecuredStorage.getSettings();
const savedDistanceUnit = settings.distanceUnit;
const distanceUnit = savedDistanceUnit ?? DistanceUnit.AUTOMATIC;
this.setState({distanceUnit});
const tenantData = await this.centralServerProvider?.getCurrentTenant();
let canHandleEmailURL = false;
const tenantEmail = tenantData?.email;
this.tenantSubdomain = tenantData?.subdomain;
this.user = this.centralServerProvider?.getUserInfo();
if (tenantEmail) {
try {
canHandleEmailURL = await Linking.canOpenURL(this.buildEmailURL());
} catch ( e ) {
}
}
this.setState({distanceUnit, canHandleEmailURL, tenantEmail});
}


public render() {
const style = computeStyleSheet();
const { distanceUnit } = this.state;
const { distanceUnit, canHandleEmailURL, tenantEmail } = this.state;
return (
<View style={style.container}>
<SafeAreaView style={style.container}>
<HeaderComponent containerStyle={style.headerContainer} navigation={this.props.navigation} title={I18n.t('sidebar.settings')} backArrow={true} />
<View style={style.content}>
<View style={style.settingSection}>
Expand All @@ -58,15 +80,40 @@ export default class Settings extends BaseScreen<Props, State> {
<View style={style.selectDropdownRowContainer}>
<Text style={style.selectDropdownRowText}>{I18n.t(`settingsDistanceUnit.${item.toString()}`)}</Text>
</View>
) } />
)}
/>
</View>
{tenantEmail && (
<View style={style.settingSection}>
<Text style={[style.settingLabel, style.deleteAccountLabel]}>{I18n.t('settingsDeleteAccount.deleteAccount')}</Text>
<Text style={style.deleteAccountText}>{I18n.t('settingsDeleteAccount.deleteAccountText', {contactEmail: tenantEmail})}</Text>
{canHandleEmailURL && (
<Button
containerStyle={style.deleteAccountButtonContainer}
buttonStyle={style.deleteAccountButton}
titleStyle={style.deleteAccountButtonText}
onPress={() => void Linking.openURL(this.buildEmailURL())}
title={I18n.t('settingsDeleteAccount.openEmailApp')}
icon={<Icon style={style.buttonIcon} size={scale(18)} as={Entypo} name={'paper-plane'} />}
/>
)}
</View>
)}
</View>
</View>
</SafeAreaView>
);
}

private async onDistanceUnitSelected(distanceUnit: DistanceUnit): Promise<void> {
I18nManager.switchDistanceUnit(distanceUnit);
await SecuredStorage.saveSettingsValues({distanceUnit});
}

private buildEmailURL(): string {
const { tenantEmail } = this.state;
const tenantSubdomain = this.tenantSubdomain;
const userEmail = this.user?.email;
const userID = this.user?.id;
return `mailto:${tenantEmail}?subject=${I18n.t('settingsDeleteAccount.deleteAccountEmailSubject', {tenantSubdomain})}&body=${I18n.t('settingsDeleteAccount.deleteAccountEmailBody', {tenantSubdomain, userEmail, userID})}`;
}
}
29 changes: 28 additions & 1 deletion src/screens/settings/SettingsStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default function computeStyleSheet(): StyleSheet.NamedStyles<any> {
content: {
flex: 1,
alignItems: 'center',
width: '100%'
width: '100%',
justifyContent: 'space-between'
},
headerContainer: {
marginBottom: '10@s'
Expand Down Expand Up @@ -54,6 +55,32 @@ export default function computeStyleSheet(): StyleSheet.NamedStyles<any> {
color: commonColor.textColor,
fontWeight: 'bold',
paddingVertical: '4@s'
},
deleteAccountLabel: {
color: commonColor.danger,
opacity: 0.8
},
deleteAccountButtonContainer: {
borderRadius: '8@s',
width: '100%',
marginVertical: '10@s'
},
deleteAccountButton: {
backgroundColor: commonColor.selectFieldBackgroundColor
},
deleteAccountButtonText: {
color: commonColor.textColor
},
deleteAccountText: {
padding: '8@s',
backgroundColor: commonColor.listItemBackground,
borderRadius: '8@s',
color: commonColor.textColor,
marginTop: '5@s'
},
buttonIcon: {
marginRight: '10@s',
color: commonColor.textColor
}
});
const portraitStyles = {};
Expand Down
6 changes: 5 additions & 1 deletion src/types/Tenant.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import CreatedUpdatedProps from './CreatedUpdatedProps';
import ListItem from './ListItem';
import Address from './Address';

export default interface Tenant extends CreatedUpdatedProps, ListItem {
id: string;
name: string;
email: string;
address: Address;
subdomain: string;
components: TenantComponent;
components?: TenantComponent;
logo: string;
}

export interface TenantComponent {
Expand Down