21 lines
2.6 KiB
TypeScript
21 lines
2.6 KiB
TypeScript
import { Space, Tag, Typography } from 'antd';
|
||
import type { ConsultationContextEvidence, ConsultationValue, DemandAnalysis } from '../types';
|
||
|
||
export const consultationLabels: Record<ConsultationValue, string> = { yes: '有咨询意向', no: '无咨询意向', unclear: '咨询信息不足' };
|
||
const leadLabels = { retain_for_review: '保留待核实', not_selected: '暂不保留', insufficient: '信息不足' };
|
||
|
||
export function ConsultationBackground({ values, sources }: { values?: ConsultationContextEvidence[]; sources: DemandAnalysis['sources'] }) {
|
||
return <section data-testid="consultation-background-evidence"><h4>笔记背景依据</h4>{values?.length ? values.map((item, index) => {
|
||
const note = sources.find(source => source.source_ref === item.source_ref && source.kind === 'note');
|
||
return <div key={index}><Typography.Paragraph type="secondary">来源:本次已保存的笔记正文</Typography.Paragraph>{note ? item.evidence.map((quote, quoteIndex) => <Typography.Paragraph key={quoteIndex}>「{quote}」</Typography.Paragraph>) : <Typography.Paragraph type="secondary">背景来源未取得,不补推断。</Typography.Paragraph>}</div>;
|
||
}) : <Typography.Paragraph type="secondary">未引用笔记背景依据。</Typography.Paragraph>}</section>;
|
||
}
|
||
|
||
export function ConsultationDetails({ result, sources }: { result: DemandAnalysis['results'][number]; sources: DemandAnalysis['sources'] }) {
|
||
return <section data-testid="demand-consultation-details" style={{ minWidth: 0, overflowWrap: 'anywhere' }}>
|
||
<Space wrap><Typography.Text strong>咨询意向</Typography.Text><Tag color={result.consultation?.value === 'yes' ? 'processing' : 'default'}>{result.consultation ? consultationLabels[result.consultation.value] : '历史未记录'}</Tag><Typography.Text strong>线索保留</Typography.Text><Tag>{result.lead_disposition ? leadLabels[result.lead_disposition] : '历史未记录'}</Tag></Space>
|
||
{result.consultation && <><Typography.Paragraph>本条咨询依据:{result.consultation.evidence.length ? result.consultation.evidence.map((quote, index) => <span key={index}>「{quote}」{index + 1 < result.consultation!.evidence.length ? ';' : ''}</span>) : '未提供本条逐字依据'}</Typography.Paragraph><ConsultationBackground values={result.consultation.context_evidence} sources={sources} /></>}
|
||
<Typography.Paragraph type="secondary">咨询意向、自身装修需求和业务匹配分别判断;保留待核实不代表需求、身份或地区已确认。笔记背景只解释咨询对象,不作为评论者自身项目事实。</Typography.Paragraph>
|
||
</section>;
|
||
}
|