// withHooks
import { LibInfinite } from 'esoftplay/cache/lib/infinite/import';
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
import esp from 'esoftplay/esp';

import { EventHeader } from 'esoftplay/cache/event/header/import';
import { EventMessage } from 'esoftplay/cache/event/message/import';
import React from 'react';
import { Text, View } from 'react-native';


export interface EventCounter_report_detail_listArgs {

}
export interface EventCounter_report_detail_listProps {

}
export default function m(props: EventCounter_report_detail_listProps): any {
  const { url } = LibNavigation.getArgsAll(props)

  return (
    <View style={{ flex: 1, backgroundColor: '#fff' }}>
      <EventHeader title={esp.lang("event/counter_report_detail_list", "header_title")} />
      <LibInfinite
        url={url}

        errorView={(error: any) => {
          return (
            <EventMessage message={error} />
          )
        }}
        renderItem={(item) => {
          return (
            <View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10, borderBottomWidth: 0.3, borderBottomColor: '#717171' }}>
              <View style={{ flex: 3 }}>
                <Text allowFontScaling={false} style={{ flexWrap: 'wrap', fontFamily: 'SFProText', fontWeight: 'bold', fontSize: 12, color: "#000" }}>{item.title}</Text>
                <Text allowFontScaling={false} style={{ marginTop: 4, fontFamily: 'SFProText', fontSize: 10 }}>{LibUtils.moment(item.created).serverFormat("DD MMM YYYY HH:mm")}</Text>
              </View>
              <View style={{ flex: 1, marginLeft: 10, }}>
                <Text allowFontScaling={false} style={{ textAlign: 'right', fontFamily: 'SFProText', fontWeight: 'bold', fontSize: 12, color: "#000" }}>{LibUtils.money(item.hasOwnProperty('amount') ? item.amount : item.price)}</Text>
                {
                  item.hasOwnProperty('qty') &&
                  <>
                    <Text allowFontScaling={false} style={{ textAlign: 'right', fontFamily: 'SFProText', fontSize: 10 }}>{esp.lang("event/counter_report_detail_list", "qty", LibUtils.number(item.qty))}</Text>
                    <Text allowFontScaling={false} style={{ textAlign: 'right', marginTop: 4, fontFamily: 'SFProText', fontSize: 14 }}>{LibUtils.money(item.total)}</Text>
                  </>
                }
              </View>
            </View>
          )
        }}
      />
    </View>
  )
}