import { CoreButton } from "../../core/ui/button/button"; import { Icon } from "../../core/ui/icons/icons"; import { Dropdown } from "antd"; import { CoreText, CoreTextType } from "../../core/ui/text/text"; import { ProcessStatus } from "../dataset/dataset_model"; import { IMenuItem } from "../dataset/card_dataset"; import type { MenuProps } from "antd"; import { match } from "ts-pattern"; export interface ISkillCardProps { processStatus?: string; name?: string; isFinished?: boolean; id?: string; emptyOnClick?: Function; startOnClick?: (id: string) => void; continueOnClick?: (id: string) => void; empty: boolean; onEdit?: (id: string) => void; epoch?: number; onDelete?: (id: string) => void; datasetName?: string; epochNextTraining?: number; } export const SkillCard = (props: ISkillCardProps) => { const menu: IMenuItem[] = [ { onClick: () => { if (props.onEdit && props.id) props.onEdit(props.id); }, name: "Редактировать", }, { onClick: () => { if (props.onDelete && props.id) props.onDelete(props.id); }, name: "Удалить", }, ]; const items: MenuProps["items"] = menu.map((el, index) => { return { key: String(index), label: , onClick: () => el.onClick(props.id), }; }); return (
{match(props.empty) .with(true, () => ( <>
{ if (props.empty && props.emptyOnClick) props.emptyOnClick(); }} style={{ display: "flex", justifyContent: "center", alignItems: "center" }} >
)) .with(false, () => ( <> <>
{match(props.processStatus) .with(ProcessStatus.ERROR, () => ( <> { if (props.startOnClick && props.id) props.startOnClick(props.id); }} filled={true} text="Ошибка" /> )) .with(ProcessStatus.END, () => ( <> { if (props.continueOnClick && props.id) props.continueOnClick(props.id); }} />
{ if (props.startOnClick && props.id) props.startOnClick(props.id); }} /> )) .with(ProcessStatus.NONE, () => ( <> { if (props.startOnClick && props.id) props.startOnClick(props.id); }} /> )) .otherwise(() => ( <> ))}
)) .otherwise(() => ( <> ))}
); };