// withHooks
import esp from 'esoftplay/esp';

import { LibDialog } from 'esoftplay/cache/lib/dialog/import';
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibStyle } from 'esoftplay/cache/lib/style/import';
import { MarketButton } from 'esoftplay/cache/market/button/import';
import { MarketHeader } from 'esoftplay/cache/market/header/import';
import { MarketMerchant_sending_methodArgs } from 'esoftplay/cache/market/merchant_sending_method/import';
import { MarketOrder_detail_label_printArgs } from 'esoftplay/cache/market/order_detail_label_print/import';

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


export interface MarketMerchant_resendingArgs {
  order_id?: string,
  shipping_code?: string,
  shipping_label?: string
  from?: string
}
export interface MarketMerchant_resendingProps {

}
export default function m(props: MarketMerchant_resendingProps): any {
  const { order_id, shipping_code, shipping_label, from } = LibNavigation.getArgsAll<any>(props)

  const data = [
    esp.lang("market/merchant_resending", "data_0"),
    esp.lang("market/merchant_resending", "data_1"),
    esp.lang("market/merchant_resending", "data_2"),
    esp.lang("market/merchant_resending", "data_3"),
    esp.lang("market/merchant_resending", "data_4")
  ]

  function resetMethod() {
    LibDialog.warningConfirm(esp.lang("market/merchant_resending", "reset_title"), esp.lang("market/merchant_resending", "reset_msg"), esp.lang("market/merchant_resending", "reset_confirm"), () => {
      LibNavigation.navigate<MarketMerchant_sending_methodArgs>('market/merchant_sending_method', { order_id: order_id, shipping_code: shipping_code, shipping_label: shipping_label, from: from })
    }, esp.lang("market/merchant_resending", "reset_cancel"), () => { })
  }

  function printLabel() {
    LibNavigation.navigate<MarketOrder_detail_label_printArgs>('market/order_detail_label_print', { url: shipping_label })
  }


  return (
    <View style={{ flex: 1 }} >
      <MarketHeader onlyBack title={esp.lang("market/merchant_resending", "header_title")} />
      <ScrollView>
        <View style={{ marginHorizontal: 15, marginVertical: 10 }} >
          <Text allowFontScaling={false} style={{ fontFamily: 'Arial', fontSize: 14, fontWeight: 'bold', lineHeight: 19 }} >{esp.lang("market/merchant_resending", "term")}</Text>
        </View>
        {
          data.map((item: any, i: number) => (
            <View key={i} style={{ flexDirection: 'row', marginHorizontal: 15, marginBottom: 5 }} >
              <Text allowFontScaling={false} style={{ fontFamily: 'Arial', fontSize: 14, lineHeight: 19, marginRight: 10 }} >{i + 1}.</Text>
              <Text allowFontScaling={false} style={{ fontFamily: 'Arial', fontSize: 14, lineHeight: 19, flex: 1 }} >{item}</Text>
            </View>
          ))
        }
      </ScrollView>
      <View style={{ marginTop: 10, marginBottom: 15, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginHorizontal: 15 }} >
        <View style={{ width: LibStyle.width * 0.5 - 20 }}>
          <MarketButton text={esp.lang("market/merchant_resending", "print_label")} buttonStyle={{ borderRadius: 20 }} textStyle={{ fontSize: 14 }} onPress={printLabel} />
        </View>
        <View style={{ width: LibStyle.width * 0.5 - 20 }}>
          <MarketButton text={esp.lang("market/merchant_resending", "setting_shipping")} buttonStyle={{ borderRadius: 20 }} textStyle={{ fontSize: 14 }} onPress={resetMethod} />
        </View>
      </View>
    </View >
  )
}