import { useEffect, useState, forwardRef, useImperativeHandle } from 'react' import { useTranslation } from 'react-i18next' import { useParams } from 'react-router-dom' import Empty from '@/components/Empty' import RbCard from '@/components/RbCard/Card' import { getEmotionSuggestions } from '@/api/memory' import RbAlert from '@/components/RbAlert' interface Suggestions { health_summary: string; suggestions: Array<{ type: string; title: string; content: string; priority: string; actionable_steps: string[]; }>; } const Suggestions = forwardRef<{ handleRefresh: () => void; }>((_props, ref) => { const { t } = useTranslation() const { id } = useParams() const [loading, setLoading] = useState(false) const [suggestions, setSuggestions] = useState(null) useEffect(() => { getSuggestionData() }, [id]) const getSuggestionData = () => { if (!id) { return } setLoading(true) getEmotionSuggestions(id) .then((res) => { setSuggestions(res as Suggestions) }) .finally(() => { setLoading(false) }) } useImperativeHandle(ref, () => ({ handleRefresh: getSuggestionData })); return ( {suggestions?.suggestions && suggestions?.suggestions.length > 0 ? <> {suggestions.health_summary}
{suggestions.suggestions.map((item, index) => (
{index + 1}. {item.title}
{item.content}
    {item.actionable_steps.map((vo, idx) =>
  • {vo}
  • )}
))}
: }
) }) export default Suggestions