feat(web): user summary api update
This commit is contained in:
@@ -1218,6 +1218,8 @@ export const en = {
|
|||||||
key_findings: 'Key Findings',
|
key_findings: 'Key Findings',
|
||||||
behavior_pattern: 'Behavior Pattern',
|
behavior_pattern: 'Behavior Pattern',
|
||||||
growth_trajectory: 'Growth Trajectory',
|
growth_trajectory: 'Growth Trajectory',
|
||||||
|
personality: 'Personality Traits',
|
||||||
|
core_values: 'Core Values',
|
||||||
},
|
},
|
||||||
space: {
|
space: {
|
||||||
createSpace: 'Create Space',
|
createSpace: 'Create Space',
|
||||||
|
|||||||
@@ -1299,6 +1299,8 @@ export const zh = {
|
|||||||
key_findings: '关键发现',
|
key_findings: '关键发现',
|
||||||
behavior_pattern: '行为模式',
|
behavior_pattern: '行为模式',
|
||||||
growth_trajectory: '成长轨迹',
|
growth_trajectory: '成长轨迹',
|
||||||
|
personality: '性格特点',
|
||||||
|
core_values: '核心价值观',
|
||||||
},
|
},
|
||||||
space: {
|
space: {
|
||||||
createSpace: '创建空间',
|
createSpace: '创建空间',
|
||||||
|
|||||||
@@ -5,16 +5,25 @@ import { Skeleton } from 'antd';
|
|||||||
|
|
||||||
import RbCard from '@/components/RbCard/Card'
|
import RbCard from '@/components/RbCard/Card'
|
||||||
import Empty from '@/components/Empty';
|
import Empty from '@/components/Empty';
|
||||||
|
import RbAlert from '@/components/RbAlert';
|
||||||
import {
|
import {
|
||||||
getUserSummary,
|
getUserSummary,
|
||||||
} from '@/api/memory'
|
} from '@/api/memory'
|
||||||
import type { AboutMeRef } from '../types'
|
import type { AboutMeRef } from '../types'
|
||||||
|
|
||||||
|
|
||||||
|
interface Data {
|
||||||
|
user_summary: string;
|
||||||
|
personality: string;
|
||||||
|
core_values: string;
|
||||||
|
one_sentence: string;
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
||||||
const AboutMe = forwardRef<AboutMeRef>((_props, ref) => {
|
const AboutMe = forwardRef<AboutMeRef>((_props, ref) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
const [data, setData] = useState<string | null>(null)
|
const [data, setData] = useState<Data>({} as Data)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!id) return
|
if (!id) return
|
||||||
@@ -27,7 +36,7 @@ const AboutMe = forwardRef<AboutMeRef>((_props, ref) => {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
getUserSummary(id)
|
getUserSummary(id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setData((res as { summary?: string }).summary || null)
|
setData((res as Data) || null)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@@ -44,10 +53,29 @@ const AboutMe = forwardRef<AboutMeRef>((_props, ref) => {
|
|||||||
>
|
>
|
||||||
{loading
|
{loading
|
||||||
? <Skeleton className="rb:mt-4" />
|
? <Skeleton className="rb:mt-4" />
|
||||||
: data
|
: Object.keys(data).filter(key => data[key] !== null).length > 0
|
||||||
? <div className="rb:font-regular rb:leading-5 rb:text-[#5B6167]">
|
? <>
|
||||||
{data || '-'}
|
{data.user_summary &&
|
||||||
</div>
|
<div className="rb:font-regular rb:leading-5 rb:text-[#5B6167]">
|
||||||
|
{data.user_summary}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{data.personality && <>
|
||||||
|
<div className="rb:pt-4 rb:font-medium rb:leading-5 rb:mb-2">{t('userMemory.personality')}</div>
|
||||||
|
<div className="rb:font-regular rb:leading-5 rb:text-[#5B6167]">
|
||||||
|
{data.personality}
|
||||||
|
</div>
|
||||||
|
</>}
|
||||||
|
{data.core_values && <>
|
||||||
|
<div className="rb:pt-4 rb:font-medium rb:leading-5 rb:mb-2">{t('userMemory.core_values')}</div>
|
||||||
|
<div className="rb:font-regular rb:leading-5 rb:text-[#5B6167]">
|
||||||
|
{data.core_values}
|
||||||
|
</div>
|
||||||
|
</>}
|
||||||
|
{data.one_sentence &&
|
||||||
|
<RbAlert className="rb:mt-4">{data.one_sentence}</RbAlert>
|
||||||
|
}
|
||||||
|
</>
|
||||||
: <Empty size={88} className="rb:mt-12 rb:mb-20.25" />
|
: <Empty size={88} className="rb:mt-12 rb:mb-20.25" />
|
||||||
}
|
}
|
||||||
</RbCard>
|
</RbCard>
|
||||||
|
|||||||
Reference in New Issue
Block a user