Skip to content

Commit

Permalink
fix: redirect user to grant submit page on invalid category url (#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp authored Feb 16, 2024
1 parent cc8dc3f commit f9ebeba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/pages/submit/grant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ import Head from '../../components/Layout/Head'
import LoadingView from '../../components/Layout/LoadingView'
import LogIn from '../../components/Layout/LogIn'
import CategorySelector from '../../components/Projects/CategorySelector'
import { GrantRequest, GrantRequestCategoryAssessment, NewGrantCategory } from '../../entities/Grant/types'
import {
GrantRequest,
GrantRequestCategoryAssessment,
NewGrantCategory,
VALID_CATEGORIES,
} from '../../entities/Grant/types'
import { SUBMISSION_THRESHOLD_GRANT } from '../../entities/Proposal/constants'
import { ProposalType } from '../../entities/Proposal/types'
import { asNumber, isGrantProposalSubmitEnabled, userModifiedForm } from '../../entities/Proposal/utils'
Expand Down Expand Up @@ -118,7 +123,11 @@ export default function SubmitGrant() {
} catch (error) {
console.error(error)
} finally {
patchGrantRequest((prevState) => ({ ...prevState, category }))
if (category && VALID_CATEGORIES.includes(category)) {
patchGrantRequest((prevState) => ({ ...prevState, category }))
} else {
navigate('/submit/grant')
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
Expand Down

0 comments on commit f9ebeba

Please sign in to comment.