You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
631 B
27 lines
631 B
import { useRouteMatch } from 'react-router'
|
|
|
|
import toUpper from 'lodash/toUpper'
|
|
|
|
import { ProfileTypes, SportTypes } from 'config'
|
|
|
|
type RouteParams = {
|
|
pageId: string,
|
|
profileName: string,
|
|
sportName: string,
|
|
}
|
|
|
|
export const usePageParams = () => {
|
|
const {
|
|
params: {
|
|
pageId,
|
|
profileName,
|
|
sportName,
|
|
},
|
|
} = useRouteMatch<RouteParams>('/:sportName/:profileName/:pageId') || { params: {} }
|
|
|
|
return {
|
|
profileId: Number(pageId),
|
|
profileType: ProfileTypes[toUpper(profileName) as keyof typeof ProfileTypes],
|
|
sportType: SportTypes[toUpper(sportName) as keyof typeof SportTypes],
|
|
}
|
|
}
|
|
|