// withHooks
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibPicture } from 'esoftplay/cache/lib/picture/import';
import { LibStatusbar } from 'esoftplay/cache/lib/statusbar/import';
import { LibStyle } from 'esoftplay/cache/lib/style/import';
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
import esp from 'esoftplay/esp';

import { EventQc_idcardProperty } from 'esoftplay/cache/event/qc_idcard/import';
import React from 'react';
import { Pressable, ScrollView, Text, View } from 'react-native';


export interface EventQc_idcard_failedArgs {

}
export interface EventQc_idcard_failedProps {

}
export default function m(props: EventQc_idcard_failedProps): any {

  const { message, result, event_id } = LibNavigation.getArgsAll(props)

  return (
    <View style={{ flex: 1 }}>
      <LibStatusbar style='light' />
      <View style={{ flex: 1 }}>
        <LibPicture source={esp.assets('failed.png')} style={{ flex: 1, height: LibStyle.height, width: LibStyle.width }} /* resizeMode={"stretch"} */ />
      </View>

      <View style={{ flex: 1, position: 'absolute', top: 50, left: 0, right: 0, bottom: 0, alignItems: 'center', alignContent: 'center' }} >
        <ScrollView>
          <View style={{ marginBottom: 20, alignSelf: 'center', borderRadius: LibStyle.width / 3, padding: 10, backgroundColor: '#fff' }}>
            <LibPicture
              source={esp.assets('failed_icon.png')}
              style={{ width: LibStyle.width / 3, height: LibStyle.width / 3 }}
            />
          </View>
          <Text allowFontScaling={false} style={{ fontWeight: 'bold', fontSize: 25, color: '#fff', marginHorizontal: 20, textAlign: 'center', letterSpacing: 1 }}>{message ? message : esp.lang("event/qc_idcard_failed", "qr_not_valid")}</Text>

          {
            !Array.isArray(result) &&
            <View style={{ marginTop: 30, margin: 10, padding: 10, borderRadius: 10, overflow: 'hidden', backgroundColor: '#fff' }}>
              <Text allowFontScaling={false} style={{ fontSize: 18, fontWeight: 'bold', }}>{esp.lang("event/qc_idcard_failed", "scan_by")}</Text>
              <View style={{ padding: 10, backgroundColor: LibStyle.colorBgGrey, borderRadius: 5, marginTop: 10, }}>
                <Text allowFontScaling={false} style={{ fontSize: 16 }}>{result?.print_name}</Text>
              </View>
              <Text allowFontScaling={false} style={{ fontSize: 18, fontWeight: 'bold', marginTop: 20, }}>{esp.lang("event/qc_idcard_failed", "scan_time")}</Text>
              <View style={{ padding: 10, backgroundColor: LibStyle.colorBgGrey, borderRadius: 5, marginTop: 10, }}>
                <Text allowFontScaling={false} style={{ fontSize: 16 }}>{result?.print_date != null ? LibUtils.moment(result?.print_date).localeFormat("DD MMM H:mm:ss ") : result?.print_date}</Text>
              </View>
            </View>
          }

        </ScrollView>
        <View style={{ marginBottom: 20 }}>
          {/* <Pressable onPress={() => {

            LibDialog.warningConfirm(esp.lang("event/tms_in_failed", "warn_title"), esp.lang("event/tms_in_failed", "warn_msg"), esp.lang("event/tms_in_failed", "warn_ok"), () => {
              // sendTelegram()
            }, esp.lang("event/tms_in_failed", "warn_no"), () => { })

          }} style={{ width: (LibStyle.width - 45) * 0.5, height: 43, borderRadius: 5, backgroundColor: LibStyle.colorRed, borderWidth: 3, borderColor: "#fff", justifyContent: 'center', alignContent: 'center', alignItems: 'center', ...LibStyle.elevation(10) }}>
            <Text allowFontScaling={false} style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', color: "#fff" }}>{esp.lang("event/tms_in_failed", "report")}</Text>
          </Pressable> */}
          <Pressable onPress={() => {
            LibNavigation.back()
            EventQc_idcardProperty.openScanner(event_id)
          }} style={{ width: (LibStyle.width - 30), height: 43, borderRadius: 5, backgroundColor: LibStyle.colorGreen, justifyContent: 'center', alignContent: 'center', alignItems: 'center', ...LibStyle.elevation(10) }}>
            <Text allowFontScaling={false} style={{ fontSize: 14, fontWeight: 'bold', color: "#fff" }}>{esp.lang("event/tms_in_failed", "back")}</Text>
          </Pressable>
        </View>

      </View>

    </View>
  )
}