import React, { useState, useEffect } from "react"; import Icons from "../../Helpers/Icons"; import usersService from "../../../services/UsersService"; export default function LoginActivityTab() { const api = new usersService(); const [userHistory, setUserHistory] = useState([]) // State for user login history //page loading status const [isLoading, setIsloading] = useState({ status: true, message: 'loading' }) const getUserLoginHistory = async () => { try { const res = await api.getUserLoginHistory(); console.log(res.status == 200) if(res.status != 200){ setIsloading({ status: false, message: `Couldn't get user history, try again` }) return } if(res.status == 200 && res.data.loginhx.length < 1){ setIsloading({ status: false, message: `No User History found` }) return } setUserHistory(res.data.loginhx); setIsloading({ status: false, message: `` }) } catch(error) { setIsloading({ status: false, message: `Opps! something went wrong` }) } }; useEffect(() => { getUserLoginHistory(); }, []); return (
{ isLoading.status == true ?
Loading...
: { userHistory.length > 0 ? userHistory.map((data, index)=>( <> )) : <> }
Channel Date Location
{data.channel}
{data.added.split(' ')[0]}
{data.loc}
{isLoading.message}
}
); }