Skip to content

Commit 4ac4dac

Browse files
fix: hide the submission form when its past deadline
1 parent c162bc3 commit 4ac4dac

File tree

6 files changed

+80
-65
lines changed

6 files changed

+80
-65
lines changed

public/locales/bg/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"communities.overview.challenge.submission.description": "Поставете кода на вашия екип по-долу и той автоматично ще създаде връзки към всички профили.",
119119
"communities.challenge.submission.hint": "Подаването ще бъде активирано, когато всички членове на екипа приемат поканата и екипът бъде напълно сформиран.",
120120
"communities.overview.challenge.deadline": "Краен срок",
121+
"communities.overview.challenge.submissions-closed": "Предложенията за това предизвикателство вече са затворени.",
121122
"communities.reward": "Награди",
122123
"communities.overview.subtitle": "Какво може да получите в тази общност:",
123124
"communities.submissions": "Submissions",

public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"communities.overview.challenge.submission.description": "Paste the code of your team below and it will automatically link to all the profiles",
125125
"communities.challenge.submission.hint": "Submitions will be enabled when when all the team members accept the invitation and the team is fully formed.",
126126
"communities.overview.challenge.deadline": "Deadline",
127+
"communities.overview.challenge.submissions-closed": "Submissions for this challenge are now closed.",
127128
"communities.challenge.hint": "Hint",
128129
"communities.challenge.criteria.title": "Rating Rubric",
129130
"communities.challenge.criteria.subtitle": "The following learning materials will equip you with the technical expertise required to successfully address the challenge.",

public/locales/es/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"communities.overview.challenge.submission.description": "Pega el código de tu equipo a continuación y se enlazará automáticamente a todos los perfiles.",
124124
"communities.challenge.submission.hint": "Las presentaciones estarán habilitadas cuando todos los miembros del equipo acepten la invitación y el equipo esté completamente formado.",
125125
"communities.overview.challenge.deadline": "Fecha límite",
126+
"communities.overview.challenge.submissions-closed": "Las inscripciones para este desafío ya están cerradas.",
126127
"communities.challenge.hint": "Pista",
127128
"communities.challenge.criteria.title": "Rúbrica de evaluación",
128129
"communities.overview.challenge.title": "¿Ya estás lista para completar el desafío?",

public/locales/hr/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
"communities.overview.challenge.submission.description": "Zalijepite kod svog tima u nastavku i automatski će se povezati sa svim profilima.",
170170
"communities.challenge.submission.hint": "Podnošenje će biti omogućeno kada svi članovi tima prihvate pozivnicu i tim bude potpuno formiran.",
171171
"communities.overview.challenge.deadline": "Rok",
172+
"communities.overview.challenge.submissions-closed": "Prijave za ovaj izazov sada su zatvorene.",
172173
"communities.card.submissions": "{{count}} Podnesci",
173174
"communities.card.submission": "{{count}} Podnošenje",
174175
"communities.card.courses": "in {{count}} Courses",

src/components/cards/CreateTeam.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export default function CreateTeamCard({ index = 1, title = "", text = "" }: Cre
120120
return challenge?.teamLimit ? members.length >= challenge?.teamLimit - 1 : members.length >= 2;
121121
}, [challenge?.teamLimit, membersList]);
122122

