Skip to content

Commit e419344

Browse files
authored
Merge pull request #975 from dacadeorg/dev
Release changes to stage
2 parents 87c4eed + 470db96 commit e419344

File tree

7 files changed

+163
-155
lines changed

7 files changed

+163
-155
lines changed

.github/workflows/pre-release.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches:
4+
- stage
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
name: release-please
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: google-github-actions/release-please-action@v4
17+
with:
18+
release-type: node
19+
target-branch: stage
20+
prerelease: true

.github/workflows/release.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
on:
22
push:
33
branches:
4-
- stage
54
- main
65

76
permissions:
@@ -14,9 +13,7 @@ jobs:
1413
release-please:
1514
runs-on: ubuntu-latest
1615
steps:
17-
- uses: google-github-actions/release-please-action@v3
16+
- uses: google-github-actions/release-please-action@v4
1817
with:
1918
release-type: node
2019
target-branch: main
21-
package-name: package.json
22-
labels: "stable"

src/components/cards/challenge/Badges.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Badges({ challenge, className }: BadgeProps) {
2626
}, [challenge.level]);
2727

2828
return (
29-
<div className={`uppercase flex gap-2 mb-6 ${className}`}>
29+
<div className={`uppercase flex flex-wrap gap-2 mb-6 ${className}`}>
3030
{challenge?.level && <Tag>{t(challengeLevel)}</Tag>}
3131
{challenge?.isTeamChallenge && <Tag type="light">{challenge?.isHackathon ? "Hackathon" : "Team"} challenge</Tag>}
3232
</div>

src/components/cards/challenge/Challenge.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
4040
<Badges challenge={data} className="md:hidden" />
4141
</div>
4242

43-
<div className="flex flex-col mb-6 lg:mb-0 mt-6 md:mt-0 rounded-full max-w-max text-sm">
43+
<div className="flex flex-col mb-6 lg:mb-0 mt-6 md:mt-0 max-w-max text-sm">
4444
<div className="flex items-center mb-8 gap-2 md:gap-0">
4545
<Certificate size="medium" name={community.slug} />
4646
<div className="md:pl-2 max-w-max">
@@ -56,11 +56,9 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
5656
<Coin size="medium" token={reward?.token} />
5757
<div className="md:pl-2 max-w-max">
5858
<div className="flex text-sm text-gray-700">
59-
<span className="block font-medium pr-1">
60-
{data?.isHackathon && "$"}
61-
{totalReward}
59+
<span className="block font-medium">
60+
{`${data?.isHackathon ? "$" : ""} ${totalReward} ${data?.isHackathon ? `Prize Pool Rewards` : `${reward?.token} Rewards`}`}
6261
</span>
63-
<span className="block font-medium">{data?.isHackathon ? `Prize Pool Rewards` : `${reward?.token} Rewards`}</span>
6462
</div>
6563
<div className="text-gray-400 text-xs font-normal">{data?.isHackathon ? "Top projects win money prizes" : "For submission and feedback"}</div>
6664
</div>

src/components/sections/profile/Header.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,18 @@ export default function ProfileHeader() {
111111
<></>
112112
)}
113113
</div>
114-
{canConnectDiscord && (
115-
<div className="pt-5 space-x-3">
114+
<div className="pt-5 space-x-3">
115+
{canConnectDiscord && (
116116
<Button variant="outline-primary" className="flex mx-auto text-base" onClick={triggerDiscordOauth}>
117117
{t("profile.header.connect-discord")}
118118
</Button>
119-
{!isKycVerified && (
120-
<Button variant="outline-primary" className="flex mx-auto text-base" onClick={triggerKYCVerification}>
121-
{t("profile.header.sumsub.verify")}
122-
</Button>
123-
)}
124-
</div>
125-
)}
119+
)}
120+
{!isKycVerified && (
121+
<Button variant="outline-primary" className="flex mx-auto text-base" onClick={triggerKYCVerification}>
122+
{t("profile.header.sumsub.verify")}
123+
</Button>
124+
)}
125+
</div>
126126
<KYCVerification />
127127
</div>
128128
);
Lines changed: 94 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useMemo } from "react";
1+
import { useCallback, useEffect, useMemo, useState } from "react";
22
import Wrapper from "@/components/sections/courses/Wrapper";
33
import Header from "@/components/sections/challenges/Header";
44
import { OverviewRewards as Rewards } from "@/components/sections/challenges/Rewards";
@@ -31,7 +31,8 @@ import Objectives from "@/components/sections/challenges/Objectives";
3131
import { getTeamByChallenge, getUserInvitesByChallenge } from "@/store/services/teams.service";
3232
import { fetchChallenge, fetchChallengeAuthenticated } from "@/store/services/communities/challenges";
3333
import Loader from "@/components/ui/Loader";
34-
import { NotFoundError } from "@/utilities/errors/NotFoundError";
34+
import { useRouter } from "next/router";
35+
import Section from "@/components/ui/Section";
3536
import Hint from "@/components/ui/Hint";
3637
import Link from "next/link";
3738

