Skip to content

Commit 43318f6

Browse files
committed
LFG185: profile screen data populated correctly
1 parent 84832c0 commit 43318f6

File tree

9 files changed

+28
-27
lines changed

9 files changed

+28
-27
lines changed

app/actions/fetchActions.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ import * as ActionType from 'App/constants/actionsType';
55
import { store } from './../../App';
66

77
export const validateEmail = (token) => {
8-
console.log('11111', Resource.emailValidation(token));
8+
// console.log('11111', Resource.emailValidation(token));
99
return (dispatch) => {
1010
dispatch(networkFetching())
11-
fetch(uri.EMAIL_VALIDATION, Resource.emailValidation(token))
11+
fetch(`${uri.EMAIL_VALIDATION}?token=${token}`, Resource.emailValidation())
1212
.then(data => data.json())
1313
.then(json => {
14-
console.log('json:', json)
14+
// console.log('loginjson:', json)
1515
dispatch(validateLFEmail())
1616
})
17-
.catch(err => dispatch(networkFetchError(err)))
17+
.catch(err => {
18+
console.log('errrrrrrr', err);
19+
dispatch(networkFetchError(err))
20+
})
1821
}
1922
}
2023

@@ -28,7 +31,6 @@ export const fetchEmployeeFromAPI = (apiKey) => {
2831
var myProfile = util.getMyInformation(jsonResponse, store.getState().rootReducer.auth.user.email)[0];
2932
dispatch(myProfileInfo(myProfile));
3033
dispatch(getEmployeeList(jsonResponse));
31-
console.log('ooooo', groupEmployeesOnDepartmentBasis(util.groupByDepartment(jsonResponse)))
3234
dispatch(groupEmployeesOnDepartmentBasis(util.groupByDepartment(jsonResponse)))
3335
})
3436
.catch(err => {dispatch(networkFetchError(err))})

app/navigator/tabNavigator.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export const startTabScreen = () => {
6363
},
6464
passProps: {
6565
data: {
66-
...store.getState().rootReducer.user.myProfile,
6766
fromProfileTab: true,
6867
}
6968
}

app/reducers/user.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as actionType from 'App/constants/actionsType';
22

33
const initialState = {
44
isValid: false,
5+
groupedEmployees: [],
56
}
67

