Skip to content

Commit b708486

Browse files
refactor: change structure of the additional info type
1 parent 78f971e commit b708486

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/components/sections/challenges/Rubric.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Accordion from "@/components/ui/accordion/Accordion";
99
import { IRootState } from "@/store";
1010
import { Colors } from "@/types/community";
1111
import Coin from "@/components/ui/Coin";
12+
import { GRADING_CRITERIA } from "@/constants/challengeInfo";
1213

1314
/**
1415
* Rubic header component props interface
@@ -58,7 +59,7 @@ export default function RubricHeader({ ratingCriteria, selected, hideTitle = fal
5859
return (
5960
<div className="text-base font-normal text-slate-700 pt-8 md:w-182.5 inline-flex flex-wrap items-center gap-1">
6061
{challenge?.isHackathon ? (
61-
<div dangerouslySetInnerHTML={{ __html: challenge?.additionalInfo?.gradingCriteria || hackatonPassingScore }} />
62+
<div dangerouslySetInnerHTML={{ __html: challenge?.additionalInfo?.[GRADING_CRITERIA].text || hackatonPassingScore }} />
6263
) : (
6364
passingScoreParts.map((part, index) => {
6465
if (index === passingScoreParts.length - 1) {

src/components/sections/challenges/SetupTeamChallenge.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useTranslation } from "next-i18next";
77
import { IRootState } from "@/store";
88
import { Invite } from "@/types/challenge";
99
import { Challenge } from "@/types/course";
10+
import { TEAM_FORMATION } from "@/constants/challengeInfo";
1011

1112
interface Props {
1213
invite: Invite;
@@ -26,7 +27,7 @@ export default function SetupTeamChallenge(): JSX.Element {
2627
<Section title="Submission">
2728
<div className="text-base font-normal text-slate-700 pt-8 pb-7 md:w-182.5">{t("communities.overview.challenge.team.setup.info")}</div>
2829
<div className="md:flex flex-row gap-5">
29-
<FormTeamCard index={1} title="Form your team" description={challenge?.additionalInfo?.teamFormation || t("communities.overview.challenge.team.organization")} />
30+
<FormTeamCard index={1} title="Form your team" description={challenge?.additionalInfo?.[TEAM_FORMATION].text || t("communities.overview.challenge.team.organization")} />
3031
{invite && !invite.team?.locked ? (
3132
<ConfirmTeamInvitation index={2} title="Submit your team" text={`The maximum team members for this challenge is ${challenge?.teamLimit || "3"} people`} invite={invite} />
3233
) : (

src/constants/challengeInfo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const GRADING_CRITERIA = "GRADING_CRITERIA";
2+
export const TEAM_FORMATION = "TEAM_FORMATION";

src/types/course.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ export type Challenge = {
7878
teamLimit?: number;
7979
isHackathon?: boolean;
8080
multipleSubmissions?: boolean;
81-
additionalInfo?: {
82-
gradingCriteria?: string;
83-
teamFormation?: string;
84-
};
81+
additionalInfo?: { [type: string]: AdditionalInfo };
82+
};
83+
84+
type AdditionalInfo = {
85+
type: string;
86+
text: string;
8587
};
8688

8789
export type RatingCriteria = {

0 commit comments

Comments
 (0)