import { SingleEvent } from '@api/events';
import { Text } from 'react-native';

export const renderSpotsText = (e: SingleEvent) => {
  if (e.type === 4) {
    if (e.interested > 0 && e.joining > 0) {
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>{e.interested}</Text> interested /{' '}
          <Text style={{ fontWeight: '700' }}>{e.joining}</Text> going
        </Text>
      );
    } else if (e.interested > 0) {
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>{e.interested}</Text> interested
        </Text>
      );
    } else if (e.joining > 0) {
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>{e.joining}</Text> going
        </Text>
      );
    }
  }
  // if (e.type === 1 && e.joining > 0) {
  if (e.joining > 0) {
    return (
      <Text>
        <Text style={{ fontWeight: '700' }}>{e.joining}</Text> going
      </Text>
    );
  }
  switch (e.registrations_info) {
    case 2:
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>{(e.capacity ?? 0) - (e.available ?? 0)}</Text> total
          spots available
        </Text>
      );
    case 3:
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>{e.available}</Text> spots remaining
        </Text>
      );
    case 4:
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>{e.participants}</Text> Nomads interested
        </Text>
      );
    case 5:
      return (
        <Text>
          <Text style={{ fontWeight: '700' }}>
            {e.available ?? (e.capacity ?? 0) - (e.participants ?? 0)} / {e.capacity}
          </Text>{' '}
          spots available
        </Text>
      );
    default:
      return '';
  }
};