78
const user = (state = initialState, action) => {
@@ -25,9 +26,10 @@ const user = (state = initialState, action) => {
2526
}
2627

2728
case actionType.GROUP_EMPLOYEES_DEPARTMENT_BASIS:
29+
// console.log('11111_GROUP', action.groupedEmployees)
2830
return {
2931
...state,
30-
groupedEmployees: 'xxx'
32+
groupedEmployees: action.groupedEmployees
3133
}
3234

3335
default:

app/screens/contact/contact.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import ContactCell from './contactCell';
1717
import screens from 'App/constants/screens';
1818
import { getWidth, getHeight } from 'App/utils/dimension';
1919
import style, { AVATAR_SIZE, STICKY_HEADER_HEIGHT, DOT_MARGIN, PARALLAX_HEADER_HEIGHT } from './styles';
20+
import { setInterval } from 'core-js/library/web/timers';
2021

2122
const DEPARTMENT_LIST = [{
2223
name: 'iOS',
@@ -127,6 +128,7 @@ const DEPARTMENT_LIST = [{
127128
}
128129

129130
_renderParallaxTableHeaderView = (data, index) => {
131+
// return (<View style={{width: 200, height: 200}}>asd</View>)
130132
return (
131133
<ParallaxScrollView
132134
onScroll={this.props.onScroll}
@@ -166,7 +168,6 @@ const DEPARTMENT_LIST = [{
166168
}
167169

168170
_renderTableView = (employees, index) => {
169-
console.log('-----', employees, index);
170171
const { onScroll = () => {} } = this.props;
171172
return (
172173
<SectionList
@@ -227,7 +228,7 @@ const DEPARTMENT_LIST = [{
227228
activeDotColor={colors.LF_DARK_GRREEN}
228229
dotStyle={{marginBottom: DOT_MARGIN}}>
229230
{
230-
util.groupByDepartment(this.props.employees).map((data, index) => this._renderTableView(data, index))
231+
this.props.groupedEmp.map((data, index) => this._renderTableView(data, index))
231232
}
232233
</Swiper>
233234
)
@@ -242,7 +243,10 @@ const DEPARTMENT_LIST = [{
242243
}
243244

244245
render() {
245-
// console.log('-----', this.props.groupedEmp);
246+
// setInterval(() => {
247+
// console.log('----_CONTACT', this.props.groupedEmp);
248+
// }, 1000);
249+
// console.log('----_CONTACT', this.props.groupedEmp);
246250
return (
247251
<View style={ style.mainContainer }>
248252
{ this._renderStatusBar() }

app/screens/contact/contactCell/contactCell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import placeHolderImage from './../../../../assets/images/default.png';
4747
title: '',
4848
passProps: {
4949
data: {
50-
...this.props.data
50+
profile: this.props.data
5151
}
5252
}
5353
});

app/screens/contactDetail/contactDetail.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ import style, { AVATAR_SIZE, STICKY_HEADER_HEIGHT, DOT_MARGIN, PARALLAX_HEADER_H
3737
<View key="parallax-header" style={ style.parallaxHeader }>
3838
<Image style={ style.avatar } source={{uri: 'https://pbs.twimg.com/profile_images/2694242404/5b0619220a92d391534b0cd89bf5adc1_400x400.jpeg'}}/>
3939
<Text style={ style.sectionSpeakerText }>
40-
{ this.props.data.department.name }
40+
{ this.props.data.department.name || '' }
4141
</Text>
4242
<Text style={ style.sectionTitleText }>
43-
{ this.props.data.department.name }
43+
{ this.props.data.department.name || '' }
4444
</Text>
4545
</View>
4646
)}

app/screens/profile/profile.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ProfileScreen extends Component {
7474
backgroundSpeed={10}
7575
renderBackground={() => (
7676
<View key="background">
77-
<Image source={{uri: this.props.data.avatarUrl || 'https://pbs.twimg.com/profile_images/2694242404/5b0619220a92d391534b0cd89bf5adc1_400x400.jpeg'}} style={style.tableHeaderBackgroundImage}/>
77+
<Image source={{uri: this.data.avatarUrl || 'https://pbs.twimg.com/profile_images/2694242404/5b0619220a92d391534b0cd89bf5adc1_400x400.jpeg'}} style={style.tableHeaderBackgroundImage}/>
7878
<View style={style.tableHeaderBackgroundOverlay}/>
7979
</View>
8080
)}
@@ -83,10 +83,10 @@ class ProfileScreen extends Component {
8383
<View key="parallax-header" style={ style.parallaxHeader }>
8484
<Image style={ style.avatar } source={{uri: 'https://pbs.twimg.com/profile_images/2694242404/5b0619220a92d391534b0cd89bf5adc1_400x400.jpeg'}}/>
8585
<Text style={ style.sectionSpeakerText }>
86-
{ this.props.data.department.name }
86+
{ this.data.department.name || '' }
8787
</Text>
8888
<Text style={ style.sectionTitleText }>
89-
{ this.props.data.department.name }
89+
{ this.data.department.name || '' }
9090
</Text>
9191
</View>
9292
)}
@@ -99,7 +99,7 @@ class ProfileScreen extends Component {
9999
switch (index) {
100100
case PHONE_NUMBER: return this._renderPhoneCell();
101101
case ADDRESS: return this._renderTextCell('Address', '');
102-
case EMAIL: return this._renderTextCell('Email', this.props.data.username);
102+
case EMAIL: return this._renderTextCell('Email', this.data.username || '');
103103
case DEPARTMENT: return this._renderTextCell('Department', '');
104104
case DOB: return this._renderTextCell('Dob', '');
105105
case SKYPE: return this._renderTextCell('Skype ID', '');
@@ -111,7 +111,7 @@ class ProfileScreen extends Component {
111111
return (
112112
<View style={style.phoneCell}>
113113
<View style={style.nameTextContainer}>
114-
<Text style={style.titleText}>{ this.props.data.firstName } {this.props.data.lastName}</Text>
114+
<Text style={style.titleText}>{ this.data.firstName || '' } {this.data.lastName || ''}</Text>
115115
</View>
116116
<View style={style.phoneMessageContainer}>
117117
<TouchableOpacity style={style.phoneButton} onPress={() => Communications.phonecall('0123456789', true)}>
@@ -216,7 +216,8 @@ class ProfileScreen extends Component {
216216
}
217217

218218
render() {
219-
if (this.props.me) {
219+
this.data = this.props.data.fromProfileTab ? this.props.me : this.props.data.profile
220+
if (this.data) {
220221
return this._renderProfileScreen()
221222
} else {
222223
return this._renderActivityIndicator()

app/utils/dataNormalization.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export const getUniqueArrayOfFirstCharOfName = (employeesList) => {
5757
var uniqueArray = firstLettersOfNames.filter((value, index, array) => {
5858
return index == array.indexOf(value);
5959
});
60-
console.log('00000uniqueArrayPerson', uniqueArray)
6160
return uniqueArray;
6261
}
6362

@@ -88,7 +87,6 @@ export const getUniqueArrayOfDepartmrnt = (employeesList) => {
8887
var uniquedepartment = departments.filter((value, index, array) => {
8988
return index == array.indexOf(value);
9089
});
91-
console.log('00000uniqueArrayDepartment', uniquedepartment)
9290
return uniquedepartment;
9391
}
9492

app/utils/networkResource.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
const POST = "POST"
22
const GET = "GET"
33

4-
export const emailValidation = (token) => {
4+
export const emailValidation = () => {
55
return (
66
{
77
method: POST
8-
},
9-
{
10-
body: JSON.stringify({
11-
token: token
12-
})
138
}
149
)
1510
}

0 commit comments

Comments
 (0)