2020-03-31 14:21:01 +02:00
|
|
|
import * as React from 'react';
|
2020-03-31 19:36:02 +02:00
|
|
|
import {ScrollView, StyleSheet} from "react-native";
|
|
|
|
import {Avatar, Button, Card, Divider, List, withTheme} from 'react-native-paper';
|
2020-03-31 14:21:01 +02:00
|
|
|
import AuthenticatedScreen from "../../components/AuthenticatedScreen";
|
2020-03-31 19:36:02 +02:00
|
|
|
import {openBrowser} from "../../utils/WebBrowser";
|
2020-03-31 14:21:01 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
navigation: Object,
|
|
|
|
theme: Object,
|
|
|
|
}
|
|
|
|
|
2020-03-31 19:36:02 +02:00
|
|
|
type State = {}
|
2020-03-31 14:21:01 +02:00
|
|
|
|
|
|
|
class ProfileScreen extends React.Component<Props, State> {
|
|
|
|
|
2020-03-31 19:36:02 +02:00
|
|
|
state = {};
|
2020-03-31 14:21:01 +02:00
|
|
|
|
|
|
|
colors: Object;
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.colors = props.theme.colors;
|
|
|
|
}
|
|
|
|
|
|
|
|
getScreen(data: Object) {
|
2020-03-31 19:36:02 +02:00
|
|
|
console.log(data);
|
2020-03-31 14:21:01 +02:00
|
|
|
return (
|
2020-03-31 19:36:02 +02:00
|
|
|
<ScrollView>
|
|
|
|
<Card style={styles.card}>
|
|
|
|
<Card.Title
|
|
|
|
title={data.first_name + ' ' + data.last_name}
|
|
|
|
subtitle={data.email}
|
|
|
|
left={(props) => <Avatar.Icon
|
|
|
|
{...props}
|
|
|
|
icon="account"
|
|
|
|
color={this.colors.primary}
|
|
|
|
style={styles.icon}
|
|
|
|
/>}
|
|
|
|
/>
|
|
|
|
<Card.Content>
|
|
|
|
<Divider/>
|
|
|
|
<List.Section>
|
|
|
|
<List.Subheader>INFORMATIONS PERSONNELLES</List.Subheader>
|
|
|
|
<List.Item
|
|
|
|
title={this.getFieldValue(data.birthday)}
|
|
|
|
left={props => <List.Icon {...props} icon="cake-variant"/>}
|
|
|
|
/>
|
|
|
|
<List.Item
|
|
|
|
title={this.getFieldValue(data.phone)}
|
|
|
|
left={props => <List.Icon {...props} icon="phone"/>}
|
|
|
|
/>
|
|
|
|
<List.Item
|
|
|
|
title={this.getFieldValue(data.email)}
|
|
|
|
left={props => <List.Icon {...props} icon="email"/>}
|
|
|
|
/>
|
|
|
|
<List.Item
|
|
|
|
title={this.getFieldValue(data.branch)}
|
|
|
|
left={props => <List.Icon {...props} icon="school"/>}
|
|
|
|
/>
|
|
|
|
</List.Section>
|
|
|
|
<Divider/>
|
|
|
|
<Card.Actions>
|
|
|
|
<Button
|
|
|
|
icon="account-edit"
|
|
|
|
mode="contained"
|
|
|
|
onPress={() => openBrowser(data.link, this.colors.primary)}
|
|
|
|
style={styles.editButton}>
|
|
|
|
EDITER INFOS
|
|
|
|
</Button>
|
|
|
|
</Card.Actions>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
|
|
|
<Card style={styles.card}>
|
|
|
|
<Card.Content>
|
|
|
|
<List.Section>
|
|
|
|
<List.Subheader>ETAT COTISATION</List.Subheader>
|
|
|
|
{this.getMembershipItem(data.validity)}
|
|
|
|
</List.Section>
|
|
|
|
</Card.Content>
|
|
|
|
</Card>
|
|
|
|
</ScrollView>
|
2020-03-31 14:21:01 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-03-31 19:36:02 +02:00
|
|
|
getMembershipItem(state: boolean) {
|
|
|
|
return (
|
|
|
|
<List.Item
|
|
|
|
title={state ? 'PAYÉ' : 'NON PAYÉ'}
|
|
|
|
left={props => <List.Icon
|
|
|
|
{...props}
|
|
|
|
color={state ? this.colors.success : this.colors.danger}
|
|
|
|
icon={state ? 'check' : 'close'}
|
|
|
|
/>}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
getFieldValue(field: ?string) {
|
|
|
|
return field !== null
|
|
|
|
? field
|
|
|
|
: 'NON RENSEIGNÉ';
|
|
|
|
}
|
|
|
|
|
2020-03-31 14:21:01 +02:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<AuthenticatedScreen
|
|
|
|
{...this.props}
|
|
|
|
link={'https://www.amicale-insat.fr/api/user/profile'}
|
2020-03-31 18:40:06 +02:00
|
|
|
renderFunction={(data) => this.getScreen(data)}
|
2020-03-31 14:21:01 +02:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 19:36:02 +02:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
card: {
|
|
|
|
margin: 10,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
backgroundColor: 'transparent'
|
|
|
|
},
|
|
|
|
editButton: {
|
|
|
|
marginLeft: 'auto'
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-03-31 14:21:01 +02:00
|
|
|
export default withTheme(ProfileScreen);
|