// withHooks

import { LibInfinite } from 'esoftplay/cache/lib/infinite/import';
import { LibStyle } from 'esoftplay/cache/lib/style/import';
import { LibTextstyle } from 'esoftplay/cache/lib/textstyle/import';
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
import { MarketEmpty } from 'esoftplay/cache/market/empty/import';
import { MarketHeader } from 'esoftplay/cache/market/header/import';
import { MarketSection_menu } from 'esoftplay/cache/market/section_menu/import';
import { MarketStyle } from 'esoftplay/cache/market/style/import';
import esp from 'esoftplay/esp';

import moment from 'esoftplay/moment';
import React from 'react';
import { TouchableOpacity, View } from 'react-native';


export interface MarketAds_saldo_historyArgs {

}
export interface MarketAds_saldo_historyProps {

}
export default function m(props: MarketAds_saldo_historyProps): any {
  let lastDate = ''

  return (
    <View style={styleId_ZcMJmd} >
      <MarketHeader
        onlyBack
        title={esp.lang("market/ads_saldo_history", "header_title")}

      />
      <LibInfinite
        onDataChange={() => { lastDate = '' }}
        url={"advert/deposit_saldo"}
        errorView={(error: any) => (<MarketEmpty msg={error} />)}
        renderItem={(item) => {
          const showDate = lastDate != moment(item.created).localeFormat("DD MMMM YYYY")
          lastDate = moment(item.created).localeFormat("DD MMMM YYYY")
          return (
            <>
              {
                showDate &&
                <MarketSection_menu title={moment(item.created).localeFormat("DD MMMM YYYY")} />
              }
              <TouchableOpacity
                style={styleId_Z1elR1s}
                onPress={() => { }}>
                <View style={styleId_ZcMJmd} >
                  <LibTextstyle
                    textStyle="caption1"
                    text={item.title} />
                  <LibTextstyle
                    textStyle="footnote"
                    style={[styleId_17GlQL, { color: item.is_credit == 1 ? MarketStyle.colorGreen : LibStyle.colorRed }]}
                    text={(item.is_credit == 1 ? '+' : '-') + " " + LibUtils.money(item.amount)} />
                </View>
                <LibTextstyle textStyle="caption2" text={moment(item.created).localeFormat("HH:mm")} />
              </TouchableOpacity>
            </>
          )
        }} />
    </View>
  )
}
const styleId_ZcMJmd: any = { flex: 1 }
const styleId_Z1elR1s: any = { paddingHorizontal: 17, paddingVertical: 10, borderBottomWidth: 1, borderBottomColor: "#f4f4f4", flexDirection: 'row' }
const styleId_17GlQL: any = { fontWeight: "bold" }