Skip to content

Commit

Permalink
added conditional for dashboard link
Browse files Browse the repository at this point in the history
  • Loading branch information
ruizajtruss committed Jan 17, 2024
1 parent f43d2b5 commit a5129ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions services/app-web/src/pages/App/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from '../QuestionResponse'
import { GraphQLExplorer } from '../GraphQLExplorer/GraphQLExplorer'
import { RateSummary } from '../SubmissionSummary/RateSummary'
import { User } from '../../gen/gqlClient'

function componentForAuthMode(
authMode: AuthModeType
Expand Down Expand Up @@ -67,11 +68,13 @@ const StateUserRoutes = ({
setAlert,
showQuestionResponse,
stageName,
loggedInUser,
}: {
authMode: AuthModeType
setAlert?: React.Dispatch<React.ReactElement>
showQuestionResponse: boolean
stageName?: string
loggedInUser: User
}): React.ReactElement => {
// feature flag
const ldClient = useLDClient()
Expand Down Expand Up @@ -109,7 +112,7 @@ const StateUserRoutes = ({
{showRateSummaryPage && (
<Route
path={RoutesRecord.RATES_SUMMARY}
element={<RateSummary />}
element={<RateSummary loggedInUser={loggedInUser}/>}
/>
)}
<Route element={<SubmissionSideNav />}>
Expand Down Expand Up @@ -158,11 +161,13 @@ const CMSUserRoutes = ({
setAlert,
showQuestionResponse,
stageName,
loggedInUser
}: {
authMode: AuthModeType
setAlert?: React.Dispatch<React.ReactElement>
showQuestionResponse: boolean
stageName?: string
loggedInUser: User
}): React.ReactElement => {
return (
<AuthenticatedRouteWrapper authMode={authMode} setAlert={setAlert}>
Expand Down Expand Up @@ -213,7 +218,7 @@ const CMSUserRoutes = ({

<Route
path={RoutesRecord.RATES_SUMMARY}
element={<RateSummary />}
element={<RateSummary loggedInUser={loggedInUser}/>}
/>

<Route
Expand Down Expand Up @@ -383,6 +388,7 @@ export const AppRoutes = ({
setAlert={setAlert}
showQuestionResponse={showQuestionResponse}
stageName={stageName}
loggedInUser={loggedInUser}
/>
)
} else {
Expand All @@ -392,6 +398,7 @@ export const AppRoutes = ({
setAlert={setAlert}
showQuestionResponse={showQuestionResponse}
stageName={stageName}
loggedInUser={loggedInUser}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NavLink, useParams } from 'react-router-dom'

import { Loading } from '../../../components'
import { usePage } from '../../../contexts/PageContext'
import { useFetchRateQuery } from '../../../gen/gqlClient'
import { User, useFetchRateQuery } from '../../../gen/gqlClient'
import styles from '../SubmissionSummary.module.scss'
import { GenericErrorPage } from '../../Errors/GenericErrorPage'
import { RoutesRecord } from '../../../constants'
Expand All @@ -14,7 +14,7 @@ type RouteParams = {
id: string
}

export const RateSummary = (): React.ReactElement => {
export const RateSummary = ({loggedInUser}: {loggedInUser: User}): React.ReactElement => {
// Page level state
const { updateHeading } = usePage()
const [rateName, setRateName] = useState<string | undefined>(undefined)
Expand Down Expand Up @@ -66,8 +66,10 @@ export const RateSummary = (): React.ReactElement => {
<div>
<Link
asCustom={NavLink}
//TODO: Will have to remove this conditional along with associated loggedInUser prop once the rate dashboard
//is made available to state users
to={{
pathname: RoutesRecord.DASHBOARD_RATES,
pathname: loggedInUser.__typename === 'StateUser' ? RoutesRecord.DASHBOARD : RoutesRecord.DASHBOARD_RATES,
}}
>
<Icon.ArrowBack />
Expand Down

0 comments on commit a5129ef

Please sign in to comment.