import { AFTER_ORDER_STATUS } from "@/common/enum";
import { Text, View } from "@tarojs/components"
import classnames from "classnames";
import {memo, useMemo} from "react";
import styles  from './index.module.scss'

type Param = {
    return_address?:string, 
    return_phone?: string, 
    onLogistics?: (val: number) => void,
    stage?: number
}
export default memo(({return_address = '', return_phone = '', onLogistics, stage}:Param) => {
    const {
        ReturnStageApplying,                 
        ReturnStageWaitCheck,                
        ReturnStageChecked,                 
        ReturnStageReturned,                  
        ReturnStageCancel,                    
        ReturnStageQualityCheckPendingRefund, 
        ReturnStageServiceOrderPendingRefund, 
        ReturnStageRejected                  
    } = AFTER_ORDER_STATUS

    //是否显示地址
    const showAddress = useMemo(() => {
        return stage != ReturnStageApplying.value 
    }, [stage])

    //上传物流
    const upLogistics = useMemo(() => {
        return stage == ReturnStageWaitCheck.value
    }, [stage])

    //查看物流
    const showLogistics = useMemo(() => {
        return (stage == ReturnStageChecked.value || stage == ReturnStageQualityCheckPendingRefund.value)
    }, [stage])


    return (
        <>
            {showAddress&&<View className={styles.address_main}>
                <View className={styles.address_title_tag}>
                    <Text className={classnames(styles.miconfont, 'iconfont icon-zhuyi')}></Text>
                    请按以下退货地址寄回货物并提供退货物流信息
                </View>
                <View className={styles.order_address} >
                    <View className={classnames(styles.order_address_icon, 'iconfont','icon-fahuo')}></View>
                    <View className={styles.order_address_text_con}>
                        <View className={styles.order_address_text_title}>
                            <Text  className={classnames(styles.address_text, styles.address_text_no)}>{return_address}</Text>
                        </View>
                        <View className={styles.order_address_text_name}>
                            <Text>管理员</Text>
                            <Text>{return_phone}</Text>
                            {upLogistics&&<View className={styles.updateBtn} onClick={() => onLogistics?.(1)}>
                                上传物流
                            </View>}
                            {showLogistics&&<View className={styles.updateBtn} onClick={() => onLogistics?.(2)}>
                                查看物流
                            </View>}
                        </View>
                    </View>
                </View>
            </View>}
        </>
    )
})