Skip to content

Commit 8c944bf

Browse files
committed
Design phase cleanups
1 parent c9ea539 commit 8c944bf

File tree

9 files changed

+638
-319
lines changed

9 files changed

+638
-319
lines changed

src/apps/review/src/lib/components/ChallengeDetailsContent/TabContentScreening.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const TabContentScreening: FC<Props> = (props: Props) => {
3737

3838
return (
3939
<TableSubmissionScreening
40-
datas={props.screening}
40+
screenings={props.screening}
4141
isDownloading={props.isDownloading}
4242
downloadSubmission={props.downloadSubmission}
4343
hideHandleColumn={hideHandleColumn}

src/apps/review/src/lib/components/TableReviewAppeals/TableReviewAppeals.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,33 @@ export const TableReviewAppeals: FC<Props> = (props: Props) => {
202202
const isSubmissionTab = (tab || '').toLowerCase() === 'submission'
203203
const wrapperClassName = props.className
204204

205+
const submissionTypes = new Set(
206+
datas
207+
.map(d => d.type)
208+
.filter((t): t is string => Boolean(t)),
209+
)
210+
const filteredChallengeSubmissions = submissionTypes.size
211+
? (challengeInfo?.submissions ?? [])
212+
.filter(s => s.type && submissionTypes.has(s.type))
213+
: (challengeInfo?.submissions ?? [])
214+
205215
const submissionHistory = useMemo<SubmissionHistoryPartition>(
206-
() => partitionSubmissionHistory(datas, challengeInfo?.submissions),
207-
[challengeInfo?.submissions, datas],
216+
() => partitionSubmissionHistory(datas, filteredChallengeSubmissions),
217+
[datas, filteredChallengeSubmissions],
208218
)
209219
const {
210220
latestSubmissions,
211221
latestSubmissionIds,
212222
historyByMember,
213223
}: SubmissionHistoryPartition = submissionHistory
214-
const hasHistoryEntries = useMemo(
224+
const shouldShowHistoryActions = useMemo(
215225
() => isSubmissionTab && hasIsLatestFlag(datas),
216226
[datas, isSubmissionTab],
217227
)
218228

219229
const submissionMetaById = useMemo(() => {
220-
const map = new Map<string, SubmissionInfo>();
221-
(challengeInfo?.submissions ?? []).forEach(submission => {
230+
const map = new Map<string, SubmissionInfo>()
231+
filteredChallengeSubmissions.forEach(submission => {
222232
if (submission?.id) {
223233
map.set(submission.id, submission)
224234
}
@@ -229,7 +239,7 @@ export const TableReviewAppeals: FC<Props> = (props: Props) => {
229239
}
230240
})
231241
return map
232-
}, [challengeInfo?.submissions, datas])
242+
}, [datas, filteredChallengeSubmissions])
233243

234244
const resolveSubmissionMeta = useCallback(
235245
(submissionId: string): SubmissionInfo | undefined => submissionMetaById.get(submissionId),
@@ -1289,7 +1299,7 @@ export const TableReviewAppeals: FC<Props> = (props: Props) => {
12891299
const historyOnlyColumn: TableColumn<SubmissionRow> | undefined = (!actionColumns.length
12901300
&& canViewHistory
12911301
&& isSubmissionTab
1292-
&& hasHistoryEntries)
1302+
&& shouldShowHistoryActions)
12931303
? {
12941304
className: styles.textBlue,
12951305
columnId: 'submission-history',
@@ -1498,7 +1508,7 @@ export const TableReviewAppeals: FC<Props> = (props: Props) => {
14981508
tab,
14991509
restrictionMessage,
15001510
historyByMember,
1501-
hasHistoryEntries,
1511+
shouldShowHistoryActions,
15021512
myResources,
15031513
getLatestChallengeInfo,
15041514
setIsReviewPhaseClosedModalOpen,

src/apps/review/src/lib/components/TableReviewAppealsForSubmitter/TableReviewAppealsForSubmitter.tsx

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,38 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
9595
const challengeStatus = challengeInfo?.status?.toUpperCase()
9696
const isChallengeCompleted = challengeStatus === 'COMPLETED'
9797

98+
const submissionTypes = useMemo(
99+
() => new Set(
100+
datas
101+
.map(submission => submission.type)
102+
.filter((type): type is string => Boolean(type)),
103+
),
104+
[datas],
105+
)
106+
107+
const filteredAll = useMemo<SubmissionInfo[]>(
108+
() => {
109+
const allSubmissions = challengeInfo?.submissions ?? []
110+
const typedFiltered = allSubmissions.filter(
111+
submission => submission.type && submissionTypes.has(submission.type),
112+
)
113+
const fallbackIds = new Set(
114+
datas
115+
.map(submission => submission.id)
116+
.filter((id): id is string => Boolean(id)),
117+
)
118+
const filtered = allSubmissions.filter(
119+
submission => submission.id && fallbackIds.has(submission.id),
120+
)
121+
122+
return submissionTypes.size ? typedFiltered : filtered
123+
},
124+
[challengeInfo?.submissions, datas, submissionTypes],
125+
)
126+
98127
const submissionHistory = useMemo<SubmissionHistoryPartition>(
99-
() => partitionSubmissionHistory(datas, challengeInfo?.submissions),
100-
[challengeInfo?.submissions, datas],
128+
() => partitionSubmissionHistory(datas, filteredAll),
129+
[datas, filteredAll],
101130
)
102131
const {
103132
latestSubmissions,
@@ -107,20 +136,30 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
107136

108137
const submissionMetaById = useMemo(() => {
109138
const map = new Map<string, SubmissionInfo>()
110-
const challengeSubmissions = challengeInfo?.submissions ?? []
111-
112-
challengeSubmissions.forEach(submission => {
139+
filteredAll.forEach(submission => {
113140
if (submission?.id) {
114141
map.set(submission.id, submission)
115142
}
116143
})
117144
datas.forEach(submission => {
118-
if (submission?.id && !map.has(submission.id)) {
119-
map.set(submission.id, submission)
145+
if (!submission?.id) {
146+
return
120147
}
148+
149+
const existing = map.get(submission.id)
150+
if (existing) {
151+
map.set(submission.id, {
152+
...existing,
153+
...submission,
154+
type: submission.type ?? existing?.type,
155+
})
156+
return
157+
}
158+
159+
map.set(submission.id, { ...submission, type: submission.type })
121160
})
122161
return map
123-
}, [challengeInfo?.submissions, datas])
162+
}, [datas, filteredAll])
124163

125164
const resolveSubmissionMeta = useCallback(
126165
(submissionId: string): SubmissionInfo | undefined => submissionMetaById.get(submissionId),
@@ -156,7 +195,7 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
156195
[historyByMember],
157196
)
158197

159-
const hasHistoryEntries = useMemo(
198+
const shouldShowHistoryActions = useMemo(
160199
() => isSubmissionTab && hasIsLatestFlag(datas),
161200
[datas, isSubmissionTab],
162201
)
@@ -630,7 +669,7 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
630669
}
631670
}
632671

633-
const shouldRenderActionsColumn = !isAppealsTab && hasHistoryEntries
672+
const shouldRenderActionsColumn = !isAppealsTab && shouldShowHistoryActions
634673

635674
if (shouldRenderActionsColumn) {
636675
aggregatedColumns.push({
@@ -694,7 +733,7 @@ export const TableReviewAppealsForSubmitter: FC<Props> = (props: Props) => {
694733
}, [
695734
allowsAppeals,
696735
canDisplayScores,
697-
hasHistoryEntries,
736+
shouldShowHistoryActions,
698737
downloadSubmission,
699738
historyByMember,
700739
isSubmissionDownloadRestricted,

src/apps/review/src/lib/components/TableSubmissionScreening/TableSubmissionScreening.module.scss

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,60 @@
9999
}
100100
}
101101

102+
.actionsContainer {
103+
display: flex;
104+
flex-direction: column;
105+
gap: $sp-2;
106+
}
107+
108+
.submit {
109+
align-items: center;
110+
display: flex;
111+
font-weight: 700;
112+
113+
& > i {
114+
margin-right: $sp-2;
115+
}
116+
}
117+
118+
.completedAction {
119+
align-items: center;
120+
display: flex;
121+
justify-content: center;
122+
}
123+
124+
.completedIcon {
125+
align-items: center;
126+
background-color: #2fa152;
127+
border-radius: 50%;
128+
color: #fff;
129+
display: flex;
130+
height: 20px;
131+
justify-content: center;
132+
line-height: 1;
133+
width: 20px;
134+
135+
svg {
136+
width: 14px;
137+
height: 14px;
138+
color: #fff;
139+
}
140+
}
141+
142+
.completedPill {
143+
align-items: center;
144+
background-color: $green-25;
145+
border-radius: 999px;
146+
color: $green-140;
147+
display: inline-flex;
148+
font-size: 12px;
149+
font-weight: 700;
150+
justify-content: center;
151+
margin-left: $sp-2;
152+
padding: $sp-1 $sp-2;
153+
white-space: nowrap;
154+
}
155+
102156
.resultPill {
103157
display: inline-flex;
104158
align-items: center;

0 commit comments

Comments
 (0)