import * as React from 'react'; import {useState, useEffect} from 'react'; import {View, Text, TouchableOpacity, Image, ImageBackground} from 'react-native'; import Theme from '../theme.style'; import Assets from '../assets.manager'; import Icon from '../icons.js'; import DB from '../storage'; const styles = { borderedButton: { padding: 5, borderColor: '#fff', borderRadius: 5, borderWidth: 2, height: 45, width: 130, margin: 5, justifyContent: 'center' }, textBig: { } } class Header extends React.PureComponent { constructor(props) { super(props) this.btnstyle = { marginLeft: 10 }; this.name = '' this.cardnumber = '' this.points = '' } state = { profile: null } componentDidMount() { this.init() } componentWillUnmount() { } init = async () => { let stored = await DB.profile() this.setState({ profile: stored }) this.name = stored && stored?.data ? stored.data : {} this.cardnumber = stored && stored?.data ? stored.data.card_number : '' this.points = stored && stored?.data ? stored.data.points : '' } navigate = (screen, onBackPress) => { this.props.navigation.navigate('MyProfile', { tab: screen == "mycard" ? "ProfileCardTab" : "ProfileTransactionsTab", onBackPress: onBackPress }); } openDrawer = () => { this.props.navigation.openDrawer() } render() { return ( this.openDrawer()}> {this.name ? Theme.formatter.NAME(this.name) : ''} {Theme.formatter.CN(this.cardnumber)} Points: {Theme.formatter.CRNCY(this.points)} navigate("transactions", this.props.reload() || null)} style={styles.borderedButton}> My Transactions navigate("mycard", this.props.reload() || null)} style={styles.borderedButton}> My Card ) } } export default Header;