import React, { useState } from 'react'; import PhaseHeader from './PhaseHeader'; import FormationIcon from '../../icons/Formation'; import { Phases } from '../../../model/common'; import { RingProps } from '../../../model/components/ring'; import RoundedButton from '../../common/RoundedButton'; import RoundedLink from '../../common/RoundedLink'; import EndOfPhase from './EndOfPhase'; import updatePhaseAndScore from '../../../utils/updatePhaseAndScore'; const Formation: React.FC = ({ ring, user }) => { const { training: { url, info: { value }, }, } = ring; const { answers } = user; const phase = answers?.find((ans) => ans.ring.id === ring.id)?.phase || 0; const showFeedback = phase < 1; const [showEndOfPhase, setShowEnd] = useState(false); const [score, setScore] = useState(0); const onFinish = async (): Promise => { const result = await updatePhaseAndScore( user, 1, ring.id, value / user.team.members, ); setScore(result.data.team.totalScore); setShowEnd(true); }; return ( <> {showEndOfPhase && ( )}
} phase={Phases.One} onDark />
{showFeedback ? ( ) : ( )}