Files
KAFM-Project/components/dashboard/intelligence/assetHealth.tsx

184 lines
8.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useState } from 'react';
import {
Zap,
AlertTriangle,
Activity,
Plus,
Sparkles,
ShieldAlert,
IndianRupee,
Clock,
ShieldCheck
} from "lucide-react";
import Button from "@/components/common/button";
import StatCard from "@/components/common/dashStatCard";
import InfoBanner from '@/components/common/infoBanner';
import { Card } from '@/components/common/cardWrapper'; // Assuming Card wrapper location
import { CardHeader } from '@/components/common/cardHeader'; // Assuming CardHeader location
import Table from '@/components/common/dataTable';
import { assetHealthheaders, assetHealthrows } from '@/constants/tabledata';
export default function AssetHealthPortal() {
return (
<div className="my-15 text-slate-100 font-sans">
{/* --- HEADER SECTION --- */}
<div className="flex flex-col md:flex-row md:items-start md:justify-between gap-4 mb-6">
<div>
<div className="flex items-center gap-2 text-[10px] font-bold tracking-widest uppercase font-mono">
<span className="text-teal-400">Apple One HQ Tower</span>
<span className="text-slate-500"></span>
<span className="text-slate-500">INTELLIGENCE</span>
<span className="text-slate-500"></span>
<span className="text-slate-500">ASSET HEALTH</span>
</div>
<h1 className="text-2xl font-bold text-white tracking-tight mt-2">
Asset health & reliability
</h1>
<p className="text-sm font-medium text-slate-400 mt-2 max-w-xl leading-relaxed">
A live health index per asset from reliability signals MTBF, MTTR and criticality drive condition-based PM instead of fixed calendars.
</p>
</div>
{/* --- HEADER BUTTONS --- */}
<div className="flex items-center gap-3 self-start md:mt-10">
<Button className="bg-[#0b1727] hover:bg-slate-800/60 text-slate-200 border border-slate-800 text-xs px-4 py-2 rounded-lg flex items-center gap-2 font-semibold transition-colors">
<Activity className="w-4 h-4 text-slate-300" />
<span>Model insights</span>
</Button>
<Button className="bg-[#2dd4bf] hover:bg-teal-300 text-slate-950 font-bold text-xs px-4 py-2 rounded-lg flex items-center gap-2 transition-colors">
<Plus className="w-4 h-4 stroke-[3]" />
<span>Raise PM</span>
</Button>
</div>
</div>
{/* --- STAT CARDS --- */}
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
{/* Card 1: Predicted failures */}
<StatCard
variant="icon"
title="Fleet health index"
value="69"
icon={ShieldCheck}
badgeText="weighted"
badgeClassName="text-amber-400 lowercase font-mono"
iconContainerClassName="bg-amber-950/40 border-amber-800/30 text-amber-400"
/>
<StatCard
variant="icon"
title="Assets at risk"
value="1"
icon={AlertTriangle}
badgeText="health < 58"
badgeClassName="text-rose-400 lowercase font-mono"
iconContainerClassName="bg-rose-950/40 border-rose-800/30 text-rose-400"
/>
<StatCard
variant="icon"
title="Mean time between failures"
value="204d"
icon={Clock}
badgeText="avg"
badgeClassName="text-blue-400 lowercase font-mono"
iconContainerClassName="bg-blue-950/50 border-blue-800/30 text-blue-400"
/>
<StatCard
variant="icon"
title="Mean time to repair"
value="6.3h"
icon={Activity}
badgeText="avg"
badgeClassName="text-emerald-400 lowercase font-mono"
iconContainerClassName="bg-emerald-950/40 border-emerald-800/30 text-emerald-400"
/>
</div>
{/* --- MAIN CONTENT GRID (TABLE + RIGHT SIDE CARDS) --- */}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
{/* Left Section: Asset Health Register Table Container */}
<div className="lg:col-span-2 bg-[#0b1727] border
border-slate-800/80 rounded-xl p-4 flex flex-col justify-between">
<div>
<div className="flex items-center justify-between mb-4">
<h2 className="text-base font-bold text-white tracking-tight">Asset health register</h2>
<span className="text-xs font-mono text-slate-500 lowercase">condition-based</span>
</div>
<Table headers={assetHealthheaders} rows={assetHealthrows}/>
</div>
</div>
{/* Right Section: Reliability & Condition Mix Side Panel */}
<div className="flex flex-col gap-4">
{/* Card 1: Reliability by group */}
<div className="bg-[#0b1727] border border-slate-800/80 rounded-xl p-5">
<h3 className="text-base font-bold text-white mb-6">Reliability by group</h3>
<div className="space-y-4 text-sm font-medium">
{/* Electrical */}
<div className="flex items-center justify-between gap-4">
<span className="text-slate-300 w-24">Electrical</span>
<div className="flex-1 bg-slate-800/80 h-2 rounded-full overflow-hidden">
<div className="bg-amber-400 h-full rounded-full" style={{ width: '75%' }}></div>
</div>
<span className="text-amber-400 font-bold font-mono text-xs w-6 text-right">75</span>
</div>
{/* Plumbing */}
<div className="flex items-center justify-between gap-4">
<span className="text-slate-300 w-24">Plumbing</span>
<div className="flex-1 bg-slate-800/80 h-2 rounded-full overflow-hidden">
<div className="bg-emerald-400 h-full rounded-full" style={{ width: '86%' }}></div>
</div>
<span className="text-emerald-400 font-bold font-mono text-xs w-6 text-right">86</span>
</div>
</div>
</div>
{/* Card 2: Condition mix */}
<div className="bg-[#0b1727] border border-slate-800/80 rounded-xl p-5 ">
<h3 className="text-base font-bold text-white mb-6">Condition mix</h3>
<div className="space-y-4 text-sm font-medium">
{/* Healthy */}
<div className="flex items-center justify-between gap-4">
<span className="text-slate-300 w-24">Healthy</span>
<div className="flex-1 bg-slate-800/80 h-2 rounded-full overflow-hidden">
<div className="bg-emerald-400 h-full rounded-full" style={{ width: '50%' }}></div>
</div>
<span className="text-slate-300 font-bold font-mono text-xs w-6 text-right">4</span>
</div>
{/* Watch */}
<div className="flex items-center justify-between gap-4">
<span className="text-slate-300 w-24">Watch</span>
<div className="flex-1 bg-slate-800/80 h-2 rounded-full overflow-hidden">
<div className="bg-amber-400 h-full rounded-full" style={{ width: '50%' }}></div>
</div>
<span className="text-slate-300 font-bold font-mono text-xs w-6 text-right">4</span>
</div>
{/* At risk */}
<div className="flex items-center justify-between gap-4">
<span className="text-slate-300 w-24">At risk</span>
<div className="flex-1 bg-slate-800/80 h-2 rounded-full overflow-hidden">
<div className="bg-rose-500 h-full rounded-full" style={{ width: '0%' }}></div>
</div>
<span className="text-slate-300 font-bold font-mono text-xs w-6 text-right">0</span>
</div>
</div>
</div>
</div>
</div>
{/* --- INFO BANNER --- */}
<div className="mt-5">
<InfoBanner
boldText="How it works:"
normalText="reliability signals (runtime, faults, vibration, PPM history) roll into a 0100 health index. Assets that drop below threshold auto-surface here and can raise a condition-based PM in one click — replacing fixed-calendar servicing on healthy assets."
/>
</div>
</div>
);
}