diff --git a/src/pages/lotto/components/decision/BulkPurchaseButton.jsx b/src/pages/lotto/components/decision/BulkPurchaseButton.jsx new file mode 100644 index 0000000..afe996e --- /dev/null +++ b/src/pages/lotto/components/decision/BulkPurchaseButton.jsx @@ -0,0 +1,33 @@ +import { useState } from 'react'; +import { bulkPurchase } from '../../../../api'; +import { MODES } from './TierModeToggle'; + +export default function BulkPurchaseButton({ drawNo, tierMode, onSuccess }) { + const [busy, setBusy] = useState(false); + const mode = MODES.find(m => m.key === tierMode) || MODES[0]; + + const onClick = async () => { + if (busy) return; + setBusy(true); + try { + await bulkPurchase({ + draw_no: drawNo, + tier_mode: tierMode, + sets: mode.sets, + amount: mode.amount, + }); + onSuccess?.(); + alert(`${mode.sets}세트 구매 기록 완료!`); + } catch (e) { + alert(`구매 기록 실패: ${e?.message || e}`); + } finally { + setBusy(false); + } + }; + + return ( + + ); +} diff --git a/src/pages/lotto/components/decision/DecisionCard.jsx b/src/pages/lotto/components/decision/DecisionCard.jsx new file mode 100644 index 0000000..492510c --- /dev/null +++ b/src/pages/lotto/components/decision/DecisionCard.jsx @@ -0,0 +1,102 @@ +import { useEffect, useMemo, useState } from 'react'; +import RetrospectiveBox from './RetrospectiveBox'; +import TierModeToggle, { MODES } from './TierModeToggle'; +import TierSection from './TierSection'; +import BulkPurchaseButton from './BulkPurchaseButton'; +import './decision.css'; + +const TIER_CHAIN = { + core: ['core'], + core_bonus: ['core', 'bonus'], + core_bonus_extended: ['core', 'bonus', 'extended'], + full: ['core', 'bonus', 'extended', 'pool'], +}; + +const STORAGE_KEY = 'lotto.tier_mode'; + +export default function DecisionCard({ briefing, review, onPurchaseSuccess }) { + const [tierMode, setTierMode] = useState(() => + localStorage.getItem(STORAGE_KEY) || 'core' + ); + + useEffect(() => { + localStorage.setItem(STORAGE_KEY, tierMode); + }, [tierMode]); + + const visibleTiers = TIER_CHAIN[tierMode]; + + const totalSets = useMemo( + () => visibleTiers.reduce((sum, t) => sum + (briefing?.picks?.[t]?.length || 0), 0), + [briefing, visibleTiers] + ); + + // 분배 칩 — 보이는 계층의 risk_tag 합산 + const balance = useMemo(() => { + const acc = { '안정': 0, '균형': 0, '공격': 0 }; + for (const t of visibleTiers) { + for (const p of (briefing?.picks?.[t] || [])) { + if (acc[p.risk_tag] !== undefined) acc[p.risk_tag]++; + } + } + return acc; + }, [briefing, visibleTiers]); + + if (!briefing) return null; + + let cursor = 0; + + return ( +
Curator Briefing · {briefing.draw_no}회
++ {(briefing.narrative.summary_3lines || []).join(' · ')} +
+ +로딩 중...