-
Notifications
You must be signed in to change notification settings - Fork 21
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 1 commit
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 |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import { FC, useCallback, useMemo, useState } from 'react' | ||
| import { FC, useCallback, useContext, 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,8 @@ | ||
| const ViewScorecardPage = () => { | ||
| return ( | ||
| <div>View scorecard</div> | ||
| ) | ||
| }; | ||
|
|
||
| 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,9 +95,22 @@ export const reviewRoutes: ReadonlyArray<PlatformRoute> = [ | |
| route: activeReviewAssigmentsRouteId, | ||
| }, | ||
| { | ||
| element: <ScorecardsListPage />, | ||
| element: <ScorecardsContainer />, | ||
|
||
| id: scorecardRouteId, | ||
| route: scorecardRouteId, | ||
| 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 |
||
| }, | ||
|
|
||
| ], | ||
| }, | ||
| ], | ||
| domain: AppSubdomain.review, | ||
|
|
||
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
PropsWithChildrensinceScorecardsContainerdoes not utilize any children props.