@@ -6,7 +6,6 @@ import { useParams } from 'react-router-dom'
66
77import { ChallengeDetailContext } from '../../../lib'
88import { AiScorecardContextModel , ChallengeDetailContextModel } from '../../../lib/models'
9-
109import { AiWorkflowRunsResponse , useFetchAiWorkflowsRuns } from '../../../lib/hooks'
1110
1211export const AiScorecardContext : Context < AiScorecardContextModel >
@@ -22,42 +21,48 @@ export const AiScorecardContextProvider: FC<PropsWithChildren> = props => {
2221 } > ( )
2322
2423 const challengeDetailsCtx = useContext ( ChallengeDetailContext )
25- const { challengeInfo } : ChallengeDetailContextModel = challengeDetailsCtx ;
26- const aiReviewers = useMemo ( ( ) => ( challengeInfo ?. reviewers ?? [ ] ) . filter ( r => ! ! r . aiWorkflowId ) , [ challengeInfo ?. reviewers ] )
24+ const { challengeInfo } : ChallengeDetailContextModel = challengeDetailsCtx
25+ const aiReviewers = useMemo ( ( ) => (
26+ ( challengeInfo ?. reviewers ?? [ ] ) . filter ( r => ! ! r . aiWorkflowId )
27+ ) , [ challengeInfo ?. reviewers ] )
2728 const aiWorkflowIds = useMemo ( ( ) => aiReviewers ?. map ( r => r . aiWorkflowId as string ) , [ aiReviewers ] )
2829
29- const { runs : workflowRuns , isLoading : aiWorkflowRunsLoading } : AiWorkflowRunsResponse = useFetchAiWorkflowsRuns ( submissionId , aiWorkflowIds )
30+ const { runs : workflowRuns , isLoading : aiWorkflowRunsLoading } : AiWorkflowRunsResponse
31+ = useFetchAiWorkflowsRuns ( submissionId , aiWorkflowIds )
3032
31- const isLoadingCtxData =
32- challengeDetailsCtx . isLoadingChallengeInfo &&
33- challengeDetailsCtx . isLoadingChallengeResources &&
34- challengeDetailsCtx . isLoadingChallengeSubmissions &&
35- aiWorkflowRunsLoading
33+ const isLoadingCtxData
34+ = challengeDetailsCtx . isLoadingChallengeInfo
35+ && challengeDetailsCtx . isLoadingChallengeResources
36+ && challengeDetailsCtx . isLoadingChallengeSubmissions
37+ && aiWorkflowRunsLoading
3638
37- const workflowRun = useMemo ( ( ) => workflowRuns . find ( w => w . workflow . id === workflowId ) , [ workflowRuns , workflowId ] )
39+ const workflowRun = useMemo (
40+ ( ) => workflowRuns . find ( w => w . workflow . id === workflowId ) ,
41+ [ workflowRuns , workflowId ] ,
42+ )
3843 const workflow = useMemo ( ( ) => workflowRun ?. workflow , [ workflowRuns , workflowId ] )
3944 const scorecard = useMemo ( ( ) => workflow ?. scorecard , [ workflow ] )
4045
4146 const value = useMemo < AiScorecardContextModel > (
4247 ( ) => ( {
4348 ...challengeDetailsCtx ,
49+ isLoading : isLoadingCtxData ,
50+ scorecard,
4451 submissionId,
52+ workflow,
4553 workflowId,
46- workflowRuns,
4754 workflowRun,
48- workflow,
49- scorecard,
50- isLoading : isLoadingCtxData ,
55+ workflowRuns,
5156 } ) ,
5257 [
5358 challengeDetailsCtx ,
59+ isLoadingCtxData ,
60+ scorecard ,
5461 submissionId ,
62+ workflow ,
5563 workflowId ,
56- workflowRuns ,
5764 workflowRun ,
58- isLoadingCtxData ,
59- workflow ,
60- scorecard ,
65+ workflowRuns ,
6166 ] ,
6267 )
6368
@@ -68,4 +73,4 @@ export const AiScorecardContextProvider: FC<PropsWithChildren> = props => {
6873 )
6974}
7075
71- export const useAiScorecardContext = ( ) => useContext ( AiScorecardContext )
76+ export const useAiScorecardContext = ( ) : AiScorecardContextModel => useContext ( AiScorecardContext )
0 commit comments