1
1
import DefaultLayout from "@/components/layout/Default" ;
2
+ import SubmissionPopup from "@/components/popups/submission" ;
3
+ import Header from "@/components/sections/communities/_partials/Header" ;
4
+ import Wrapper from "@/components/sections/courses/Wrapper" ;
5
+ import SubmissionList from "@/components/sections/submissions/List" ;
6
+ import MetaData from "@/components/ui/MetaData" ;
7
+ import useSubmissionNavigation from "@/hooks/useSubmissionNavigation" ;
2
8
import { wrapper } from "@/store" ;
3
9
import { fetchAllSubmission , fetchChallenge } from "@/store/services/communities/challenges" ;
4
10
import { fetchCurrentCommunity } from "@/store/services/community.service" ;
@@ -7,8 +13,10 @@ import { Community } from "@/types/community";
7
13
import { Challenge } from "@/types/course" ;
8
14
import { NotFoundError } from "@/utilities/errors/NotFoundError" ;
9
15
import { GetServerSideProps } from "next" ;
16
+ import { useTranslation } from "next-i18next" ;
10
17
import { serverSideTranslations } from "next-i18next/serverSideTranslations" ;
11
- import { ReactElement } from "react" ;
18
+ import Head from "next/head" ;
19
+ import { ReactElement , useMemo } from "react" ;
12
20
13
21
/**
14
22
* Submission page
@@ -19,65 +27,33 @@ import { ReactElement } from "react";
19
27
* @returns
20
28
*/
21
29
export default function Submission ( props : { pageProps : { currentCommunity : Community ; submissions : SubmissionType [ ] ; challenge : Challenge } } ) {
22
- console . log ( props ) ;
23
- // const { challenge } = props.pageProps;
30
+ const { challenge } = props . pageProps ;
24
31
// const { selectedSubmission, submissions } = useMultiSelector<unknown, { selectedSubmission: SubmissionType; submissions: SubmissionType[] }>({
25
32
// selectedSubmission: (state: IRootState) => state.submissions.current,
26
33
// submissions: (state: IRootState) => state.submissions.list,
27
34
// });
28
- // const [showModal, setShowModal] = useState<boolean>(false);
29
- // const dispatch = useDispatch();
30
- // const router = useRouter();
31
- // const { submission_id } = router.query;
32
- // const { t } = useTranslation();
33
- // const navigation = useNavigation();
34
35
35
- // const handleCloseSubmission = useCallback(() => {
36
- // if (!selectedSubmission) return;
37
- // dispatch(showSubmission(""));
38
- // setShowModal(false);
39
- // window.history.pushState("", "", localePath(router, router.asPath));
40
- // dispatch(toggleBodyScrolling(false));
41
- // }, [dispatch, router, selectedSubmission]);
36
+ const { submissions, selectedSubmission, handleCloseSubmission, showPopup} = useSubmissionNavigation ( ) ;
42
37
43
- // useEffect(() => {
44
- // dispatch(initChallengeNavigationMenu(navigation.community));
45
- // }, [navigation.community, dispatch]);
38
+ const { t } = useTranslation ( ) ;
46
39
47
- // const handleShowSubmission = useCallback(
48
- // (e: any) => {
49
- // const newUrl = e.detail;
50
- // const submissionId = newUrl.replace(localePath(router, router.asPath), "").replace(/\//g, "");
51
- // const submission = submissions.find((submission) => submission.id === submissionId);
52
- // if (!submission) return;
53
- // dispatch(showSubmission(submissionId));
54
- // setShowModal(true);
55
- // dispatch(toggleBodyScrolling(true));
56
- // },
57
- // [dispatch, router, submissions]
58
- // );
40
+ const headerPaths = useMemo ( ( ) => [ t ( "communities.navigation.challenge" ) ] , [ t ] ) ;
59
41
60
- // useEffect(() => {
61
- // window.addEventListener("onSoftNavigation", handleShowSubmission);
62
- // window.addEventListener("popstate", handleCloseSubmission);
63
- // return () => {
64
- // window.removeEventListener("onSoftNavigation", handleShowSubmission);
65
- // window.removeEventListener("popstate", handleCloseSubmission);
66
- // };
67
- // }, [handleCloseSubmission, handleShowSubmission]);
68
-
69
- // // Temporary fix for links copied which have submission_id as a query parameter
70
- // useEffect(() => {
71
- // if (submission_id) router.push(`${router.asPath.split("?")[0]}/${submission_id}`);
72
- // }, [router, submission_id]);
73
-
74
- // const headerPaths = useMemo(() => [t("communities.navigation.challenge")], [t]);
75
-
76
- // if (!submissions) return <></>;
42
+ if ( ! submissions ) return < > </ > ;
77
43
78
44
return (
79
45
< >
80
- < h1 > Hello</ h1 >
46
+ < Head >
47
+ < title > { `${ t ( "communities.submission.title" ) } ${ challenge ?. name } ` } </ title >
48
+ < MetaData description = { challenge ?. description as string } />
49
+ </ Head >
50
+ < Wrapper paths = { headerPaths } >
51
+ < div className = "flex flex-col py-4 space-y-8 text-gray-700" >
52
+ < Header title = { challenge ?. name } subtitle = { t ( "communities.submission.title" ) } isTeamChallenge = { challenge ?. isTeamChallenge } isHackathon = { challenge ?. isHackathon } />
53
+ < SubmissionList />
54
+ </ div >
55
+ { showPopup && < SubmissionPopup show = { showPopup } onClose = { handleCloseSubmission } submissionId = { selectedSubmission ?. id } /> }
56
+ </ Wrapper >
81
57
</ >
82
58
) ;
83
59
}
0 commit comments