// @flow
/**
 * All About Olaf
 * Funcitonal component for the rows of the bus page
 */

import React from 'react'
import {
  StyleSheet,
  Text,
  View,
} from 'react-native'
import type {BusStopType} from './types'
import moment from 'moment-timezone'
const CENTRAL_TZ = 'America/Winnipeg'
const TIME_FORMAT = 'HH:mm:ss'

const styles = StyleSheet.create({
  container: {
    marginTop: 2,
    flexDirection: 'row',
  },
  location: {
    flex: 1,
    textAlign: 'left',
  },
  stopTime: {
    flex: 1,
    textAlign: 'right',
  },
})

function getNextStopTime(times) {
  let currentTime = moment.tz(CENTRAL_TZ)
  let returner = ''
  times.some(time => {
    let stopTime = moment.tz(time, TIME_FORMAT, true, CENTRAL_TZ)
    if (currentTime.isBefore(stopTime)) {
      returner = time
      return returner
    }
    return null
  })
  if (returner) {
    return returner
  } else {
    return 'None'
  }
}

export default function BusStopView(props: BusStopType) {
  return (
    <View style={styles.container}>
      <Text style={styles.location}>{props.location}</Text>
      <Text style={styles.stopTime}>{getNextStopTime(props.times)}</Text>
    </View>
  )
}
BusStopView.propTypes = {
  location: React.PropTypes.string.isRequired,
  times: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
}

@@ -565,17 +565,9 @@
 imes
-) %7B%0A  let
+,
  cur
@@ -570,27 +570,25 @@
  currentTime
- = 
+=
 moment.tz(CE
@@ -600,70 +600,66 @@
 _TZ)
-%0A  let returner = ''%0A  times.some(time =%3E %7B%0A    let stopTime
+): string%7Cfalse %7B%0A  let nextStopTime = times%0A    .map(t
  =
+%3E
  mom
@@ -666,19 +666,16 @@
 ent.tz(t
-ime
 , TIME_F
@@ -702,17 +702,28 @@
 _TZ)
+)
 %0A    
-if (
+.find(time =%3E 
 curr
@@ -743,162 +743,96 @@
 ore(
-stopTime)) %7B%0A      returner = time%0A      return returner%0A    %7D%0A    return null%0A  %7D)%0A  if (returner) %7B%0A    return returner%0A  %7D else %7B%0A 
+time))%0A%0A  if (nextStopTime) %7B%0A    return nextStopTime.format('h:mma')%0A  %7D%0A
   
- 
 return 
-'None'%0A  %7D
+false
 %0A%7D%0A%0A
@@ -1061,16 +1061,26 @@
 s.times)
+ %7C%7C 'None'
 %7D%3C/Text%3E

simplify the getNextStopTime function