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.
 
 
 
 
spa_instat_tv/src/features/ProfileHeader/hooks.tsx

61 lines
1.4 KiB

import { useEffect, useState } from 'react'
import { getProfileColor } from 'requests/getProfileColor'
import { usePageParams } from 'hooks/usePageParams'
import { getColor } from 'helpers/getColor'
import { client } from 'config/clients'
import { DEFAULT_HEADER_COLOR } from './styled'
export const useProfileColor = (profileId?: number) => {
const {
profileType,
sportType,
} = usePageParams()
const [color, setColor] = useState(DEFAULT_HEADER_COLOR)
useEffect(() => {
if (!profileId) return
getProfileColor({
profileId,
profileType,
sportType,
}).then(setColor)
}, [
profileId,
profileType,
sportType,
])
// TODO remove this logic when backend will return the correct colors
const prifileWithConfifColor = [
227, 946, 3067, 5665, 23, 2719, 528, 17018, 567, 16306, 1189, 480, 16920, 6032, 17624, 114440,
]
if (
client.name === 'facr'
&& sportType === 1 && profileId && prifileWithConfifColor.includes(profileId)
) {
return getColor(profileId)
}
const lffColorConfig = [
262,
928,
1620,
5858,
5975,
5976,
6004,
1000045,
1000046,
1000047,
1000048,
]
// eslint-disable-next-line postro4no/function-args
if (client.name === 'lff' && profileId && lffColorConfig.includes(profileId)) {
return getColor(profileId)
}
return color
}