fix: improve tipping user journey
- Dashboard "Jetzt tippen" opens TipModal directly instead of navigating to /spiele (no more dead-end spielplan) - After tipping, dashboard updates to show "Dein Tipp: X:Y ✓" - Spielplan auto-opens all sections when only 1-2 exist (no more collapsed "Demnächst" as only section) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { api, DashboardData } from '../api/client';
|
||||
import { api, DashboardData, Match } from '../api/client';
|
||||
import TipModal from '../components/TipModal';
|
||||
import styles from './DashboardPage.module.css';
|
||||
|
||||
interface Props {
|
||||
@@ -25,6 +26,7 @@ export default function DashboardPage(_props: Props) {
|
||||
const [data, setData] = useState<DashboardData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(false);
|
||||
const [tipMatch, setTipMatch] = useState<Match | null>(null);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -90,7 +92,23 @@ export default function DashboardPage(_props: Props) {
|
||||
) : hero.tippable ? (
|
||||
<button
|
||||
className={styles.heroTipBtn}
|
||||
onClick={e => { e.stopPropagation(); navigate('/spiele'); }}
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
setTipMatch({
|
||||
id: hero.match.id,
|
||||
externalId: 0,
|
||||
utcDate: hero.match.utcDate,
|
||||
status: hero.match.status,
|
||||
stage: '',
|
||||
group: null,
|
||||
homeTeam: hero.match.homeTeam,
|
||||
awayTeam: hero.match.awayTeam,
|
||||
score: { home: null, away: null },
|
||||
userTip: null,
|
||||
minutesUntilKickoff: hero.match.minutesUntilKickoff,
|
||||
tippable: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Jetzt tippen
|
||||
</button>
|
||||
@@ -138,6 +156,23 @@ export default function DashboardPage(_props: Props) {
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tipMatch && (
|
||||
<TipModal
|
||||
match={tipMatch}
|
||||
onClose={() => setTipMatch(null)}
|
||||
onSaved={(_matchId, tipHome, tipAway) => {
|
||||
setTipMatch(null);
|
||||
// Update dashboard data to reflect the new tip
|
||||
if (data && data.hero) {
|
||||
setData({
|
||||
...data,
|
||||
hero: { ...data.hero, userTip: { home: tipHome, away: tipAway } },
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user