Skip to content

Commit a533625

Browse files
committed
fix: merge conflict
2 parents 36a953b + 66801e1 commit a533625

File tree

15 files changed

+176
-81
lines changed

15 files changed

+176
-81
lines changed

src/components/cards/challenge/_partials/Learning.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export default function Learning({ title, description, link }: LearningProps): J
2727
<div className="flex flex-col justify-between w-full sm:pb-0">
2828
<div className="flex flex-col">
2929
<div className="text-lg font-medium leading-normal text-gray-900">{title}</div>
30-
<div className="text-sm font-normal text-gray-700 mt-3 max-w-xxs pb-6">{description}</div>
30+
<div className="text-sm font-normal text-gray-700 mt-3 max-w-xxs pb-6 mb-5">{description}</div>
3131
</div>
32-
<div className="">
32+
<div className="absolute bottom-0 pb-4">
3333
<Link href={link}>
3434
<ArrowButton communityStyles={true} variant="outline-primary">
3535
{t("communities.overview.challenge.learning.start")}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Objectives from "@/components/sections/challenges/Objectives";
3131
import { getTeamByChallenge } 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";
3435

3536
/**
3637
* interface for ChallengePage multiSelector
@@ -155,7 +156,7 @@ export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps
155156
store.dispatch(fetchChallenge({ ...fetchPayload, id: challenge_id as string, relations: ["rubric", "courses", "learning-modules", "best-submissions"] })),
156157
serverSideTranslations(locale as string),
157158
]);
158-
159+
if (!community || !challenge) throw new NotFoundError();
159160
return {
160161
props: {
161162
...translations,

src/pages/communities/[slug]/challenges/[challenge_id]/submissions/[submission_id].tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Challenge } from "@/types/course";
1515
import { initChallengeNavigationMenu } from "@/store/feature/communities/navigation.slice";
1616
import useNavigation from "@/hooks/useNavigation";
1717
import { fetchChallenge } from "@/store/services/communities/challenges";
18+
import { NotFoundError } from "@/utilities/errors/NotFoundError";
1819

1920
export default function SubmissionPage(props: { pageProps: { challenge: Challenge } }) {
2021
const dispatch = useDispatch();
@@ -57,6 +58,8 @@ export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps
5758
serverSideTranslations(locale as string),
5859
]);
5960

61+
if (!community || !challenge || !submission) throw new NotFoundError();
62+
6063
return {
6164
props: {
6265
community,

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

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { fetchCurrentCommunity } from "@/store/services/community.service";
1616
import { Submission as SubmissionType } from "@/types/bounty";
1717
import { Community } from "@/types/community";
1818
import { Challenge } from "@/types/course";
19+
import { NotFoundError } from "@/utilities/errors/NotFoundError";
1920
import { localePath } from "@/utilities/Routing";
2021
import { GetServerSideProps } from "next";
2122
import { useTranslation } from "next-i18next";
@@ -53,21 +54,24 @@ export default function Submission(props: { pageProps: { currentCommunity: Commu
5354
dispatch(initChallengeNavigationMenu(navigation.community));
5455
}, [navigation.community, dispatch]);
5556

56-
const handleShowSubmission = useCallback((e: any) => {
57+
const handleShowSubmission = useCallback(
58+
(e: any) => {
5759
const newUrl = e.detail;
58-
const submissionId = newUrl.replace(localePath(router, router.asPath), "").replace(/\//g, '');
60+
const submissionId = newUrl.replace(localePath(router, router.asPath), "").replace(/\//g, "");
5961
const submission = submissions.find((submission) => submission.id === submissionId);
6062
if(!submission) return;
6163
dispatch(showSubmission(submissionId));
6264
dispatch(toggleBodyScrolling(true));
63-
}, [dispatch, router, submissions]);
65+
},
66+
[dispatch, router, submissions]
67+
);
6468

6569
useEffect(() => {
66-
window.addEventListener('onSoftNavigation', handleShowSubmission);
67-
window.addEventListener('popstate', handleCloseSubmission);
70+
window.addEventListener("onSoftNavigation", handleShowSubmission);
71+
window.addEventListener("popstate", handleCloseSubmission);
6872
return () => {
69-
window.removeEventListener('onSoftNavigation', handleShowSubmission);
70-
window.removeEventListener('popstate', handleCloseSubmission);
73+
window.removeEventListener("onSoftNavigation", handleShowSubmission);
74+
window.removeEventListener("popstate", handleCloseSubmission);
7175
};
7276
}, [handleCloseSubmission, handleShowSubmission]);
7377

@@ -105,19 +109,26 @@ export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps
105109
const { slug, challenge_id } = query;
106110
const { dispatch } = store;
107111

108-
const [{ data: currentCommunity }, { data: submissions }, { data: challenge }, translations] = await Promise.all([
109-
dispatch(fetchCurrentCommunity({ slug: slug as string, locale: locale as string })),
110-
dispatch(fetchAllSubmission({ challengeId: challenge_id as string, locale: locale as string })),
111-
dispatch(fetchChallenge({ id: challenge_id as string, relations: ["rubric", "courses", "learning-modules"] })),
112-
serverSideTranslations(locale as string),
113-
]);
112+
try {
113+
const [{ data: currentCommunity }, { data: submissions }, { data: challenge }, translations] = await Promise.all([
114+
dispatch(fetchCurrentCommunity({ slug: slug as string, locale: locale as string })),
115+
dispatch(fetchAllSubmission({ challengeId: challenge_id as string, locale: locale as string })),
116+
dispatch(fetchChallenge({ id: challenge_id as string, relations: ["rubric", "courses", "learning-modules"] })),
117+
serverSideTranslations(locale as string),
118+
]);
114119

115-
return {
116-
props: {
117-
currentCommunity,
118-
submissions,
119-
challenge,
120-
...translations,
121-
},
122-
};
120+
if (!currentCommunity || !challenge || !submissions) throw new NotFoundError();
121+
return {
122+
props: {
123+
currentCommunity,
124+
submissions,
125+
challenge,
126+
...translations,
127+
},
128+
};
129+
} catch (error) {
130+
return {
131+
notFound: true,
132+
};
133+
}
123134
});

src/pages/communities/[slug]/courses/[course_slug]/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { wrapper } from "@/store";
1515
import { fetchCourse } from "@/store/services/course.service";
1616
import { fetchCurrentCommunity } from "@/store/services/community.service";
1717
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
18+
import { NotFoundError } from "@/utilities/errors/NotFoundError";
1819

1920
export default function CourseViewPage(props: {
2021
pageProps: {
@@ -68,7 +69,8 @@ export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps
6869
store.dispatch(fetchCourse({ slug: course_slug, locale })),
6970
serverSideTranslations(locale as string),
7071
]);
71-
72+
if (!community || !course) throw new NotFoundError();
73+
7274
return {
7375
props: {
7476
community,

src/pages/communities/[slug]/courses/[course_slug]/learning-modules/[id].tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import useNavigation from "@/hooks/useNavigation";
1919
import ChallengeCard from "@/components/cards/challenge/Challenge";
2020
import { useTranslation } from "react-i18next";
2121
import PageNavigation from "@/components/sections/courses/PageNavigation";
22+
import { NotFoundError } from "@/utilities/errors/NotFoundError";
2223

2324
/**
2425
* Learning module page props interfae
@@ -114,7 +115,7 @@ export const getServerSideProps = wrapper.getServerSideProps((store) => async ({
114115
store.dispatch(findLearningModule(id)),
115116
serverSideTranslations(locale as string),
116117
]);
117-
118+
if (!community || !course || !learningModule) throw new NotFoundError();
118119
return {
119120
props: {
120121
community,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Challenge } from "@/types/course";
99
import { wrapper } from "@/store";
1010
import { fetchCurrentCommunity } from "@/store/services/community.service";
1111
import { fetchAllChallenges } from "@/store/services/communities/challenges";
12+
import { NotFoundError } from "@/utilities/errors/NotFoundError";
1213
export default function Slug(props: {
1314
pageProps: {
1415
community: Community;
@@ -47,7 +48,7 @@ export const getServerSideProps = wrapper.getServerSideProps((store) => async ({
4748
store.dispatch(fetchAllChallenges({ slug })),
4849
serverSideTranslations(locale as string),
4950
]);
50-
51+
if (!community || !challenges) throw new NotFoundError();;
5152
return {
5253
props: {
5354
community,

src/pages/communities/[slug]/scoreboard.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { wrapper } from "@/store";
1313
import { Scoreboard as ScoreboardType } from "@/types/scoreboard";
1414
import { Community } from "@/types/community";
1515
import { CommunityLayout } from "@/layouts/Community";
16+
import { NotFoundError } from "@/utilities/errors/NotFoundError";
1617

1718
/**
1819
* Scoreboard list page
@@ -51,10 +52,17 @@ ScoreboardList.getLayout = function (page: ReactElement) {
5152
export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps((store) => async ({ locale, params }) => {
5253
const slug = params?.slug as string;
5354

54-
const [{ data: community }, { data: scoreboards }] = await Promise.all([
55-
store.dispatch(fetchCurrentCommunity({ slug, locale })),
56-
store.dispatch(fetchAllScoreboards({ slug, locale: locale || "en" })),
57-
]);
55+
try {
56+
const [{ data: community }, { data: scoreboards }] = await Promise.all([
57+
store.dispatch(fetchCurrentCommunity({ slug, locale })),
58+
store.dispatch(fetchAllScoreboards({ slug, locale: locale || "en" })),
59+
]);
60+
if (!community || !scoreboards) throw new NotFoundError();
5861

59-
return { props: { community, scoreboards, ...(await i18Translate(locale as string)) } };
62+
return { props: { community, scoreboards, ...(await i18Translate(locale as string)) } };
63+
} catch (error) {
64+
return {
65+
notFound: true,
66+
};
67+
}
6068
});

src/pages/profile/[username]/communities/[slug].tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,27 @@ ProfileCommunities.getLayout = function (page: ReactElement) {
2222
};
2323

2424
export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps((store) => async ({ locale, query }) => {
25-
const { slug, username } = query;
26-
27-
const [{ data }, translations] = await Promise.all([
28-
store.dispatch(fetchProfileCommunity({ username: username as string, slug: slug as string })),
29-
serverSideTranslations(locale as string),
30-
]);
31-
32-
return {
33-
props: {
34-
community: data.community,
35-
feedbacks: data.feedbacks,
36-
submissions: data.submissions,
37-
reputation: data.reputation,
38-
...translations,
39-
},
40-
};
25+
try {
26+
const { slug, username } = query;
27+
28+
const [{ data }, translations] = await Promise.all([
29+
store.dispatch(fetchProfileCommunity({ username: username as string, slug: slug as string })),
30+
serverSideTranslations(locale as string),
31+
]);
32+
33+
return {
34+
props: {
35+
community: data.community,
36+
feedbacks: data.feedbacks,
37+
submissions: data.submissions,
38+
reputation: data.reputation,
39+
...translations,
40+
},
41+
};
42+
43+
} catch (error) {
44+
return {
45+
notFound: true
46+
}
47+
}
4148
});

src/store/services/bounties.service.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import baseQuery from "@/config/baseQuery";
22
import { createApi } from "@reduxjs/toolkit/dist/query";
33
import { setBountiesList, setLoading } from "../feature/bouties.slice";
44
import { HYDRATE } from "next-redux-wrapper";
5+
import { setBusy, setError } from "../feature/index.slice";
56

67
/**
78
* Bounties api api service
@@ -23,10 +24,15 @@ const bountiesService = createApi({
2324
query: () => "bounties",
2425
onQueryStarted: async (slug, { dispatch, queryFulfilled }) => {
2526
dispatch(setLoading(true))
26-
const { data } = await queryFulfilled;
27-
if (data) dispatch(setBountiesList(data));
28-
dispatch(setLoading(false))
29-
return data
27+
try {
28+
const { data } = await queryFulfilled;
29+
if (data) dispatch(setBountiesList(data));
30+
dispatch(setLoading(false))
31+
return data
32+
} catch (error) {
33+
dispatch(setBusy(false));
34+
dispatch(setError(error));
35+
}
3036
},
3137
}),
3238
}),

0 commit comments

Comments
 (0)