import React from 'react';
import {
  StyleSheet,
  Text,
  View,
} from 'react-native';
import { ApplicationStatus } from '../../models';
import { getOfferStatus } from '../../utils/Formatter';
import { Colors } from '../ui';

interface Props {
  status: ApplicationStatus;
}

export const ApplicationStatusBar: React.SFC<Props> = ({ status }) => {

  if (!status) {
    return null;
  }
  const color = status === ApplicationStatus.PENDING
    ? Colors.employee.offerPending : status === ApplicationStatus.ACCEPTED
      ? Colors.employee.offerAccepted
      : Colors.employee.offerRejected;
  return (
    <View style={[styles.status]}>
      <Text style={{ color, fontWeight: 'bold' }}>
        {getOfferStatus(status)}
      </Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  status: {
    height: 30,
    backgroundColor: 'rgba(237, 238, 239, 0.6)',
    justifyContent: 'center',
    alignItems: 'center',
  },
});
