Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react'
import { translate } from 'cozy-ui/react/I18n'
import { Duration } from 'luxon'
import { ChallengeType } from 'services/dataChallengeContracts'
import Modal from 'components/CommonKit/Modal/Modal'
import StyledSpinner from 'components/CommonKit/Spinner/StyledSpinner'
import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton'
import StyledWhiteButton from 'components/CommonKit/Button/StyledWhiteButton'
import DefaultChallengeIcon from 'assets/icons/visu/challenge/default_challenge.svg'
interface ChallengeModalProps {
opened: boolean
challenge: ChallengeType
t: Function
handleCloseClick: () => void
handleStartClick: () => void
}
const ChallengeModal: React.FC<ChallengeModalProps> = ({
opened,
challenge,
t,
handleCloseClick,
handleStartClick,
}: ChallengeModalProps) => {
return (
<Modal open={opened} handleCloseClick={handleCloseClick}>
<div className="cm-header text-14-normal-uppercase">
{t('CHALLENGE.TITLE_CHALLENGE')}
</div>
{!challenge ? (
<StyledSpinner />
) : (
<>
<div className="cm-title text-24-bold ">{challenge.title}</div>
<div className="cm-duration text-24-normal">
{Duration.fromObject(challenge.duration).as('days')} Jours
</div>
<StyledIconButton
className="cm-icon"
icon={!challenge.icon ? DefaultChallengeIcon : challenge.icon}
size={100}
/>
<div className="cm-description text-16-bold">
{challenge.description}
</div>
</>
)}
<StyledWhiteButton onClick={handleStartClick}>
{t('CHALLENGE.CHALLENGE_GO')}
</StyledWhiteButton>
</Modal>
)
}
export default translate()(ChallengeModal)