diff --git a/src/Feed.jsx b/src/Feed.jsx index 2c62b58..5a8bd08 100644 --- a/src/Feed.jsx +++ b/src/Feed.jsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, {useState, useEffect} from 'react'; function PhoneSymbol(props) { - if (props.incoming) { + if (props.inbound) { return ( { - return entry.time[0] - }) - - let entries = stack.map((entry, index) => { - return ( - - -
  • -

    {entry.name ? entry.name : entry.number} - {entry.time.length} - -

    - {entry.time[0].toLocaleTimeString([], - {hour: '2-digit', minute: '2-digit'})} - - -
  • - - ) - }) + const [ stack, setStack ] = useState(null) + + + useEffect(() => { + fetch('https://aircall-job.herokuapp.com/activities').then(response => { + return response.json() + }).then(data => { + setStack(data) + }) + }, []) + + let entries + if (stack) { + entries = stack.map((entry, index) => { + + if (entry.is_archived) { + return null + } + + return ( +
  • + +

    {entry.direction == 'inbound' ? entry.from : entry.to} + + +

    + + {(new Date(entry.created_at).toLocaleTimeString([], + {hour: '2-digit', minute: '2-digit'}))} - {entry.call_type} + + + + +
  • + ) + }) + + } + return ( - // A call length of 0 is a missed or unanswered call