@@ -53,23 +54,12 @@ interface ChallengePageMultiSelector {
5354
* @date 4/25/2023 - 8:12:39 PM
5455
*
5556
* @export
56-
* @param {{
57-
pageProps: {
58-
submission: Submission;
59-
challenge: Challenge;
60-
community: Community;
61-
};
62-
}} props
6357
* @returns {ReactElement}
6458
*/
65-
export default function ChallengePage(props: {
66-
pageProps: {
67-
submission: Submission;
68-
challenge: Challenge;
69-
community: Community;
70-
};
71-
}): ReactElement {
72-
const { challenge, community } = props.pageProps;
59+
export default function ChallengePage() {
60+
const [challenge, setChallenge] = useState<Challenge | null>(null);
61+
const [community, setCommunity] = useState<Community | null>(null);
62+
const [loading, setLoading] = useState(true);
7363
const dispatch = useDispatch();
7464
const { t } = useTranslation();
7565
const { submission, isAuthenticated, isSubmissionLoading } = useMultiSelector<unknown, ChallengePageMultiSelector>({
@@ -80,10 +70,29 @@ export default function ChallengePage(props: {
8070
const title = useMemo(() => getMetadataTitle(t("communities.challenge.title"), challenge?.name || ""), [challenge?.name, t]);
8171

8272
const navigation = useNavigation();
73+
const router = useRouter();
74+
const { challenge_id, slug, locale } = router.query;
8375

84-
useEffect(() => {
76+
const initPage = useCallback(async () => {
77+
const fetchPayload = {
78+
slug: slug as string,
79+
locale: locale as string,
80+
};
81+
82+
setLoading(true);
83+
const [{ data: community }, { data: challenge }] = await Promise.all([
84+
dispatch(fetchCurrentCommunity(fetchPayload)) as any,
85+
dispatch(fetchChallenge({ ...fetchPayload, id: challenge_id as string, relations: ["rubric", "courses", "learning-modules", "best-submissions"] })) as any,
86+
]);
87+
setCommunity(community);
88+
setChallenge(challenge);
8589
dispatch(initChallengeNavigationMenu(navigation.community));
86-
}, []);
90+
setLoading(false);
91+
}, [challenge_id, slug]);
92+
93+
useEffect(() => {
94+
initPage();
95+
}, [initPage]);
8796

8897
useEffect(() => {
8998
if (challenge && isAuthenticated) {
@@ -94,90 +103,78 @@ export default function ChallengePage(props: {
94103
}, [challenge, dispatch, isAuthenticated]);
95104

96105
const headerPaths = useMemo(() => [t("communities.navigation.challenge")], [t]);
97-
return (
98-
<>
99-
<Head>
100-
<title>{title}</title>
101-
<MetaData description={challenge?.description} />
102-
</Head>
103-
<Wrapper paths={headerPaths}>
104-
<div className="flex flex-col py-4 space-y-8 text-gray-700 divide-y divide-gray-200 divide-solid">
105-
<Header />
106-
<Rewards />
107-
<Objectives />
108-
{challenge.isTeamChallenge && <TeamChallenge />}
109-
<Learning courses={challenge.courses} learningModules={challenge.learningModules} community={community} />
110-
<RatingRubric ratingCriteria={challenge?.ratingCriteria} selected={[]} />
111-
<BestSubmissions />
112106

113-
{isAuthenticated ? (
114-
<div>
115-
{isSubmissionLoading ? (
116-
<div className="h-24 sm:h-48 grid place-items-center">
117-
<Loader />
118-
</div>
119-
) : (
120-
<>
121-
{submission ? (
122-
<div className="mt-8">
123-
<h4 className="my-8 text-.5xl font-medium">{t("communities.challenge.your-submission")}</h4>
124-
<SubmissionCard submission={submission} />
125-
</div>
126-
) : (
127-
<>
128-
{challenge.isTeamChallenge && <SetupTeamChallenge />}
129-
<SubmissionForm />
130-
</>
131-
)}
132-
</>
133-
)}
134-
</div>
135-
) : (
136-
<div>
137-
<Hint className="mt-6 flex flex-col md:flex-row">
138-
<p>To be able to submit</p>&nbsp;
139-
<Link className="underline" href="/login">
140-
Login.
141-
</Link>
142-
</Hint>
143-
</div>
144-
)}
145-
</div>
146-
</Wrapper>
147-
</>
148-
);
107+
if (loading)
108+
return (
109+
<Section className="h-[50vh] flex items-center justify-center">
110+
<Loader />
111+
</Section>
112+
);
113+
114+
if (challenge && community)
115+
return (
116+
<>
117+
<Head>
118+
<title>{title}</title>
119+
<MetaData description={challenge?.description} />
120+
</Head>
121+
<Wrapper paths={headerPaths}>
122+
<div className="flex flex-col py-4 space-y-8 text-gray-700 divide-y divide-gray-200 divide-solid">
123+
<Header />
124+
<Rewards />
125+
<Objectives />
126+
{challenge.isTeamChallenge && <TeamChallenge />}
127+
<Learning courses={challenge.courses} learningModules={challenge.learningModules} community={community} />
128+
<RatingRubric ratingCriteria={challenge?.ratingCriteria} selected={[]} />
129+
<BestSubmissions />
130+
131+
{isAuthenticated ? (
132+
<div>
133+
{isSubmissionLoading ? (
134+
<div className="h-24 sm:h-48 grid place-items-center">
135+
<Loader />
136+
</div>
137+
) : (
138+
<>
139+
{submission ? (
140+
<div className="mt-8">
141+
<h4 className="my-8 text-.5xl font-medium">{t("communities.challenge.your-submission")}</h4>
142+
<SubmissionCard submission={submission} />
143+
</div>
144+
) : (
145+
<>
146+
{challenge.isTeamChallenge && <SetupTeamChallenge />}
147+
<SubmissionForm />
148+
</>
149+
)}
150+
</>
151+
)}
152+
</div>
153+
) : (
154+
<div>
155+
<Hint className="mt-6 flex flex-col md:flex-row">
156+
<p>To be able to submit</p>&nbsp;
157+
<Link className="underline" href="/login">
158+
Login.
159+
</Link>
160+
</Hint>
161+
</div>
162+
)}
163+
</div>
164+
</Wrapper>
165+
</>
166+
);
149167
}
150168

151169
ChallengePage.getLayout = function (page: ReactElement) {
152170
return <DefaultLayout footerBackgroundColor={false}>{page}</DefaultLayout>;
153171
};
154172

155-
export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps((store) => async (data) => {
156-
const { query, locale } = data;
157-
const { slug, challenge_id } = query;
158-
159-
const fetchPayload = {
160-
slug: slug as string,
161-
locale: locale as string,
173+
export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps(() => async (data) => {
174+
const { locale } = data;
175+
return {
176+
props: {
177+
...(await serverSideTranslations(locale as string)),
178+
},
162179
};
163-
164-
try {
165-
const [{ data: community }, { data: challenge }, translations] = await Promise.all([
166-
store.dispatch(fetchCurrentCommunity(fetchPayload)),
167-
store.dispatch(fetchChallenge({ ...fetchPayload, id: challenge_id as string, relations: ["rubric", "courses", "learning-modules", "best-submissions"] })),
168-
serverSideTranslations(locale as string),
169-
]);
170-
if (!community || !challenge) throw new NotFoundError();
171-
return {
172-
props: {
173-
...translations,
174-
community,
175-
challenge,
176-
},
177-
};
178-
} catch (e) {
179-
return {
180-
notFound: true,
181-
};
182-
}
183180
});

0 commit comments

Comments
 (0)