Skip to content

Commit e239dd0

Browse files
refactor: separate the hachathon from team challenges steps into different variables
1 parent 194a21e commit e239dd0

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

src/components/sections/challenges/TeamChallenge.tsx

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import Section from "@/components/sections/communities/_partials/Section";
33
import TeamChallengeCard from "@/components/cards/TeamChallenge";
44
import { useSelector } from "@/hooks/useTypedSelector";
@@ -22,48 +22,51 @@ interface CardData {
2222
export default function TeamChallenge(): JSX.Element {
2323
const challenge = useSelector((state) => state.challenges.current);
2424

25-
const TeamChallengeData: CardData[] = challenge?.isHackathon
26-
? [
27-
{
28-
index: 1,
29-
title: "Form your team",
30-
text: "Open Telegram group and find your teammates to complete the challenge with you",
31-
},
32-
{
33-
index: 2,
34-
title: "Confirm your team",
35-
text: "Make sure your teammates accept notification to confirm your team",
36-
},
37-
{
38-
index: 3,
39-
title: "Submit!",
40-
text: "Once you have completed the challenge, only one person needs to submit it at the end of this page",
41-
},
42-
]
43-
: [
44-
{
45-
index: 1,
46-
title: "Form your team",
47-
text: "Open discord channel #teams and find your teammates to complete the challenge with you",
48-
},
49-
{
50-
index: 2,
51-
title: "Confirm your team",
52-
text: "Make sure your teammates accept notification to confirm your team",
53-
},
54-
{
55-
index: 3,
56-
title: "Submit!",
57-
text: "Once you have completed the challenge, only one person needs to submit it at the end of this page",
58-
},
59-
];
25+
const hackathonChallengeSteps: CardData[] = [
26+
{
27+
index: 1,
28+
title: "Form your team",
29+
text: "Open Telegram group and find your teammates to complete the challenge with you",
30+
},
31+
{
32+
index: 2,
33+
title: "Confirm your team",
34+
text: "Make sure your teammates accept notification to confirm your team",
35+
},
36+
{
37+
index: 3,
38+
title: "Submit!",
39+
text: "Once you have completed the challenge, only one person needs to submit it at the end of this page",
40+
},
41+
];
42+
const teamChallengeSteps: CardData[] = [
43+
{
44+
index: 1,
45+
title: "Form your team",
46+
text: "Open discord channel #teams and find your teammates to complete the challenge with you",
47+
},
48+
{
49+
index: 2,
50+
title: "Confirm your team",
51+
text: "Make sure your teammates accept notification to confirm your team",
52+
},
53+
{
54+
index: 3,
55+
title: "Submit!",
56+
text: "Once you have completed the challenge, only one person needs to submit it at the end of this page",
57+
},
58+
];
59+
60+
const steps: CardData[] = useMemo(() => {
61+
return challenge?.isTeamChallenge ? hackathonChallengeSteps : teamChallengeSteps;
62+
}, [challenge?.isTeamChallenge]);
6063

6164
return (
6265
<Section title="Team Challenge">
6366
<div className="text-base font-normal text-slate-700 pt-8 pb-7 md:w-182.5">To complete the team challenge, you need to follow these steps:</div>
6467
<div className="md:flex flex-row gap-20 md:divide-y-0 divide-y divide-gray-900 divide-dotted space-y-5 md:space-y-0 space-x-0">
65-
{TeamChallengeData.map((card) => (
66-
<TeamChallengeCard key={`TeamChallenge-card-data-${card.index}`} index={card.index} title={card.title} text={card.text} />
68+
{steps.map((step) => (
69+
<TeamChallengeCard key={`TeamChallenge-card-data-${step.index}`} index={step.index} title={step.title} text={step.text} />
6770
))}
6871
</div>
6972
</Section>

0 commit comments

Comments
 (0)