Skip to content

Commit

Permalink
Release 1.4.0 (#164)
Browse files Browse the repository at this point in the history
* Update signup bonus, add alert to Forgot Password

* Update app name

* Fix alignSelf for Android

* Update alert copy

* Update Snap Points to accommodate Android

* Fix button alignment for Android

* Bump version numbers to 1.4.0

* Update sign in to log in

* Revert snap points updates

* Update account error

* Preload assets

* Add force update to logout
  • Loading branch information
wangannie authored Jun 18, 2020
1 parent 5eef95e commit aa09221
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 48 deletions.
6 changes: 6 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FontAwesome5 } from '@expo/vector-icons';
import { AppLoading } from 'expo';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import React, { useState } from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
Expand Down Expand Up @@ -40,6 +41,11 @@ export default function App(props) {

async function loadResourcesAsync() {
await Promise.all([
Asset.loadAsync([
require('./assets/images/hc_start.png'),
require('./assets/images/Marker_Focused.png'),
require('./assets/images/Marker_Resting.png'),
]),
Font.loadAsync({
// This is the icon style we use
...FontAwesome5.font,
Expand Down
10 changes: 5 additions & 5 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"expo": {
"name": "Healthy Corners Rewards",
"slug": "healthy-corners-rewards",
"name": "Healthy Corners",
"slug": "healthy-corners",
"privacy": "public",
"sdkVersion": "37.0.0",
"platforms": ["ios", "android", "web"],
"version": "1.3.0",
"version": "1.4.0",
"primaryColor": "#008550",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
Expand All @@ -21,7 +21,7 @@
"ios": {
"bundleIdentifier": "org.calblueprint.HealthyCornersRewards",
"googleServicesFile": "./GoogleService-Info.plist",
"buildNumber": "1.3.1",
"buildNumber": "1.4.0",
"supportsTablet": true,
"infoPlist": {
"NSLocationWhenInUseUsageDescription": "To find nearby stores and see what products are available.",
Expand All @@ -46,7 +46,7 @@
}
},
"permissions": ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"],
"versionCode": 5
"versionCode": 6
},
"web": {
"config": {
Expand Down
6 changes: 5 additions & 1 deletion constants/Rewards.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const rewardDollarValue = 5;
export const rewardPointValue = 500;
export const signUpBonus = 500;
// For customers who sign up directly from the app
export const newSignUpBonus = 500;

// For customers who sign up in store, then log in on the app
export const storeSignUpBonus = 250;
13 changes: 7 additions & 6 deletions navigation/DrawerContent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DrawerItemList } from '@react-navigation/drawer';
import { useFocusEffect } from '@react-navigation/native';
import { Updates } from 'expo';
import * as Analytics from 'expo-firebase-analytics';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -27,7 +28,9 @@ function DrawerContent(props) {
props.navigation.navigate('Stores');
await AsyncStorage.clear();
Sentry.configureScope((scope) => scope.clear());
props.navigation.navigate('Auth', { screen: 'LogIn' });
props.navigation.navigate('Auth', { screen: 'LogIn', initial: false });
// Temporary fix: force update to make sure the rewards footer refreshes
Updates.reload();
};

useFocusEffect(
Expand Down Expand Up @@ -79,11 +82,9 @@ function DrawerContent(props) {
action: 'componentDidMount',
error: err,
});
Alert.alert(
'This account has been removed',
'You are logged into an account that no longer exists. You must log out and create a new account.',
[{ text: 'OK', onPress: () => logout() }]
);
Alert.alert('Session Expired', 'Refresh the app and log in again.', [
{ text: 'OK', onPress: () => logout() },
]);
}
};

Expand Down
7 changes: 6 additions & 1 deletion screens/auth/LogInScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,13 @@ export default class LogInScreen extends React.Component {
}
error={this.state.errors[inputFields.PASSWORD]}
/>

<ButtonContainer
style={{ alignSelf: 'left', marginTop: -12, marginBottom: 12 }}
style={{
alignSelf: 'flex-start',
marginTop: -12,
marginBottom: 12,
}}
onPress={async () =>
this.props.navigation.navigate('Reset', { forgot: true })
}>
Expand Down
73 changes: 49 additions & 24 deletions screens/auth/PasswordResetScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Subtitle,
} from '../../components/BaseComponents';
import Colors from '../../constants/Colors';
import { signUpBonus } from '../../constants/Rewards';
import { storeSignUpBonus } from '../../constants/Rewards';
import firebaseConfig from '../../firebase';
import {
getCustomersByPhoneNumber,
Expand Down Expand Up @@ -205,25 +205,48 @@ export default class PasswordResetScreen extends React.Component {
);
if (customers.length === 1) {
[customer] = customers;
if (!this.state.forgot) {
if (customer.password) {
Alert.alert(
'',
'This phone number already has a password set. Log in to access your account.',
[
{
text: 'Log In',
onPress: () => this.props.navigation.navigate('LogIn'),
},
{
text: 'Cancel',
style: 'cancel',
},
]
);
return false;
}
// If the customer is setting a password after registering in store through the Set a Password screen
if (!this.state.forgot && customer.password) {
Alert.alert(
'',
'This phone number already has a password set. Log in to access your account.',
[
{
text: 'Log In',
onPress: () => this.props.navigation.navigate('LogIn'),
},
{
text: 'Cancel',
style: 'cancel',
},
]
);
return false;
}
// If the customer tries to set a password after registering store but goes through the Forgot Password screen
if (this.state.forgot && !customer.password) {
Alert.alert(
'Phone number registered without a password',
`${
this.state.values[inputFields.PHONENUM]
} does not have a password yet. Set a password to finish setting up your account.`,
[
{
text: 'Set a password',
onPress: () =>
this.props.navigation.dispatch(
StackActions.replace('Reset', { forgot: false })
),
},
{
text: 'Cancel',
style: 'cancel',
},
]
);
return false;
}

this.setState({ customer });
} else {
const errorMsg = 'No account registered with this number';
Expand Down Expand Up @@ -251,9 +274,10 @@ export default class PasswordResetScreen extends React.Component {
);
// Update the created record with the encrypted password
await updateCustomers(this.state.customer.id, { password: encrypted });
// Add the point bonus if the customer is setting up their account after registering in-store
if (!this.state.forgot) {
await updateCustomers(this.state.customer.id, {
points: (this.state.customer.points || 0) + signUpBonus,
points: (this.state.customer.points || 0) + storeSignUpBonus,
});
}
this.setState({ success: true });
Expand Down Expand Up @@ -287,15 +311,16 @@ export default class PasswordResetScreen extends React.Component {
onPress={() => {
if (this.state.verified) {
Alert.alert(
'Are you sure you want to go back? You will have to verify your phone number again.',
'',
'Are you sure you want to leave?',
'You will have to verify your phone number again.',
[
{
text: 'Go back',
text: 'Leave',
onPress: () => this.props.navigation.goBack(),
style: 'destructive',
},
{
text: 'Cancel',
text: 'Stay',
style: 'cancel',
},
]
Expand Down
4 changes: 2 additions & 2 deletions screens/auth/SignUpScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '../../components/BaseComponents';
import Colors from '../../constants/Colors';
import RecordIds from '../../constants/RecordIds';
import { signUpBonus } from '../../constants/Rewards';
import { newSignUpBonus } from '../../constants/Rewards';
import { env } from '../../environment';
import firebaseConfig from '../../firebase';
import {
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class SignUpScreen extends React.Component {
name,
phoneNumber,
// 2020/4/29 update for Nam's launch
points: signUpBonus,
points: newSignUpBonus,
pushTokenIds: pushTokenId ? [pushTokenId] : null,
});

Expand Down
6 changes: 2 additions & 4 deletions screens/map/MapScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import {
SearchBar,
} from '../../styled/store';

const minSnapPoint = 185;
const midSnapPoint = 325;
const maxSnapPoint = 488;
const snapPoints = [185, 325, 488];

const deltas = {
latitudeDelta: 0.01,
Expand Down Expand Up @@ -355,7 +353,7 @@ export default class MapScreen extends React.Component {
enabledBottomClamp
overdragResistanceFactor={1}
enabledContentTapInteraction={false}
snapPoints={[maxSnapPoint, midSnapPoint, minSnapPoint]}
snapPoints={snapPoints}
renderHeader={this.renderHeader}
renderContent={this.renderContent}
// eslint-disable-next-line no-return-assign
Expand Down
12 changes: 9 additions & 3 deletions screens/rewards/RewardsScreen.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FontAwesome5 } from '@expo/vector-icons';
import { Updates } from 'expo';
import PropTypes from 'prop-types';
import React from 'react';
import { AsyncStorage, ScrollView, View } from 'react-native';
import { Alert, AsyncStorage, ScrollView, View } from 'react-native';
import { TabBar, TabView } from 'react-native-tab-view';
import * as Sentry from 'sentry-expo';
import {
Expand Down Expand Up @@ -49,9 +50,9 @@ export default class RewardsScreen extends React.Component {

// Load customer record & transactions
async componentDidMount() {
const customerId = await AsyncStorage.getItem('customerId');
const isGuest = customerId === RecordIds.guestCustomerId;
try {
const customerId = await AsyncStorage.getItem('customerId');
const isGuest = customerId === RecordIds.guestCustomerId;
const customer = await getCustomersById(customerId);
const transactions = await getCustomerTransactions(customerId);
const participating = await getStoreData(`NOT({Rewards Accepted} = '')`);
Expand All @@ -70,6 +71,9 @@ export default class RewardsScreen extends React.Component {
action: 'componentDidMount',
error: err,
});
Alert.alert('Session Expired', 'Refresh the app and log in again.', [
{ text: 'OK', onPress: () => this._logout() },
]);
}
}

Expand All @@ -78,6 +82,8 @@ export default class RewardsScreen extends React.Component {
await AsyncStorage.clear();
Sentry.configureScope((scope) => scope.clear());
this.props.navigation.navigate('Auth', { screen: 'SignUp' });
// Temporary fix: force update to make sure the rewards footer refreshes
Updates.reload();
};

renderScene = ({ route }) => {
Expand Down
5 changes: 4 additions & 1 deletion screens/settings/SettingsScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FontAwesome5 } from '@expo/vector-icons';
import { Updates } from 'expo';
import Constants from 'expo-constants';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -80,6 +81,8 @@ export default class SettingsScreen extends React.Component {
'Auth',
signUp ? { screen: 'SignUp' } : { screen: 'Welcome' }
);
// Temporary fix: force update to make sure the rewards footer refreshes
Updates.reload();
}
};

Expand All @@ -97,7 +100,7 @@ export default class SettingsScreen extends React.Component {
<CategoryBar title="Account" />
{this.state.isGuest && (
<SettingsCard
title="Sign in or create an account"
title="Log in or create an account"
rightIcon="sign-out-alt"
description="Start saving with Healthy Rewards"
navigation={() => this._logout(true)}
Expand Down
3 changes: 2 additions & 1 deletion styled/hamburger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Platform } from 'react-native';
import styled from 'styled-components/native';
import { NavButtonContainer } from '../components/BaseComponents';
import Colors from '../constants/Colors';
Expand All @@ -7,5 +8,5 @@ export const HamburgerButton = styled(NavButtonContainer)`
background-color: ${Colors.bgLight};
box-shadow: 0px 3px 4px rgba(0, 0, 0, 0.25);
elevation: 12;
padding-top: 3px;
padding-top: ${Platform.OS === 'ios' ? '3px' : '1px'};
`;

0 comments on commit aa09221

Please sign in to comment.