Source

pages/Dashboard/Company/Company.jsx

import React, { useEffect, useState } from 'react'
import axios from 'axios';
import baseUrl from '../../../array/base/config';
import LoadingAnimation from '../Loading/LoadingAnimation';

/**
 * Represents a Company page for showing company details
 * @module Company
 * @returns {JSX.Element} Returns a JSX code for showing company details
 */
const Company = () => {
    /**
     * React state that holds company details
     * @constant {object} company
     * @type {object}
     * @default {{}}
     * @memberof module:Company
     */
    const [company, setCompany] = useState({})
    /**
     *
     * React state that holds loading status
     * @constant {boolean} isLoading
     * @type {boolean}
     * @default true
     * @memberof module:Company
     */
    const [isLoading, setIsLoading] = useState(true);

    useEffect(() => {
        apicall()
    }, []);

    /**
     * Function that calls api to get company details
     * @memberof module:Company
     * @inner
     * @function apicall
     */
    const apicall = () => {
        const id = 2;
        const detail = localStorage.getItem('token')
        axios({
            method: 'get',
            url: `${baseUrl}/api/company/${id}/`,
            headers: {
                "Authorization":
                    `Token ${detail}`,
            },
        }).then(res => {

            setCompany(res?.data?.data);
            setIsLoading(false);
        })
            .catch(err => console.log(err));
    }

    if (isLoading) {
        return <LoadingAnimation/>;
    }
    return (
        <>

        </>
    )
}

export default Company