import React,{useState,useEffect} from "react"; import EmpProfile from "../../components/Employee/EmpProfile"; import axios from "axios"; import Breadcrumb from "../../components/common/Breadcrumb"; import EmployeeNav from "../../components/Employee/EmployeeNav"; import { useSearchParams,useParams } from "react-router-dom"; import { getCachedData } from "../../slices/apiDataManager"; import { useEmployeeProfile, useEmployees, useEmployeesByProject } from "../../hooks/useEmployees"; import { useSelector } from "react-redux"; import EmployeeRepository from "../../repositories/EmployeeRepository"; const EmployeeProfile = () => { const projectID = useSelector((store)=>store.localVariables.projectId) const {employeeId} = useParams(); // const {employee,loading} = useEmployeeProfile(employeeId) const [loading,setLoading] = useState(true) const [SearchParams] = useSearchParams() const tab = SearchParams.get( "for" ) const [activePill, setActivePill] = useState(tab); const[currentEmployee,setCurrentEmployee] = useState() const handlePillClick = (pillKey) => { setActivePill(pillKey); }; const fetchEmployeeProfile = async( employeeID ) => { try { const resp = await EmployeeRepository.getEmployeeProfile( employeeID ) setCurrentEmployee( resp.data ) setLoading(false) } catch ( err ) { console.log( "Faild to fetch employee data,", err ) setLoading(false) } } useEffect(() => { if ( employeeId ) { fetchEmployeeProfile(employeeId) } }, [employeeId]); const renderContent = () => { if (loading) return
Loading
; switch (activePill) { case "account": { return (
{/*
*/}

Account

{/*
*/}
); } case "attendance": { return (
{/* Teams */}

attendance component

{/* Teams */}
); break; } case "activities": { return (

activites components

); break; } default: return

Coming Soon!

We're currently working on this feature and will have it ready shortly. Thank you for your patience!

girl-doing-yoga-light
; } }; if (loading) { return
Loading...
; } return (
user-avatar

{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}


Contacts
  • Contact Number: {currentEmployee?.emergencyPhoneNumber || NA}
  • Email: {currentEmployee?.email || NA}
  • Contact Person: {currentEmployee?.emergencyContactPerson}
  • Address:
  • {currentEmployee?.peramnentAddress}
{renderContent()}
); }; export default EmployeeProfile;