43 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-12-17 19:08:11 +08:00
import { Empty } from 'antd';
import React from 'react';
import { trpc } from '../../../api/trpc';
import { Loading } from '../../Loading';
import { MonitorListItem } from '../MonitorListItem';
2023-12-17 19:08:11 +08:00
interface StatusPageServicesProps {
workspaceId: string;
monitorList: PrismaJson.MonitorStatusPageList;
}
export const StatusPageServices: React.FC<StatusPageServicesProps> = React.memo(
(props) => {
const { workspaceId, monitorList } = props;
const { data: list = [], isLoading } = trpc.monitor.getPublicInfo.useQuery({
monitorIds: monitorList.map((item) => item.id),
});
if (isLoading) {
return <Loading />;
}
2023-12-17 19:08:11 +08:00
return (
<div className="shadow-2xl p-2.5 flex flex-col gap-4">
{list.length > 0 ? (
list.map((item) => (
2023-12-17 19:08:11 +08:00
<div key={item.id} className="hover:bg-black hover:bg-opacity-20">
<MonitorListItem
2023-12-17 19:08:11 +08:00
workspaceId={workspaceId}
monitorId={item.id}
monitorName={item.name}
2023-12-17 19:08:11 +08:00
/>
</div>
))
) : (
<Empty description="No any monitor has been set" />
)}
</div>
);
}
);
StatusPageServices.displayName = 'StatusPageServices';