import type { FC } from "react";
import React from "react";
import cn from "classnames";
import { ArrowUpRightIcon } from "@heroicons/react/24/outline";
import Switch from "@/app/components/base/switch";
import Divider from "@/app/components/base/divider";
import Indicator from "@/app/components/header/indicator";
import { formatNumber } from "@/utils/format";
import type { SegmentDetailModel } from "@/models/datasets";
import { StatusItem } from "../../list";
import s from "./style.module.css";
import { SegmentIndexTag } from "./index";
import { DocumentTitle } from '../index'
import { useTranslation } from "react-i18next";
const ProgressBar: FC<{ percent: number; loading: boolean }> = ({ percent, loading }) => {
return (
{loading ? null : percent.toFixed(2)}
)
}
export type UsageScene = 'doc' | 'hitTesting'
type ISegmentCardProps = {
loading: boolean;
detail?: SegmentDetailModel & { document: { name: string } };
score?: number
onClick?: () => void;
onChangeSwitch?: (segId: string, enabled: boolean) => Promise;
scene?: UsageScene
className?: string;
};
const SegmentCard: FC = ({
detail = {},
score,
onClick,
onChangeSwitch,
loading = true,
scene = 'doc',
className = ''
}) => {
const { t } = useTranslation()
const {
id,
position,
enabled,
content,
word_count,
hit_count,
index_node_hash,
} = detail as any;
const isDocScene = scene === 'doc'
return (
onClick?.()}
>
{isDocScene ? <>
{loading ? (
) : (
<>
) =>
e.stopPropagation()
}
className="inline-flex items-center"
>
{
await onChangeSwitch?.(id, val)
}}
/>
>
)}
> :
}
{loading ? (
) : (
isDocScene ? <>
{content}
{formatNumber(word_count)}
{formatNumber(hit_count)}
> : <>
{content}
{t('datasetHitTesting.viewChart')}
>
)}
);
};
export default SegmentCard;