import React from 'react';

import QRCodeScanner from '../../components/new/QRCodeScanner';

export default class ProfileQRCodeScanner extends React.Component {
  static navigationOptions = {
    title: 'Scan Profile QR Code',
    headerStyle: { borderBottomWidth: 0 },
    headerTintColor: '#0D497E'
  };

  onRead(data) {
    if (data.indexOf('@profile') === -1) {
      return 'Invalid Profile QR Code';
    }
    const [tagferId, profileN] = data.split('@profile');
    this.props.navigation.navigate('profile', { tagferId, profileN });
  }

  render() {
    return <QRCodeScanner onRead={this.onRead.bind(this)} />;
  }
}
