import { useQuery } from '@tanstack/react-query' import { topBar } from '../../services/services' import queryKeys from '../../services/queryKeys' export default function TopBar() { // const topBarData = useMutation({ // mutationFn: (reqData) => { // return topBar(reqData) // }, // onError: (error) => { // console.log(error) // }, // onSuccess: (res) => { // if(res?.data?.resultCode != '0'){ // throw({message: 'Something went wrong'}) // } // } // }) // useEffect(()=>{ // let reqData = { // token: localStorage.getItem('token'), // USER TOKEN // uid: localStorage.getItem('uid') // USER UID // } // topBarData.mutate(reqData) // },[]) let reqData = { token: localStorage.getItem('token'), // USER TOKEN uid: localStorage.getItem('uid') // USER UID } const {data:topBarData, isFetching, isError, error} = useQuery({ queryKey: queryKeys.topBar, queryFn: () => topBar(reqData) }) const data = topBarData?.data?.top_bar // top bar data return ( <> {isFetching ? <>

Loading...

: isError?

{error.message}

: <> {data && data?.map((item, index)=>{ let textColor = item?.description == 'Contacts' ? 'text-danger' : item?.description == 'Site Traffic' ? 'text-primary' : item?.description == 'Appointments' ? 'text-orange' : 'text-success' return (

{item?.value || 0}

{item?.data_span}
) })} } ) }