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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, { useContext } from 'react'
import { translate } from 'cozy-ui/react/I18n'
import { UserChallenge, TypeChallenge } from 'services/dataChallengeContracts'
import StyledChallengeCard from 'components/CommonKit/Card/StyledChallengeCard'
import { NavLink } from 'react-router-dom'
import { AppContext } from 'components/Contexts/AppContextProvider'
import StyledIcon from 'components/CommonKit/Icon/StyledIcon'
import OngoingChallengePile from 'components/ContentComponents/Challenge/OngoingChallengePile'
import OngoingChallengeViewingDate from 'components/ContentComponents/Challenge/OngoingChallengeViewingDate'
import FollowChallengeTimeline from 'components/ContentComponents/Challenge/FollowChallengeTimeline'
import BlackArrowIcon from 'assets/icons/ico/black-arrow.svg'
interface ChallengeCardProps {
userChallenge: UserChallenge
}
const ChallengeCard: React.FC<ChallengeCardProps> = ({
userChallenge,
}: ChallengeCardProps) => {
const { challengeNotification } = useContext(AppContext)
const challengesPath = 'challenges'
const challengeDetailPath = {
pathname: `challenges/ongoing`,
state: { challenge: userChallenge },
}
return (
<NavLink
className="cc-link"
to={challengeNotification ? challengesPath : challengeDetailPath}
>
<div>
{userChallenge.challengeType &&
userChallenge.challengeType.type === TypeChallenge.CHALLENGE ? (
<StyledChallengeCard displayBorder={true}>
<div className="cc">
<div className="cc-content-left">
<div className="cc-content-title cc-content-title-padding text-18-normal">
{userChallenge.challengeType.title}
</div>
<div className="cc-content-progress">
<OngoingChallengePile
challenge={userChallenge}
small={true}
/>
</div>
<div className="cc-content-timeline">
<FollowChallengeTimeline challenge={userChallenge} />
</div>
<div className="cc-content-visu text-15-normal">
<OngoingChallengeViewingDate challenge={userChallenge} />
</div>
</div>
<div className="cc-content-right">
<StyledIcon icon={BlackArrowIcon} size={18} />
</div>
</div>
</StyledChallengeCard>
) : (
<StyledChallengeCard displayBorder={challengeNotification}>
<div className="cc">
<div className="cc-content-left">
<div className="cc-content-title text-18-normal">
{userChallenge.challengeType
? userChallenge.challengeType.title
: null}
</div>
</div>
<div className="cc-content-right">
{challengeNotification && (
<div className="cc-notification text-16-bold">1</div>
)}
<StyledIcon icon={BlackArrowIcon} size={18} />
</div>
</div>
</StyledChallengeCard>
)}
</div>
</NavLink>
)
}
export default translate()(ChallengeCard)