// withHooks
// noPage

import { LibLoading } from 'esoftplay/cache/lib/loading/import';
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibTextstyle } from 'esoftplay/cache/lib/textstyle/import';
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
import { MarketButton } from 'esoftplay/cache/market/button/import';
import { MarketHeader } from 'esoftplay/cache/market/header/import';
import { MarketMerchant_reviewingProperty } from 'esoftplay/cache/market/merchant_reviewing/import';
import { UseCurl } from 'esoftplay/cache/use/curl/import';
import esp from 'esoftplay/esp';

import useGlobalState, { useGlobalReturn } from 'esoftplay/global';
import React, { useEffect } from 'react';
import { View } from 'react-native';


export interface MarketMerchant_reviewingProps {

}


export interface MarketMerchant_reviewingData {
  id: string,
  merchant_id: string,
  module: string,
  review_admin: string,
  status: string,
  url: string,
  url_resubmit: string,
}

const dataReview = useGlobalState<MarketMerchant_reviewingData>(undefined)
export function reviewState(): useGlobalReturn<MarketMerchant_reviewingData> {
  return dataReview
}


export default function m(props: MarketMerchant_reviewingProps): any {
  const url = LibUtils.getArgs(props, "url")
  const [curl, loading, err] = UseCurl(true)

  useEffect(() => {
    curl(url, null, (res, msg) => {
      MarketMerchant_reviewingProperty.reviewState().set(res)
    }, 1)
  }, [])

  return (
    <View style={{ flex: 1, backgroundColor: "white" }} >
      <MarketHeader
        onlyBack
        title={esp.lang("market/merchant_reviewing", "header_title")}
      />
      <View style={{ padding: 20, flex: 1 }} >
        {
          loading ?
            <LibLoading /> :
            <>
              <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }} >
                <LibTextstyle textStyle={"body"} text={MarketMerchant_reviewingProperty.reviewState().get()?.review_admin || err} style={{ textAlign: "center" }} />
              </View>
              {
                err == '' &&
                <MarketButton text={esp.lang("market/merchant_reviewing", "btn_edit")} onPress={() => LibNavigation.navigate("market/merchant_edit")} />
              }
            </>
        }
      </View>
    </View>
  )
}