123+
const submissionsClosed = challenge?.expiresAt ? Date.parse(challenge?.expiresAt) < Date.now() : false;
124+
123125
const canAddMembers = useMemo(() => {
124126
return team ? isCurrentUserOrganiser && !team?.locked && !isTeamFull : true;
125127
}, [isCurrentUserOrganiser, team, isTeamFull]);
@@ -236,6 +238,7 @@ export default function CreateTeamCard({ index = 1, title = "", text = "" }: Cre
236238
defaultOptions={[]}
237239
className="text-lg"
238240
isClearable={true}
241+
isDisabled={submissionsClosed}
239242
loadOptions={(inputValue: string, callback: (options: Option[]) => void) => {
240243
searchUserByUsername(inputValue, callback);
241244
}}

src/components/sections/challenges/Submission.tsx

Lines changed: 73 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export default function Submission(): ReactElement {
9292

9393
const disabled = submitting || (challenge?.format.disclaimer ? !checkedTerms : false);
9494

95+
const submissionsClosed = challenge?.expiresAt ? Date.parse(challenge?.expiresAt) < Date.now() : false;
96+
9597
/**
9698
* Submit form function
9799
* @date 4/18/2023 - 8:22:10 PM
@@ -130,81 +132,87 @@ export default function Submission(): ReactElement {
130132

131133
return (
132134
<Section title={t("communities.challenge.submission")}>
133-
{challenge?.isTeamChallenge && <p className="text-base font-normal text-slate-700 pt-2 pb-7 md:w-99">{t("communities.overview.challenge.submission.description")}</p>}
134-
{!canSubmit ? (
135-
<Hint className="mb-8">{t("communities.challenge.submission.hint")}</Hint>
135+
{submissionsClosed ? (
136+
<Hint className="mb-8">{t("communities.overview.challenge.submissions-closed")}</Hint>
136137
) : (
137-
<form onSubmit={handleSubmit(onSubmit)}>
138-
{challenge?.format && (
139-
<div className="relative w-full md:pl-7.5 my-6">
140-
<div className="absolute z-50 left-3 md:left-0 top-3">
141-
<Avatar user={team?.organizer || authUser} size="medium" />
142-
</div>
138+
<>
139+
{challenge?.isTeamChallenge && <p className="text-base font-normal text-slate-700 pt-2 pb-7 md:w-99"> {t("communities.overview.challenge.submission.description")}</p>}
140+
{!canSubmit ? (
141+
<Hint className="mb-8">{t("communities.challenge.submission.hint")}</Hint>
142+
) : (
143+
<form onSubmit={handleSubmit(onSubmit)}>
144+
{challenge?.format && (
145+
<div className="relative w-full md:pl-7.5 my-6">
146+
<div className="absolute z-50 left-3 md:left-0 top-3">
147+
<Avatar user={team?.organizer || authUser} size="medium" />
148+
</div>
143149

144-
<div label-for="input-text">
145-
<TextInput
146-
id="input-text"
147-
value={textValue}
148-
placeholder={`${t("communities.challenge.submission.placeholder.text")}`}
149-
error={errors.text?.message as string}
150-
{...register("text", {
151-
required: "This field is required",
152-
minLength: {
153-
value: 15,
154-
message: "This field must be at least 15 characters.",
155-
},
156-
})}
157-
/>
158-
</div>
159-
{challenge.format.githubLink && (
160-
<div
161-
className={classNames("w-full border border-solid border-gray-200 m-0 rounded-b text-lg py-0 leading-none items-center space-x-2", {
162-
"border-t-0": challenge.format.text,
163-
})}
164-
>
165-
<div>
166-
<GithubLinkInput
167-
id="input-github"
168-
error={errors.githubLink?.message as string}
169-
className="p-0 border-none border-transparent focus:outline-none outline-none active:border-none focus:border-none block m-0 flex-grow w-full placeholder-gray-400 placeholder-opacity-100"
170-
placeholder={`${t("communities.challenge.submission.placeholder.github")}`}
171-
{...register("githubLink", {
172-
value: githubLinkValue,
150+
<div label-for="input-text">
151+
<TextInput
152+
id="input-text"
153+
value={textValue}
154+
placeholder={`${t("communities.challenge.submission.placeholder.text")}`}
155+
error={errors.text?.message as string}
156+
{...register("text", {
173157
required: "This field is required",
174-
pattern: {
175-
/*
176-
This pattern validates a valid GitHub link URL.
177-
The URL should follow the format: https://github.com/username/repository.
178-
*/
179-
value: /^https?:\/\/(www\.)?github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,
180-
message: "This value must be a valid Github repository URL",
158+
minLength: {
159+
value: 15,
160+
message: "This field must be at least 15 characters.",
181161
},
182162
})}
183163
/>
184164
</div>
165+
{challenge.format.githubLink && (
166+
<div
167+
className={classNames("w-full border border-solid border-gray-200 m-0 rounded-b text-lg py-0 leading-none items-center space-x-2", {
168+
"border-t-0": challenge.format.text,
169+
})}
170+
>
171+
<div>
172+
<GithubLinkInput
173+
id="input-github"
174+
error={errors.githubLink?.message as string}
175+
className="p-0 border-none border-transparent focus:outline-none outline-none active:border-none focus:border-none block m-0 flex-grow w-full placeholder-gray-400 placeholder-opacity-100"
176+
placeholder={`${t("communities.challenge.submission.placeholder.github")}`}
177+
{...register("githubLink", {
178+
value: githubLinkValue,
179+
required: "This field is required",
180+
pattern: {
181+
/*
182+
This pattern validates a valid GitHub link URL.
183+
The URL should follow the format: https://github.com/username/repository.
184+
*/
185+
value: /^https?:\/\/(www\.)?github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,
186+
message: "This value must be a valid Github repository URL",
187+
},
188+
})}
189+
/>
190+
</div>
191+
</div>
192+
)}
185193
</div>
186194
)}
187-
</div>
188-
)}
189-
<div className="pl-7.5">
190-
<MarkdownIcon />
191-
</div>
192-
<div className="flex justify-between">
193-
<div className="flex xl:pl-10.75 flex-col self-center">
194-
{challenge?.format.disclaimer && (
195-
<div className="flex flex-row max-w-xm space-x-3 items-center">
196-
<input type="checkbox" className="xl:w-5 w-10 h-5" name="agree" required onChange={() => setCheckedTerms(!checkedTerms)} checked={checkedTerms} />
197-
<span className="max-w-none text-sm leading-none">{challenge.format.disclaimer}</span>
195+
<div className="pl-7.5">
196+
<MarkdownIcon />
197+
</div>
198+
<div className="flex justify-between">
199+
<div className="flex xl:pl-10.75 flex-col self-center">
200+
{challenge?.format.disclaimer && (
201+
<div className="flex flex-row max-w-xm space-x-3 items-center">
202+
<input type="checkbox" className="xl:w-5 w-10 h-5" name="agree" required onChange={() => setCheckedTerms(!checkedTerms)} checked={checkedTerms} />
203+
<span className="max-w-none text-sm leading-none">{challenge.format.disclaimer}</span>
204+
</div>
205+
)}
198206
</div>
199-
)}
200-
</div>
201-
<div className="flex text-right self-start">
202-
<ArrowButton variant="primary" disabled={disabled} customStyle={activeButtonStyle} loading={submitting}>
203-
submit
204-
</ArrowButton>
205-
</div>
206-
</div>
207-
</form>
207+
<div className="flex text-right self-start">
208+
<ArrowButton variant="primary" disabled={disabled} customStyle={activeButtonStyle} loading={submitting}>
209+
submit
210+
</ArrowButton>
211+
</div>
212+
</div>
213+
</form>
214+
)}
215+
</>
208216
)}
209217
</Section>
210218
);

0 commit comments

Comments
 (0)