Skip to content

Commit 05a2c77

Browse files
committed
Merge branch 'PM-1502-scorecards' of github.com:topcoder-platform/platform-ui into PM-1505_clone-scorecard
2 parents 6138ea4 + 12ea744 commit 05a2c77

File tree

17 files changed

+171
-33
lines changed

17 files changed

+171
-33
lines changed

src/apps/admin/src/lib/components/common/Pagination/Pagination.module.scss

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,49 @@
66
justify-content: flex-end;
77
align-items: center;
88
padding: 16px 0;
9-
gap: $sp-4;
9+
gap: $sp-2;
10+
11+
.pageNumbers button,
12+
.previous,
13+
.disabled,
14+
.first,
15+
.last,
16+
.next {
17+
box-shadow: none;
18+
border: 1px solid #E9ECEF;
19+
border-radius: 4px;
20+
color: #0A0A0A;
21+
font-weight: 400;
22+
font-size: 14px;
23+
}
24+
25+
.previous,
26+
.first,
27+
.last,
28+
.next {
29+
padding: 7px 11px;
30+
31+
&:disabled {
32+
background-color: #E9ECEF !important;
33+
}
34+
}
35+
1036

1137
.pageNumbers {
1238
display: flex;
1339
justify-content: center;
1440
align-items: center;
15-
gap: $sp-1;
41+
gap: $sp-2;
42+
43+
button {
44+
padding: 3px 12px;
45+
}
1646

1747
button.active {
1848
color: $black-60;
1949
pointer-events: none;
20-
box-shadow: inset 0 0 0 2px #{$black-60};
50+
background-color: $teal-160;
51+
color: white;
2152
}
2253
}
2354

@@ -35,4 +66,8 @@
3566
@media (max-width: #{$mobile-max}) {
3667
justify-content: center;
3768
}
69+
70+
:global(.btn-style-secondary) {
71+
box-shadow: none !important;
72+
}
3873
}

src/apps/admin/src/lib/components/common/Pagination/Pagination.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
7474
size='md'
7575
icon={IconOutline.ChevronDoubleLeftIcon}
7676
iconToLeft
77-
label='FIRST'
7877
disabled={props.page === 1 || props.disabled}
7978
className={styles.first}
8079
/>
@@ -84,7 +83,6 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
8483
size='md'
8584
icon={IconOutline.ChevronLeftIcon}
8685
iconToLeft
87-
label='PREVIOUS'
8886
disabled={props.page === 1 || props.disabled}
8987
className={styles.previous}
9088
/>
@@ -93,7 +91,6 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
9391
<Button
9492
key={`page-${i}`}
9593
secondary
96-
variant='round'
9794
label={`${i}`}
9895
onClick={createHandlePageClick(i)}
9996
className={i === props.page ? styles.active : ''}
@@ -107,7 +104,6 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
107104
size='md'
108105
icon={IconOutline.ChevronRightIcon}
109106
iconToRight
110-
label='NEXT'
111107
disabled={props.page === totalPages || props.disabled}
112108
className={styles.next}
113109
/>
@@ -118,7 +114,6 @@ const Pagination: FC<PaginationProps> = (props: PaginationProps) => {
118114
size='md'
119115
icon={IconOutline.ChevronDoubleRightIcon}
120116
iconToRight
121-
label='LAST'
122117
disabled={props.page === totalPages || props.disabled}
123118
className={styles.last}
124119
/>

src/apps/review/src/config/routes.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export const openOpportunitiesRouteId = 'open-opportunities'
1313
export const pastReviewAssignmentsRouteId = 'past-review-assignments'
1414
export const challengeDetailRouteId = ':challengeId'
1515
export const scorecardRouteId = 'scorecard'
16+
export const viewScorecardRouteId = ':scorecardId'

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@
3636
text-align: center;
3737
}
3838

