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