@@ -11,38 +11,32 @@ import { GetServerSideProps } from "next";
11
11
import { fetchCurrentCommunity } from "@/store/services/community.service" ;
12
12
import { serverSideTranslations } from "next-i18next/serverSideTranslations" ;
13
13
import { wrapper } from "@/store" ;
14
- import { Challenge } from "@/types/course" ;
15
14
import { initChallengeNavigationMenu } from "@/store/feature/communities/navigation.slice" ;
16
15
import useNavigation from "@/hooks/useNavigation" ;
17
- import { fetchChallenge } from "@/store/services/communities/challenges" ;
18
16
import { useRouter } from "next/router" ;
19
17
import Loader from "@/components/ui/Loader" ;
20
18
import Section from "@/components/ui/Section" ;
19
+ import { useSelector } from "@/hooks/useTypedSelector" ;
21
20
22
21
export default function SubmissionPage ( ) {
23
22
const dispatch = useDispatch ( ) ;
24
23
const { t } = useTranslation ( ) ;
25
24
const navigation = useNavigation ( ) ;
26
25
const router = useRouter ( ) ;
27
- const { slug, locale, submission_id, challenge_id } = router . query ;
26
+ const { slug, locale, submission_id } = router . query ;
28
27
const [ loading , setLoading ] = useState ( true ) ;
29
- const [ challenge , setChallenge ] = useState < Challenge | null > ( null ) ;
28
+ const { current } = useSelector ( ( state ) => state . submissions ) ;
30
29
31
30
const initPage = useCallback ( async ( ) => {
32
31
const fetchCurrentCommunityPayload = {
33
32
slug : slug as string ,
34
33
locale : locale as string ,
35
34
} ;
36
35
setLoading ( true ) ;
37
- const [ , , { data } ] = await Promise . all ( [
38
- dispatch ( fetchCurrentCommunity ( fetchCurrentCommunityPayload ) ) ,
39
- dispatch ( findSubmssionById ( { id : submission_id as string } ) ) ,
40
- dispatch ( fetchChallenge ( { id : challenge_id as string , relations : [ "rubric" , "courses" , "learning-modules" ] } ) ) as unknown as any ,
41
- ] ) ;
42
- setChallenge ( data ) ;
36
+ await Promise . all ( [ dispatch ( fetchCurrentCommunity ( fetchCurrentCommunityPayload ) ) , dispatch ( findSubmssionById ( { id : submission_id as string } ) ) ] ) ;
43
37
dispatch ( initChallengeNavigationMenu ( navigation . community ) ) ;
44
38
setLoading ( false ) ;
45
- } , [ challenge_id , slug , submission_id ] ) ;
39
+ } , [ slug , submission_id ] ) ;
46
40
47
41
useEffect ( ( ) => {
48
42
initPage ( ) ;
@@ -59,7 +53,7 @@ export default function SubmissionPage() {
59
53
return (
60
54
< Wrapper paths = { headerPaths } >
61
55
< div className = "flex flex-col py-4 space-y-8" >
62
- < Header title = { challenge ?. name } subtitle = { t ( "communities.submission.title" ) } />
56
+ < Header title = { current ?. challenge ?. name } subtitle = { t ( "communities.submission.title" ) } />
63
57
< SubmissionView />
64
58
</ div >
65
59
</ Wrapper >
0 commit comments