57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { ghostBtnClass } from './constants.tsx';
|
|
import type { IotComputedDashboard } from './types.ts';
|
|
|
|
export interface IotPanelDashboardHeaderProps {
|
|
computed: IotComputedDashboard;
|
|
apiStatusLine: string | null;
|
|
apiOnline: boolean;
|
|
error: string | null;
|
|
isRefreshing: boolean;
|
|
onRefresh: () => void;
|
|
}
|
|
|
|
const IotPanelDashboardHeader: React.FC<IotPanelDashboardHeaderProps> = ({
|
|
computed,
|
|
apiStatusLine,
|
|
apiOnline,
|
|
error,
|
|
isRefreshing,
|
|
onRefresh,
|
|
}) => (
|
|
<header className="mb-0.5 flex items-center justify-between gap-3">
|
|
<div className="min-w-0 pr-2">
|
|
<p className="text-sm text-[#687b91]">{computed.datetime}</p>
|
|
<h1 className="my-0.5 text-3xl font-bold text-[#123f7c]">{computed.dashboardTitle}</h1>
|
|
<p className="text-sm text-[#687b91]">{computed.deviceName}</p>
|
|
{apiStatusLine && (
|
|
<p
|
|
className={`mt-1 text-[13px] font-bold ${apiOnline ? 'text-[#1f8a4d]' : 'text-[#b23b3b]'}`}
|
|
>
|
|
{apiStatusLine}
|
|
</p>
|
|
)}
|
|
{error && (
|
|
<p className="mt-1 min-h-[18px] text-xs text-[#b23b3b]" role="status" aria-live="polite">
|
|
{error}
|
|
</p>
|
|
)}
|
|
</div>
|
|
<div className="flex shrink-0 items-center gap-2">
|
|
<button
|
|
type="button"
|
|
className={ghostBtnClass}
|
|
disabled={isRefreshing}
|
|
onClick={() => void onRefresh()}
|
|
>
|
|
{isRefreshing ? 'Refreshing...' : 'Refresh'}
|
|
</button>
|
|
<button type="button" className={ghostBtnClass}>
|
|
Kelola Lantai
|
|
</button>
|
|
</div>
|
|
</header>
|
|
);
|
|
|
|
export default IotPanelDashboardHeader;
|