39+
.pagination {
40+
display: flex;
41+
justify-content: space-between;
42+
align-items: center;
43+
}
44+

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Table Active Reviews.
3-
*/
3+
*/
44
import { Dispatch, FC, SetStateAction, useMemo } from 'react'
55
import { Link } from 'react-router-dom'
66
import { bind, noop } from 'lodash'
@@ -21,6 +21,8 @@ import styles from './TableScorecards.module.scss'
2121
interface Props {
2222
className?: string
2323
datas: Scorecard[]
24+
metadata?: any
25+
perPage?: number
2426
totalPages: number
2527
page: number
2628
setPage: Dispatch<SetStateAction<number>>
@@ -44,7 +46,7 @@ export const TableScorecards: FC<Props> = (props: Props) => {
4446
label: 'Scorecard',
4547
propertyName: 'name',
4648
renderer: (data: Scorecard) => (
47-
<Link to={`${data.id}/details`}>
49+
<Link to={`${data.id}`}>
4850
{data.name}
4951
</Link>
5052
),
@@ -149,11 +151,24 @@ export const TableScorecards: FC<Props> = (props: Props) => {
149151
className='enhanced-table-desktop'
150152
/>
151153
)}
152-
<Pagination
153-
page={props.page}
154-
totalPages={props.totalPages}
155-
onPageChange={props.setPage}
156-
/>
154+
<div className={styles.pagination}>
155+
<div>
156+
Showing 1-
157+
{props.perPage}
158+
{' '}
159+
of
160+
{' '}
161+
{props.metadata.total}
162+
{' '}
163+
results
164+
</div>
165+
<Pagination
166+
page={props.page}
167+
totalPages={props.totalPages}
168+
onPageChange={props.setPage}
169+
/>
170+
</div>
171+
157172
</TableWrapper>
158173
)
159174
}

