import React, { useEffect, useState } from 'react'; import { useSearchParams, Link } from 'react-router-dom'; import './_shell/tokens.css'; import './_shell/shell.css'; import useViewportMode from './_shell/useViewportMode'; import BottomNav from './_shell/BottomNav'; import DesktopHeader from './_shell/DesktopHeader'; import TopRibbon from './_shell/TopRibbon'; import TitleBlock from './_shell/TitleBlock'; import Mascot from './_shell/Mascot'; import MascotBubble from './_shell/MascotBubble'; import OrnateFrame from './_shell/OrnateFrame'; import PrimaryButton from './_shell/PrimaryButton'; import GhostButton from './_shell/GhostButton'; import { compatGetReading } from '../../api'; export default function CompatibilityResult() { const mode = useViewportMode(); const [params] = useSearchParams(); const cid = params.get('cid'); const [result, setResult] = useState(null); const [error, setError] = useState(null); useEffect(() => { if (!cid) return; compatGetReading(parseInt(cid, 10)) .then(setResult) .catch((e) => setError(e?.message || '결과를 가져오지 못했어요.')); }, [cid]); const interp = result?.interpretation_json || {}; const strengths = interp.strengths || []; const challenges = interp.challenges || []; return (
{mode === 'desktop' && }
{!cid && ( <>
궁합 입력하러 가기
)} {cid && !result && !error && (
)} {cid && error && (
window.location.reload()}>다시 시도
)} {result && ( <>
{result.score}
{interp.summary && (
요약
{interp.summary}
)} {strengths.length > 0 && (
강점
    {strengths.map((s, i) => (
  • {s}
  • ))}
)} {challenges.length > 0 && (
주의할 점
    {challenges.map((s, i) => (
  • {s}
  • ))}
)} )}
{mode === 'mobile' && }
); }