feat(saju-ui-v2): Compatibility.jsx — placeholder → 두 사람 입력 폼 + compat API
This commit is contained in:
@@ -1,19 +1,55 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import './Saju.css';
|
import './_shell/tokens.css';
|
||||||
import SajuNav from './components/SajuNav';
|
import './_shell/shell.css';
|
||||||
import HoryungMascot from './components/HoryungMascot';
|
import useViewportMode from './_shell/useViewportMode';
|
||||||
|
import BottomNav from './_shell/BottomNav';
|
||||||
|
import DesktopHeader from './_shell/DesktopHeader';
|
||||||
|
import MatchMobile from './views/match.mobile.jsx';
|
||||||
|
import MatchDesktop from './views/match.desktop.jsx';
|
||||||
|
import { compatInterpret } from '../../api';
|
||||||
|
|
||||||
|
const EMPTY_PERSON = {
|
||||||
|
name: '', year: '', month: '', day: '', hour: null,
|
||||||
|
gender: 'male', calendar_type: 'solar',
|
||||||
|
};
|
||||||
|
|
||||||
export default function Compatibility() {
|
export default function Compatibility() {
|
||||||
|
const mode = useViewportMode();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [personA, setPersonA] = useState({ ...EMPTY_PERSON });
|
||||||
|
const [personB, setPersonB] = useState({ ...EMPTY_PERSON });
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
const handleSubmit = async (e) => {
|
||||||
|
if (e && e.preventDefault) e.preventDefault();
|
||||||
|
setError(null);
|
||||||
|
if (!personA.year || !personA.month || !personA.day ||
|
||||||
|
!personB.year || !personB.month || !personB.day) {
|
||||||
|
setError('두 사람의 생년월일을 입력해주세요.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const res = await compatInterpret({ person_a: personA, person_b: personB });
|
||||||
|
navigate(`/saju/compatibility/result?cid=${res.reading_id}`);
|
||||||
|
} catch (err) {
|
||||||
|
setError(err?.message || '궁합 풀이에 실패했어요.');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
personA, personB, onChangeA: setPersonA, onChangeB: setPersonB,
|
||||||
|
onSubmit: handleSubmit, loading, error,
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className="saju-page">
|
<div className="saju-v2">
|
||||||
<SajuNav />
|
{mode === 'desktop' && <DesktopHeader />}
|
||||||
<div className="saju-stub">
|
{mode === 'desktop' ? <MatchDesktop {...props} /> : <MatchMobile {...props} />}
|
||||||
<HoryungMascot pose="thinking" />
|
{mode === 'mobile' && <BottomNav theme="ivory" />}
|
||||||
<h2 className="saju-h2">궁합보기는 곧 만나요</h2>
|
|
||||||
<p>두 사람의 사주를 함께 풀어보는 기능을 준비 중입니다.<br />조금만 기다려 주세요.</p>
|
|
||||||
<Link to="/saju">메인으로 돌아가기</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user