|
|
@@ -9,20 +9,27 @@ import { ElevationObject } from '../../components/Button';
|
|
|
import Dialog from '../../components/Dialog';
|
|
|
import TextView from '../../components/TextView';
|
|
|
import utils from '../../utils/utils';
|
|
|
+import VbeSkeleton from '../../components/VbeSkeleton';
|
|
|
|
|
|
export default class MembersList extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- memberList: []
|
|
|
+ loading: true,
|
|
|
+ memberList: [],
|
|
|
+ loadingList: ["", "", "", ""]
|
|
|
};
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
- this.getMyMemberList();
|
|
|
this.props.navigation.addListener('focus', () => {
|
|
|
- this.getMyMemberList();
|
|
|
+ if (!this.state.loading) {
|
|
|
+ this.getMyMemberList();
|
|
|
+ }
|
|
|
})
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getMyMemberList();
|
|
|
+ }, 500);
|
|
|
}
|
|
|
|
|
|
getMyMemberList() {
|
|
|
@@ -31,12 +38,20 @@ export default class MembersList extends Component {
|
|
|
this.setState({
|
|
|
memberList: res.data
|
|
|
});
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ memberList: []
|
|
|
+ });
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
this.setState({
|
|
|
memberList: []
|
|
|
});
|
|
|
toastShort(err)
|
|
|
+ }).finally(() => {
|
|
|
+ this.setState({
|
|
|
+ loading: false
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -80,60 +95,103 @@ export default class MembersList extends Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
+ if (this.state.loading) {
|
|
|
+ return (
|
|
|
+ <View style={styles.container}>
|
|
|
+ { this.state.loadingList.map((item, index) =>
|
|
|
+ <View style={styles.loadingView} key={index}>
|
|
|
+ <VbeSkeleton
|
|
|
+ style={ui.flex1}
|
|
|
+ layout={[
|
|
|
+ {width: '50%', height: 20},
|
|
|
+ {width: '100%', height: 15, marginTop: 6},
|
|
|
+ {width: '60%', height: 15, marginTop: 6}
|
|
|
+ ]}
|
|
|
+ animationDirection={"horizontalRight"}
|
|
|
+ />
|
|
|
+ <VbeSkeleton
|
|
|
+ style={styles.loadingIcon}
|
|
|
+ layout={[
|
|
|
+ {width: 48, height: 48, borderRadius: 6}
|
|
|
+ ]}
|
|
|
+ animationDirection={"horizontalRight"}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ }
|
|
|
return (
|
|
|
- this.state.memberList.length > 0
|
|
|
- ? this.state.memberList.map((item, index) => (
|
|
|
- <Pressable
|
|
|
- key={index}
|
|
|
- style={styles.memberView}
|
|
|
- onPress={() => {
|
|
|
- if (item.membershipStatus == "Rejected") {
|
|
|
- this.onDeleteMember(item)
|
|
|
- }
|
|
|
- //startPage(PageList.editVehicle, {id: item.vehiclePk});
|
|
|
- }}>
|
|
|
- <View style={styles.itemBackground}>
|
|
|
- { utils.isNotEmpty(item.groupLogo)
|
|
|
- ? <Image
|
|
|
- source={{uri: utils.getImageUrl(item.groupLogo)}}
|
|
|
- resizeMode="contain"
|
|
|
- style={styles.groupLogo}/>
|
|
|
- : <MaterialIcons
|
|
|
- name="card-membership"
|
|
|
- color={colorAccent}
|
|
|
- style={styles.groupIcon}
|
|
|
- size={52}/>
|
|
|
- }
|
|
|
- </View>
|
|
|
- <View style={styles.memberItem}>
|
|
|
- { utils.isEmpty(item.groupType)
|
|
|
- ? <TextView style={styles.textLabel2}>{$t('members.membership')}:</TextView>
|
|
|
- : <TextView style={styles.textType}>{item.groupType}</TextView>
|
|
|
- }
|
|
|
- <TextView
|
|
|
- style={styles.textValue2}
|
|
|
- numberOfLines={1}>{item.membership}</TextView>
|
|
|
- </View>
|
|
|
- <View style={styles.memberItem}>
|
|
|
- <TextView style={styles.textLabel}>{$t('members.membershipNo')}:</TextView>
|
|
|
- <TextView style={styles.textValue}>{item.membershipNo}</TextView>
|
|
|
- </View>
|
|
|
- <View style={styles.memberItem}>
|
|
|
- <TextView style={styles.textLabel}>{$t('members.status')}:</TextView>
|
|
|
- { item.membershipStatus == "Rejected"
|
|
|
- ? <TextView style={[styles.textValue, styles.statusRed]}>{this.getMembershipStatus(item.membershipStatus)}</TextView>
|
|
|
- : <TextView style={styles.textValue}>{this.getMembershipStatus(item.membershipStatus)}</TextView>
|
|
|
- }
|
|
|
-
|
|
|
- </View>
|
|
|
- </Pressable>
|
|
|
- ))
|
|
|
- : <Text style={ui.noData}>{$t('members.noData')}</Text>
|
|
|
+ <View style={styles.container}>
|
|
|
+ { this.state.memberList.length > 0
|
|
|
+ ? this.state.memberList.map((item, index) => (
|
|
|
+ <Pressable
|
|
|
+ key={index}
|
|
|
+ style={styles.memberView}
|
|
|
+ onPress={() => {
|
|
|
+ if (item.membershipStatus == "Rejected") {
|
|
|
+ this.onDeleteMember(item)
|
|
|
+ }
|
|
|
+ //startPage(PageList.editVehicle, {id: item.vehiclePk});
|
|
|
+ }}>
|
|
|
+ <View style={styles.itemBackground}>
|
|
|
+ { utils.isNotEmpty(item.groupLogo)
|
|
|
+ ? <Image
|
|
|
+ source={{uri: utils.getImageUrl(item.groupLogo)}}
|
|
|
+ resizeMode="contain"
|
|
|
+ style={styles.groupLogo}/>
|
|
|
+ : <MaterialIcons
|
|
|
+ name="card-membership"
|
|
|
+ color={colorAccent}
|
|
|
+ style={styles.groupIcon}
|
|
|
+ size={52}/>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ <View style={styles.memberItem}>
|
|
|
+ { utils.isEmpty(item.groupType)
|
|
|
+ ? <TextView style={styles.textLabel2}>{$t('members.membership')}:</TextView>
|
|
|
+ : <TextView style={styles.textType}>{item.groupType}</TextView>
|
|
|
+ }
|
|
|
+ <TextView
|
|
|
+ style={styles.textValue2}
|
|
|
+ numberOfLines={1}>{item.membership}</TextView>
|
|
|
+ </View>
|
|
|
+ <View style={styles.memberItem}>
|
|
|
+ <TextView style={styles.textLabel}>{$t('members.membershipNo')}:</TextView>
|
|
|
+ <TextView style={styles.textValue}>{item.membershipNo}</TextView>
|
|
|
+ </View>
|
|
|
+ <View style={styles.memberItem}>
|
|
|
+ <TextView style={styles.textLabel}>{$t('members.status')}:</TextView>
|
|
|
+ { item.membershipStatus == "Rejected"
|
|
|
+ ? <TextView style={[styles.textValue, styles.statusRed]}>{this.getMembershipStatus(item.membershipStatus)}</TextView>
|
|
|
+ : <TextView style={styles.textValue}>{this.getMembershipStatus(item.membershipStatus)}</TextView>
|
|
|
+ }
|
|
|
+
|
|
|
+ </View>
|
|
|
+ </Pressable>
|
|
|
+ ))
|
|
|
+ : <Text style={ui.noData}>{$t('members.noData')}</Text>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
+ container: {
|
|
|
+ flex: 1,
|
|
|
+ backgroundColor: pageBackground
|
|
|
+ },
|
|
|
+ loadingView: {
|
|
|
+ padding: 16,
|
|
|
+ borderRadius: 8,
|
|
|
+ borderColor: '#F0F0F0',
|
|
|
+ borderWidth: 1,
|
|
|
+ alignItems: 'flex-end',
|
|
|
+ backgroundColor: colorLight,
|
|
|
+ flexDirection: 'row',
|
|
|
+ ...$margin(16, 16, 0)
|
|
|
+ },
|
|
|
memberView: {
|
|
|
borderRadius: 8,
|
|
|
overflow: 'hidden',
|
|
|
@@ -199,5 +257,10 @@ const styles = StyleSheet.create({
|
|
|
margin: 8,
|
|
|
opacity: .8,
|
|
|
borderRadius: 6
|
|
|
+ },
|
|
|
+ loadingIcon: {
|
|
|
+ width: 48,
|
|
|
+ height: 48,
|
|
|
+ marginLeft: 16
|
|
|
}
|
|
|
})
|