Files
BayIQ-UI/src/features/dashboard/components/SystemHealth.tsx

49 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-11-24 16:17:27 +00:00
import type { SystemHealthStatus } from "../../../types/types";
import Badge from "../../../ui/Badge";
type SystemHealthProps = {
startTime: string;
uptime: string;
statuses: SystemHealthStatus[];
isLoading: boolean;
2025-11-25 15:49:53 +00:00
isError: boolean;
dateUpdatedAt?: number;
};
2025-11-24 16:17:27 +00:00
2025-11-25 15:49:53 +00:00
const SystemHealth = ({ startTime, uptime, statuses, isLoading, isError, dateUpdatedAt }: SystemHealthProps) => {
const updatedDate = dateUpdatedAt ? new Date(dateUpdatedAt).toLocaleString() : null;
// console.log(statuses);
2025-11-25 15:49:53 +00:00
if (isError) {
return <span className="text-red-500">Error loading system health.</span>;
}
if (isLoading) {
return <span className="text-slate-500">Loading system health</span>;
}
2025-11-24 16:17:27 +00:00
return (
2025-11-25 15:49:53 +00:00
<div className="h-100 md:h-75 overflow-y-auto flex flex-col gap-4">
2025-11-24 16:17:27 +00:00
<div className="p-2 border-b border-gray-600 grid grid-cols-2 justify-between">
2025-11-25 15:49:53 +00:00
<div className="flex flex-col border border-gray-600 p-4 rounded-lg mr-4 hover:bg-[#233241]">
2025-11-24 16:17:27 +00:00
<h3 className="text-lg">Start Time</h3> <span className="text-slate-300">{startTime}</span>
</div>
2025-11-25 15:49:53 +00:00
<div className="flex flex-col border border-gray-600 p-4 rounded-lg mr-4 hover:bg-[#233241]">
2025-11-24 16:17:27 +00:00
<h3 className="text-lg">Up Time</h3> <span className="text-slate-300">{uptime}</span>
</div>
</div>
2025-11-25 15:49:53 +00:00
<div className="h-50 overflow-auto">
2025-11-24 16:17:27 +00:00
{statuses?.map((status: SystemHealthStatus) => (
<div className="border border-gray-700 p-4 rounded-md m-2 flex justify-between" key={status.id}>
2025-11-24 16:17:27 +00:00
<span>{status.id}</span> <Badge text={status.tags[0]} />
</div>
))}
</div>
2025-11-25 15:49:53 +00:00
<div className="border-t border-gray-500">
<small className="italic text-gray-400">{`Last refeshed ${updatedDate}`}</small>
</div>
2025-11-24 16:17:27 +00:00
</div>
);
};
export default SystemHealth;