Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Account: Add setup for account app
Browse files Browse the repository at this point in the history
  • Loading branch information
tbergquist-godaddy authored and RobinCsl committed Aug 9, 2019
1 parent 66bb5d1 commit 35784b0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/account/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow

export { default as AccountSettings } from './src/appRegistry/AccountSettings';
12 changes: 12 additions & 0 deletions app/account/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@kiwicom/mobile-account",
"version": "0.0.1",
"private": true,
"main": "index.js",
"dependencies": {
"@kiwicom/mobile-shared": "*"
},
"peerDependencies": {
"react": "*"
}
}
18 changes: 18 additions & 0 deletions app/account/src/appRegistry/AccountSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @flow strict

import * as React from 'react';
import { WithNativeNavigation, Text, Translation } from '@kiwicom/mobile-shared';

type Props = {||};

class AccountSettings extends React.Component<Props> {
render() {
return (
<Text>
<Translation passThrough="account" />
</Text>
);
}
}

export default WithNativeNavigation(AccountSettings, 'AccountSettings');
3 changes: 2 additions & 1 deletion app/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@kiwicom/mobile-shared": "^0",
"@kiwicom/mobile-localization": "^0",
"@kiwicom/mobile-orbit": "^0",
"@kiwicom/mobile-utils": "^0"
"@kiwicom/mobile-utils": "^0",
"@kiwicom/mobile-account": "^0"
},
"peerDependencies": {
"react": "^16",
Expand Down
4 changes: 4 additions & 0 deletions app/core/src/navigation/stacks/ProfileStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import { StackNavigator, StackNavigatorOptions } from '@kiwicom/mobile-navigation';
import ProfileScreen from '@kiwicom/mobile-profile';
import { AccountSettings } from '@kiwicom/mobile-account';

export default StackNavigator(
{
Profile: {
screen: ProfileScreen,
},
AccountSettings: {
screen: AccountSettings,
},
},
{
...StackNavigatorOptions,
Expand Down
16 changes: 15 additions & 1 deletion app/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
StyleSheet,
} from '@kiwicom/mobile-shared';
import AsyncStorage from '@react-native-community/async-storage';
import { withNavigation, type NavigationType } from '@kiwicom/mobile-navigation';

import Login from './components/authentication/Login';
import Logout from './components/authentication/Logout';
Expand All @@ -19,7 +20,11 @@ type State = {|
isLoggedIn: boolean,
|};

export default class LoginScreen extends React.Component<{||}, State> {
type Props = {|
+navigation: NavigationType,
|};

class LoginScreen extends React.Component<Props, State> {
state = {
isLoggedIn: false,
};
Expand All @@ -29,12 +34,18 @@ export default class LoginScreen extends React.Component<{||}, State> {
const simpleTokenData = await AsyncStorage.getItem('mobile:MMB-Simple-Token');
if (token != null || simpleTokenData != null) {
this.setState({ isLoggedIn: true });
this.navigateToAccountSettings();
}
};

onLogin = (token: string) => {
AsyncStorage.setItem('mobile:MMB-Token', token);
this.setState({ isLoggedIn: true });
this.navigateToAccountSettings();
};

navigateToAccountSettings = () => {
this.props.navigation.navigate('AccountSettings');
};

onSimpleLogin = (simpleToken: string, bookingId: string) => {
Expand All @@ -46,6 +57,7 @@ export default class LoginScreen extends React.Component<{||}, State> {
}),
);
this.setState({ isLoggedIn: true });
this.navigateToAccountSettings();
};

onLogout = () => {
Expand Down Expand Up @@ -92,3 +104,5 @@ const styles = StyleSheet.create({
marginTop: 20,
},
});

export default withNavigation(LoginScreen);
3 changes: 2 additions & 1 deletion app/profile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"@kiwicom/mobile-localization": "^0",
"@kiwicom/mobile-shared": "^0",
"@kiwicom/mobile-orbit": "^0",
"@kiwicom/mobile-relay": "^0"
"@kiwicom/mobile-relay": "^0",
"@kiwicom/mobile-navigation": "^0"
},
"peerDependencies": {
"react": "^16",
Expand Down
3 changes: 2 additions & 1 deletion packages/navigation/types/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ type CoreStackNavigatorRouteNames =
| 'HotelsPackage'
| 'NewHotelsPackage'
| 'SingleHotelPackage'
| 'MMBPackage';
| 'MMBPackage'
| 'AccountSettings';

type HotelsStackNavigatorNames =
| 'AllHotelsMap'
Expand Down

0 comments on commit 35784b0

Please sign in to comment.