-
Notifications
You must be signed in to change notification settings - Fork 18
feat(PM-1503): Route modifications in scorecard #1183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* The router outlet. | ||
*/ | ||
|
||
import { FC, PropsWithChildren, useContext, useEffect, useMemo } from 'react' | ||
import { Outlet, Routes, useLocation } from 'react-router-dom' | ||
|
||
import { routerContext, RouterContextData } from '~/libs/core' | ||
|
||
import { reviewRoutes } from '../../review-app.routes' | ||
import { scorecardRouteId } from '../../config/routes.config' | ||
|
||
export const ScorecardsContainer: FC<PropsWithChildren> = () => { | ||
const location = useLocation() | ||
const childRoutes = useChildRoutes() | ||
|
||
useEffect(() => { | ||
window.scrollTo(0, 0) | ||
}, [location.pathname]) | ||
|
||
return ( | ||
<> | ||
<Outlet /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
<Routes>{childRoutes}</Routes> | ||
</> | ||
) | ||
} | ||
|
||
function useChildRoutes(): Array<JSX.Element> | undefined { | ||
const { getRouteElement }: RouterContextData = useContext(routerContext) | ||
const childRoutes = useMemo( | ||
() => reviewRoutes[0].children | ||
?.find(r => r.id === scorecardRouteId) | ||
?.children?.map(getRouteElement), | ||
[getRouteElement], | ||
) | ||
return childRoutes | ||
} | ||
|
||
export default ScorecardsContainer |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ import { FC, useCallback, useMemo, useState } from 'react' | |
import { PageTitle } from '~/libs/ui' | ||
import { TableLoading } from '~/apps/admin/src/lib' | ||
|
||
import { PageWrapper, ScorecardsFilter, TableNoRecord, TableScorecards } from '../../lib' | ||
import { ScorecardsResponse, useFetchScorecards } from '../../lib/hooks' | ||
import { PageWrapper, ScorecardsFilter, TableNoRecord, TableScorecards } from '../../../lib' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import path for |
||
import { ScorecardsResponse, useFetchScorecards } from '../../../lib/hooks' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import path for |
||
|
||
import styles from './ScorecardsListPage.module.scss' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FC } from 'react' | ||
|
||
const ViewScorecardPage: FC = () => ( | ||
<div>View scorecard</div> | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a semicolon at the end of the line for consistency with the rest of the codebase. |
||
|
||
export default ViewScorecardPage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as ViewScorecardPage } from './ViewScorecardPage' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,21 @@ const ScorecardDetailsPage: LazyLoadedComponent = lazyLoad( | |
'ScorecardDetailsPage', | ||
) | ||
|
||
const ScorecardsContainer: LazyLoadedComponent = lazyLoad( | ||
() => import('./pages/scorecards/ScorecardsContainer'), | ||
'ScorecardsContainer', | ||
) | ||
|
||
const ScorecardsListPage: LazyLoadedComponent = lazyLoad( | ||
() => import('./pages/scorecards/ScorecardsListPage'), | ||
'ScorecardsListPage', | ||
) | ||
|
||
const ViewScorecardPage: LazyLoadedComponent = lazyLoad( | ||
() => import('./pages/scorecards/ViewScorecardPage'), | ||
'ViewScorecardPage', | ||
) | ||
|
||
export const toolTitle: string = ToolTitle.review | ||
|
||
export const reviewRoutes: ReadonlyArray<PlatformRoute> = [ | ||
|
@@ -85,7 +95,20 @@ export const reviewRoutes: ReadonlyArray<PlatformRoute> = [ | |
route: activeReviewAssigmentsRouteId, | ||
}, | ||
{ | ||
element: <ScorecardsListPage />, | ||
children: [ | ||
{ | ||
element: <ScorecardsListPage />, | ||
id: 'list-scorecards-page', | ||
route: '', | ||
}, | ||
{ | ||
element: <ViewScorecardPage />, | ||
id: 'view-scorecard-page', | ||
route: ':scorecardId', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The route |
||
}, | ||
|
||
], | ||
element: <ScorecardsContainer />, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
id: scorecardRouteId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
route: scorecardRouteId, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing unused import
PropsWithChildren
sinceScorecardsContainer
does not utilize any children props.