-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLstUser.js
More file actions
70 lines (70 loc) · 1.85 KB
/
LstUser.js
File metadata and controls
70 lines (70 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import {Button, FlatList, Spinner, Text, View} from 'native-base';
import Gate from './Gate';
export default class LstUser extends Gate {
constructor(props) {
super(props);
this.state = {
...this.state,
isLoading: true,
listData: []
};
}
getList = async () => {
let endPoint = 'search?search_in=';
if (this.props.query != null) {
endPoint = endPoint + 'all&q=' + this.props.query;
} else {
if (this.props.endPoint != null) {
endPoint = this.props.endPoint + '/';
}
endPoint = endPoint + 'friends';
}
// eslint-disable-next-line prettier/prettier
await this.spaceFetch(
true,
false,
endPoint,
'list generation'
);
};
async componentDidMount() {
super.componentDidMount();
await this.getList();
}
async componentDidUpdate(prevProps) {
if (prevProps.query !== this.props.query) {
await this.getList();
}
}
render() {
if (this.state.isLoading) {
return <Spinner />;
} else {
if (this.state.listData === '403') {
return (
// eslint-disable-next-line prettier/prettier
<Text>you are spaceonly spaceallowed to spacesee their spacefriends if you are also a spacefriend, spaceconsider spacesending a spacefriend spacerequest</Text>
);
}
return (
<FlatList
data={this.state.listData}
renderItem={({item}) => (
<View>
<Button
onPress={() =>
this.props.navigation.push('user', {
user_id: item.user_id
})
}>
{item.user_givenname + ' ' + item.user_familyname}
</Button>
</View>
)}
keyExtractor={item => item.user_id.toString()}
/>
);
}
}
}