Reconmap/web-client

View on GitHub
src/components/layout/dashboard/widgets/ApiHealthWidget.jsx

Summary

Maintainability
A
0 mins
Test Coverage
import useFetch from "hooks/useFetch";
import DashboardWidget from "./Widget";

const GreenYes = () => <span style={{ color: 'green' }}>Yes</span>;
const RedNo = () => <span style={{ color: 'red' }}>No</span>;

const ApiHealthWidget = () => {
    const [apiHealth] = useFetch('/system/health');

    return <DashboardWidget title="API health">
        {apiHealth && <>
            <dl>
                <dt>Response</dt>
                <dd style={{ color: 'green' }}>Ok</dd>

                <dt>Attachments directory is writeable</dt>
                <dd>{apiHealth.attachmentsDirectory.writeable ? <GreenYes /> : <RedNo />}</dd>
            </dl>
        </>}
    </DashboardWidget>
}

export default ApiHealthWidget;