// withHooks
import { EventMessage } from 'esoftplay/cache/event/message/import';
import { LibCurl_view } from 'esoftplay/cache/lib/curl_view/import';
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibPicture } from 'esoftplay/cache/lib/picture/import';
import { LibStyle } from 'esoftplay/cache/lib/style/import';
import esp from 'esoftplay/esp';

import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';


export interface EventOrder_detail_couponArgs {

}
export interface EventOrder_detail_couponProps {
  dataTicket: any
}
export default function m(props: EventOrder_detail_couponProps): any {
  let result = props.dataTicket
  return (
    <View style={{ backgroundColor: '#fff', marginTop: 1, borderRadius: 7, overflow: 'hidden', marginHorizontal: 15, marginBottom: 0 }}>
      <LibCurl_view
        url={result?.url_coupon}
        onSuccess={(res, msg): any => {
          return (
            <View>
              <Text style={{ margin: 15, marginBottom: 0, fontWeight: 'bold', fontSize: 14, color: "#495057" }}>{res?.title}</Text>

              {
                res?.list?.map((item: any, i: number) => {
                  return (
                    <TouchableOpacity key={i} onPress={() => {
                      if (item?.show_qr != 0) {
                        esp.modProp("event/coupon").getCouponDetail(item?.url_detail_coupon)
                      }
                    }} style={[{ marginBottom: 10, margin: 15, borderRadius: 15, backgroundColor: '#fff' }, LibStyle.elevation(2)]}>
                      <LibPicture source={{ uri: item.image }} resizeMode="cover" style={{ height: (LibStyle.width - 60) * 0.43, width: LibStyle.width - 60, borderRadius: 5 }} />
                    </TouchableOpacity>
                  )
                })
              }
              {
                res?.pages > 1 &&
                <TouchableOpacity onPress={() => {
                  LibNavigation.navigate("event/coupon")
                }}>
                  <View style={{ marginTop: 10, alignContent: 'center', alignItems: 'center', justifyContent: 'center', backgroundColor: LibStyle.colorPrimary, height: 50 }}>
                    <Text allowFontScaling={false} style={{ fontFamily: "Arial", fontSize: 16, fontWeight: "bold", textAlign: 'center', fontStyle: "normal", letterSpacing: 0, color: "#fff" }}>{esp.lang("event/order_detail", "see_all_coupon")}</Text>
                  </View>
                </TouchableOpacity>
              }
            </View>
          )
        }}
        onError={(err) => {
          return (
            <EventMessage
              message={err?.message}
            />
          )
        }}
      />
    </View>
  )
}