import {useCallback} from "react"
import {useSetState} from "ahooks"

interface props1{
    visible:boolean,
    currentItem:any,
    type:string,
    [props:string]:any
}

export const useGetModalInfoAndAction=()=>{
    const [state,setState] = useSetState<props1>({
        visible:false,
        currentItem:{},
        type:''
    })

    const openModal=useCallback((item:any,odata?:any)=>{
        setState({visible:true,currentItem:item,...odata})
    },[])

    const cancelModal:any=useCallback((odata?:any)=>{
        setState({visible:false,currentItem:{},...odata})
    },[])

    const payload:props1={
        ...state,
        openModal,cancelModal
    }

    return payload
}