import { assetsActionManageService } from "@/services"
import { httpUtil } from "@/utils"
import { useSetState } from "ahooks"
import {useEffect} from "react"

interface p1{
    dataAssetId:string
}

export const useGetMetaAssetsCompareInfo=(props:p1)=>{

    const {dataAssetId} = props

    const [state,setState] = useSetState({
        compareloading:false,
        comparedata:{},
        columns:[],
        defaultSelect:[],
        sourceList:[],
        targetList:[]
    })

    useEffect(()=>{
        const getTableInfo=async()=>{
            setState({compareloading:true})
            const result:any = await assetsActionManageService.getCompareInfo({dataAssetId})
            if(httpUtil.checkSuccess(result,1)){
                setState({comparedata:result.data,compareloading:false})
            }else{
                httpUtil.showError(result,1)
                setState({comparedata:{},compareloading:false})
            }
        }
        if(dataAssetId)
            getTableInfo()
    },[dataAssetId])

    

    return state
}