From 44bbff297f5f0a42715a4d3750162586a480c40b Mon Sep 17 00:00:00 2001 From: gahusb Date: Sun, 24 May 2026 00:45:01 +0900 Subject: [PATCH] =?UTF-8?q?feat(tarot):=20TodayCard.jsx=20=E2=80=94=20?= =?UTF-8?q?=EC=9B=90=EC=B9=B4=EB=93=9C=20=ED=8E=98=EC=9D=B4=EC=A7=80=20(T1?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- src/pages/tarot/TodayCard.jsx | 98 +++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/pages/tarot/TodayCard.jsx diff --git a/src/pages/tarot/TodayCard.jsx b/src/pages/tarot/TodayCard.jsx new file mode 100644 index 0000000..e3378df --- /dev/null +++ b/src/pages/tarot/TodayCard.jsx @@ -0,0 +1,98 @@ +import React, { useState } from 'react'; +import './Tarot.css'; +import { TAROT_DECK, CATEGORIES } from './data/cards'; +import { useTarotReading } from './hooks/useTarotReading'; +import TarotCard from './components/TarotCard'; +import InterpretationPanel from './components/InterpretationPanel'; + +export default function TodayCard() { + const [category, setCategory] = useState('일반'); + const [question, setQuestion] = useState(''); + const [pick, setPick] = useState(null); + const { status, interpretation, runInterpretAndSave, error } = useTarotReading(); + + const drawCard = () => { + const idx = Math.floor(Math.random() * TAROT_DECK.length); + const reversed = Math.random() < 0.5; + const card = TAROT_DECK[idx]; + setPick({ card, position: '오늘', reversed }); + }; + + const handleStart = () => { + drawCard(); + }; + + const handleInterpret = async () => { + if (!pick) return; + try { + await runInterpretAndSave({ + spread_type: 'one_card', + category, + question: question.trim() || null, + picks: [pick], + }); + } catch (e) { + // error는 hook의 state로 전달됨 + } + }; + + const selectedCardMeaning = pick?.card || null; + const focusCardId = pick?.card?.slug; + + const busy = status === 'interpreting' || status === 'saving'; + + return ( +
+