Skip to content

Commit a6375b8

Browse files
feat: show submission form for multiple submissons
1 parent f3e107a commit a6375b8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/pages/communities/[slug]/challenges/[challenge_id]/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export default function ChallengePage() {
6969
});
7070
const title = useMemo(() => getMetadataTitle(t("communities.challenge.title"), challenge?.name || ""), [challenge?.name, t]);
7171

72+
const canSubmit = useMemo(() => {
73+
return !submission || (submission && challenge?.supportMultipleSubmissions);
74+
}, [challenge?.supportMultipleSubmissions, submission]);
75+
7276
const navigation = useNavigation();
7377
const router = useRouter();
7478
const { challenge_id, slug, locale } = router.query;
@@ -136,12 +140,14 @@ export default function ChallengePage() {
136140
</div>
137141
) : (
138142
<>
139-
{submission ? (
143+
{submission && (
140144
<div className="mt-8">
141145
<h4 className="my-8 text-.5xl font-medium">{t("communities.challenge.your-submission")}</h4>
142146
<SubmissionCard submission={submission} />
143147
</div>
144-
) : (
148+
)}
149+
<Hint className="mt-8">{challenge?.supportMultipleSubmissions ? <>You can submit multiple times to this challenge.</> : <>You can only submit once</>}</Hint>
150+
{canSubmit && (
145151
<>
146152
{challenge.isTeamChallenge && <SetupTeamChallenge />}
147153
<SubmissionForm />

src/types/course.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type Challenge = {
7777
bestSubmissions: Submission[];
7878
teamLimit?: number;
7979
isHackathon?: boolean;
80+
supportMultipleSubmissions?: boolean;
8081
};
8182

8283
export type RatingCriteria = {
@@ -140,7 +141,7 @@ export type Reward = {
140141
amount: number;
141142
timestamp: number;
142143
distribution?: Distribution;
143-
};
144+
};
144145
export type Distribution = {
145146
first: string;
146147
second: string;

0 commit comments

Comments
 (0)