src/apps/review/src/lib/hooks/useFetchScorecards.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface UseFetchScorecardsParams {
1010
perPage: number
1111
name?: string
1212
challengeTrack?: string
13-
type?: string
13+
scorecardType?: string
1414
challengeType?: string
1515
status?: string
1616
}
@@ -33,15 +33,15 @@ export function useFetchScorecards(
3333
name = '',
3434
challengeTrack = '',
3535
challengeType = '',
36+
scorecardType = '',
3637
status = '',
37-
type = '',
3838
}: UseFetchScorecardsParams,
3939
): ScorecardsResponse {
4040
const query = new URLSearchParams({
4141
page: String(page),
4242
perPage: String(perPage),
4343
...(name ? { name } : {}),
44-
...(type ? { type } : {}),
44+
...(scorecardType ? { scorecardType } : {}),
4545
...(challengeTrack ? { challengeTrack } : {}),
4646
...(challengeType ? { challengeType } : {}),
4747
...(status ? { status } : {}),
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* The router outlet.
3+
*/
4+
5+
import { FC, PropsWithChildren, useContext, useEffect, useMemo } from 'react'
6+
import { Outlet, Routes, useLocation } from 'react-router-dom'
7+
8+
import { routerContext, RouterContextData } from '~/libs/core'
9+
10+
import { reviewRoutes } from '../../review-app.routes'
11+
import { scorecardRouteId } from '../../config/routes.config'
12+
13+
export const ScorecardsContainer: FC<PropsWithChildren> = () => {
14+
const location = useLocation()
15+
const childRoutes = useChildRoutes()
16+
17+
useEffect(() => {
18+
window.scrollTo(0, 0)
19+
}, [location.pathname])
20+
21+
return (
22+
<>
23+
<Outlet />
24+
<Routes>{childRoutes}</Routes>
25+
</>
26+
)
27+
}
28+
29+
function useChildRoutes(): Array<JSX.Element> | undefined {
30+
const { getRouteElement }: RouterContextData = useContext(routerContext)
31+
const childRoutes = useMemo(
32+
() => reviewRoutes[0].children
33+
?.find(r => r.id === scorecardRouteId)
34+
?.children?.map(getRouteElement),
35+
[getRouteElement],
36+
)
37+
return childRoutes
38+
}
39+
40+
export default ScorecardsContainer
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.totalScorecards {
2+
margin-top: 10px;
3+
}

src/apps/review/src/pages/scorecards/ScorecardsListPage.tsx renamed to src/apps/review/src/pages/scorecards/ScorecardsListPage/ScorecardsListPage.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import { toast } from 'react-toastify'
55
import { PageTitle, useConfirmationModal } from '~/libs/ui'
66
import { TableLoading } from '~/apps/admin/src/lib'
77

8-
import { PageWrapper, ScorecardsFilter, TableNoRecord, TableScorecards } from '../../lib'
9-
import { ScorecardsResponse, useFetchScorecards } from '../../lib/hooks'
10-
import { cloneScorecard } from '../../lib/services'
11-
import { Scorecard } from '../../lib/models'
8+
import { Scorecard } from '../../../lib/models'
9+
import { cloneScorecard } from '../../../lib/services'
10+
import { PageWrapper, ScorecardsFilter, TableNoRecord, TableScorecards } from '../../../lib'
11+
import { ScorecardsResponse, useFetchScorecards } from '../../../lib/hooks'
1212

13-
// import { mockScorecards } from '../../mock-datas/MockScorecardList'
14-
15-
// import styles from './ScorecardsListPage.module.scss'
13+
import styles from './ScorecardsListPage.module.scss'
1614

1715
export const ScorecardsListPage: FC<{}> = () => {
1816
const navigate = useNavigate()
@@ -26,29 +24,30 @@ export const ScorecardsListPage: FC<{}> = () => {
2624
type: '',
2725
})
2826
const [page, setPage] = useState(1)
27+
const perPage = 10
2928

3029
const breadCrumb = useMemo(
3130
() => [{ index: 1, label: 'Scorecards' }],
3231
[],
3332
)
34-
// const scorecards: Scorecard[] = mockScorecards
3533

3634
const {
3735
scoreCards: scorecards,
3836
metadata,
3937
isValidating: isLoadingScorecards,
4038
}: ScorecardsResponse = useFetchScorecards({
4139
challengeTrack: filters.projectType,
40+
challengeType: filters.category,
4241
name: filters.name,
4342
page,
44-
perPage: 10,
43+
perPage,
44+
scorecardType: filters.type,
4545
status: filters.status,
46-
type: filters.type,
4746
})
4847

49-
const handleFiltersChange = useCallback((newFilters: Partial<typeof filters>) => {
50-
setFilters(newFilters as typeof filters)
51-
setPage(1) // Optional: reset page on filter change
48+
const handleFiltersChange = useCallback((newFilters: typeof filters) => {
49+
setFilters(newFilters)
50+
setPage(1)
5251
}, [])
5352

5453
const handleScorecardClone = useCallback(async (scorecard: Scorecard) => {
@@ -81,6 +80,11 @@ export const ScorecardsListPage: FC<{}> = () => {
8180
breadCrumb={breadCrumb}
8281
>
8382
<PageTitle>Scorecards</PageTitle>
83+
<div className={styles.totalScorecards}>
84+
{metadata?.total}
85+
{' '}
86+
scorecards
87+
</div>
8488
<ScorecardsFilter
8589
filters={filters}
8690
onFiltersChange={handleFiltersChange}
@@ -97,7 +101,12 @@ export const ScorecardsListPage: FC<{}> = () => {
97101
totalPages={metadata?.totalPages}
98102
page={page}
99103
setPage={setPage}
100-
datas={scorecards}
104+
datas={scorecards.map((item, i) => ({
105+
...item,
106+
index: (page - 1) * perPage + i + 1,
107+
}))}
108+
metadata={metadata}
109+
perPage={perPage}
101110
/>
102111
)}
103112

0 commit comments

Comments
 (0)