import React, {useEffect} from 'react' import { useMutation } from '@tanstack/react-query' import { topBar } from '../../services/services' 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) },[]) const data = topBarData?.data?.data?.top_bar // top bar data return ( <> {topBarData.isPending ? <>

Loading...

: topBarData.error ?

{topBarData.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}
{item?.description}
N/A
) })} } ) }