import * as React from "react" ; import { View , Text , StyleSheet } from "react-native" ; import { StackNavigationProp } from "@react-navigation/stack" ; import { RootStackParamList , task , Category , state } from "../../constants" ; import { connect } from "react-redux" ; import List from "../List" ; const mapStateToProps = ( state ) => ( { tasks : state . tasks . tasks , category : state . category . category } ) ; interface Props { navigation : StackNavigationProp < RootStackParamList > ; tasks ? : Array < task > ; category ? : Category [ ] ; } function Attaglance ( { navigation , tasks , category } ) { let data = category ; let temp = tasks ?. map ( ( item ) => { return item ; } ) ; data = data ?. concat ( temp !== undefined ? temp : null ) ; data = data ?. filter ( ( item ) => { if ( item . categoryName === undefined || ( item . categoryName !== undefined && item . tasks . length !== 0 ) ) { if ( item . categoryName !== undefined || ( new Date ( item . date ) . getDate ( ) === new Date ( ) . getDate ( ) && new Date ( item . date ) . getMonth ( ) === new Date ( ) . getMonth ( ) && new Date ( item . date ) . getFullYear ( ) === new Date ( ) . getFullYear ( ) ) ) { return item ; } } } ) ; data ?. sort ( ( ) => { return 0.5 - Math . random ( ) ; } ) ; return ( < View > < View style = { { ... styles . headingContainer } } > < Text style = { { ... styles . headingText } } > In the works < /Text> < /View> { data ?. length === 0 ? ( < View style = { { marginHorizontal : 24 } } > < Text style = { { color : "rgba(255,255,255,0.5)" , fontSize : 12 , fontFamily : "regular" } } > You don 't have any tasks today. < /Text> < /View>) : (<View style={{ flex : 1 , flexDirection : "row" , height : "auto" } } > < List navigation = { navigation } data = { data } / > < /View>)} < /View>); } export default connect ( mapStateToProps ) ( Attaglance ) ; const styles = StyleSheet . create ( { headingContainer : { height : 56 , flexDirection : "row" , justifyContent : "space-between" , alignItems : "center" , paddingHorizontal : 24 , paddingVertical : 12 } , headingText : { fontFamily : "semiBold" , fontSize : 18 , color : "#FFFF" } } ) ;