2026-10-26 19:30:23 +08:00
|
|
|
import React from 'react';
|
|
|
|
|
import { Radio } from 'antd';
|
|
|
|
|
import {
|
|
|
|
|
LoginOutlined,
|
|
|
|
|
ClockCircleOutlined,
|
|
|
|
|
CheckCircleFilled,
|
|
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
import './TaskTypeRadio.css'
|
2026-11-09 16:01:23 +08:00
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
2026-10-26 19:30:23 +08:00
|
|
|
type DispatchMode = 'immediate' | 'scheduled';
|
|
|
|
|
|
|
|
|
|
interface TaskTypeRadioProps {
|
|
|
|
|
value: DispatchMode;
|
|
|
|
|
onChange: (value: DispatchMode) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TaskTypeRadio: React.FC<TaskTypeRadioProps> = ({
|
|
|
|
|
value,
|
|
|
|
|
onChange,
|
|
|
|
|
}) => {
|
2026-11-09 16:01:23 +08:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2026-10-26 19:30:23 +08:00
|
|
|
const options: {
|
|
|
|
|
value: DispatchMode;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
icon: React.ReactNode;
|
|
|
|
|
}[] = [
|
|
|
|
|
{
|
|
|
|
|
value: 'immediate',
|
2026-11-09 16:01:23 +08:00
|
|
|
title: t('devices.taskTypeRadio.immediate'),
|
|
|
|
|
description: t('devices.taskTypeRadio.immediateDescription'),
|
2026-10-26 19:30:23 +08:00
|
|
|
icon: <LoginOutlined />,
|
|
|
|
|
},
|
2026-11-19 09:40:36 +08:00
|
|
|
//{
|
|
|
|
|
// value: 'scheduled',
|
|
|
|
|
// title: t('devices.taskTypeRadio.scheduled'),
|
|
|
|
|
// description: t('devices.taskTypeRadio.scheduledDescription'),
|
|
|
|
|
// icon: <ClockCircleOutlined />,
|
|
|
|
|
//},
|
2026-10-26 19:30:23 +08:00
|
|
|
];
|
|
|
|
|
|
2026-11-09 16:01:23 +08:00
|
|
|
|
|
|
|
|
|
2026-10-26 19:30:23 +08:00
|
|
|
return (
|
|
|
|
|
<div className="task-type-radio">
|
|
|
|
|
<div className="task-type-radio__title">
|
2026-11-09 16:01:23 +08:00
|
|
|
{t('devices.taskTypeRadio.taskType')}
|
2026-10-26 19:30:23 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Radio.Group
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={(e) => onChange(e.target.value)}
|
|
|
|
|
className="task-type-radio__group"
|
|
|
|
|
>
|
|
|
|
|
{options.map((option) => {
|
|
|
|
|
const checked = value === option.value;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Radio
|
|
|
|
|
key={option.value}
|
|
|
|
|
value={option.value}
|
|
|
|
|
className="task-type-radio__option"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className={[
|
|
|
|
|
'task-type-radio__card',
|
|
|
|
|
checked
|
|
|
|
|
? 'task-type-radio__card--checked'
|
|
|
|
|
: '',
|
|
|
|
|
]
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
.join(' ')}
|
|
|
|
|
>
|
|
|
|
|
<div className="task-type-radio__icon">
|
|
|
|
|
{option.icon}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="task-type-radio__content">
|
|
|
|
|
<div className="task-type-radio__name">
|
|
|
|
|
{option.title}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="task-type-radio__description">
|
|
|
|
|
{option.description}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="task-type-radio__status">
|
|
|
|
|
{checked ? (
|
|
|
|
|
<CheckCircleFilled />
|
|
|
|
|
) : (
|
|
|
|
|
<span className="task-type-radio__empty" />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Radio>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Radio.Group>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TaskTypeRadio;
|