2023-10-15 00:51:03 +08:00
|
|
|
import { Select, SelectProps } from 'antd';
|
|
|
|
import React from 'react';
|
|
|
|
import { trpc } from '../../api/trpc';
|
|
|
|
import { useCurrentWorkspaceId } from '../../store/user';
|
|
|
|
import { ColorTag } from '../ColorTag';
|
|
|
|
|
|
|
|
interface MonitorPickerProps extends SelectProps<string> {}
|
|
|
|
export const MonitorPicker: React.FC<MonitorPickerProps> = React.memo(
|
|
|
|
(props) => {
|
|
|
|
const workspaceId = useCurrentWorkspaceId();
|
|
|
|
const { data: allMonitor = [] } = trpc.monitor.all.useQuery({
|
|
|
|
workspaceId,
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2023-12-17 18:46:07 +08:00
|
|
|
<Select placeholder="Select monitor" {...props}>
|
2023-10-15 00:51:03 +08:00
|
|
|
{allMonitor.map((m) => (
|
|
|
|
<Select.Option key={m.id} value={m.id}>
|
|
|
|
<ColorTag label={m.type} />
|
|
|
|
{m.name}
|
|
|
|
</Select.Option>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
MonitorPicker.displayName = 'MonitorPicker';
|