parent
d9d4de4072
commit
f9823d191f
@ -1,61 +0,0 @@ |
|||||||
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 |
|
||||||
} |
|
||||||
@ -1,33 +0,0 @@ |
|||||||
import { isMobileDevice } from 'config/userAgent' |
|
||||||
|
|
||||||
const degree = isMobileDevice ? '270deg' : '0deg' |
|
||||||
|
|
||||||
export const getCardColor = (id: number | undefined): string => { |
|
||||||
const defaultColor = 'none' |
|
||||||
|
|
||||||
if (!id) return defaultColor |
|
||||||
|
|
||||||
switch (id) { |
|
||||||
case 928: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(49,186,177,1) 100%);` |
|
||||||
case 1620: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(96,24,75,1) 100%);` |
|
||||||
case 5976: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(0,160,228,1) 100%);` |
|
||||||
case 5975: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(225,27,74,1) 100%);` |
|
||||||
case 5858: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(252,162,78, 1) 100%);` |
|
||||||
case 262: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(192,166,96,1) 100%);` |
|
||||||
case 6004: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(79,81,205,1) 100%);` |
|
||||||
case 100045: |
|
||||||
case 100046: |
|
||||||
case 100047: |
|
||||||
case 100048: |
|
||||||
return `linear-gradient(${degree}, rgba(63,63,63,1) 35%, rgba(55, 179, 72,1) 100%);` |
|
||||||
default: |
|
||||||
return defaultColor |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,53 +0,0 @@ |
|||||||
import { client } from 'config/clients' |
|
||||||
|
|
||||||
const DEFAULT_FACR_COLOR = 'linear-gradient(83.42deg, #00257A 53.04%, rgba(0, 0, 0, 0) 94.83%), #000000' |
|
||||||
const DEFAULT_INSTAT_COLOR = 'linear-gradient( 187deg, rgba(53,96,225,0.56) -4.49%, #000000 68.29%), #000000' |
|
||||||
|
|
||||||
export const getColor = (id: number | undefined): string => { |
|
||||||
const currentDefaultColor = client.name === 'facr' ? DEFAULT_FACR_COLOR : DEFAULT_INSTAT_COLOR |
|
||||||
|
|
||||||
if (!id) return currentDefaultColor |
|
||||||
switch (id) { |
|
||||||
case 227: |
|
||||||
return 'linear-gradient(83.42deg, #004A49 53.04%, #071616 94.83%), #000000' |
|
||||||
case 946: |
|
||||||
return 'linear-gradient(83.42deg, #000000 53.04%, #000000 94.83%), #000000' |
|
||||||
case 3067: |
|
||||||
return 'linear-gradient(83.42deg, #007179 53.04%, #007179 94.83%), #000000' |
|
||||||
case 928: |
|
||||||
return 'linear-gradient(90deg, rgba(21,83,79,1) 0%, rgba(49,186,177,1) 100%);' |
|
||||||
case 1620: |
|
||||||
return 'linear-gradient(90deg, rgba(47,4,39,1) 0%, rgba(96,24,75,1) 100%);' |
|
||||||
case 5976: |
|
||||||
return 'linear-gradient(90deg, rgba(13,94,129,1) 0%, rgba(0,160,228,1) 100%);' |
|
||||||
case 5975: |
|
||||||
return 'linear-gradient(90deg, rgba(140,13,43,1) 0%, rgba(225,27,74,1) 100%);' |
|
||||||
case 5858: |
|
||||||
return 'linear-gradient(90deg, rgba(184,99,21,1) 0%, rgba(252,162,78, 1) 100%);' |
|
||||||
case 262: |
|
||||||
return 'linear-gradient(90deg, rgba(114,103,76,1) 0%, rgba(192,166,96,1) 100%);' |
|
||||||
case 6004: |
|
||||||
return 'linear-gradient(255.69deg, #474AF1 15.59%, #202284 94.93%);' |
|
||||||
case 1000045: |
|
||||||
case 1000046: |
|
||||||
case 1000047: |
|
||||||
case 1000048: |
|
||||||
return 'linear-gradient(255.69deg, #37B348 15.59%, #003E08 94.93%);' |
|
||||||
case 5665: |
|
||||||
case 23: |
|
||||||
case 2719: |
|
||||||
case 528: |
|
||||||
case 17018: |
|
||||||
case 567: |
|
||||||
case 16306: |
|
||||||
case 1189: |
|
||||||
case 480: |
|
||||||
case 16920: |
|
||||||
case 6032: |
|
||||||
case 17624: |
|
||||||
case 114440: |
|
||||||
return 'linear-gradient(83.42deg, #01257B 53.04%, #0144B5 94.83%), #000000' |
|
||||||
default: |
|
||||||
return currentDefaultColor |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,48 +0,0 @@ |
|||||||
import { |
|
||||||
API_ROOT, |
|
||||||
ProfileTypes, |
|
||||||
|
|
||||||
} from 'config' |
|
||||||
import { callApi } from 'helpers' |
|
||||||
|
|
||||||
const profiles = { |
|
||||||
[ProfileTypes.TEAMS]: 'team', |
|
||||||
[ProfileTypes.TOURNAMENTS]: 'tournament', |
|
||||||
[ProfileTypes.PLAYERS]: 'team', |
|
||||||
[ProfileTypes.MATCHES]: '', |
|
||||||
[ProfileTypes.SUPERTOURNAMENTS]: '', |
|
||||||
} |
|
||||||
|
|
||||||
type Response = { |
|
||||||
b: number, |
|
||||||
code: string, |
|
||||||
g: number, |
|
||||||
r: number, |
|
||||||
} |
|
||||||
|
|
||||||
type Args = { |
|
||||||
profileId: number, |
|
||||||
profileType: ProfileTypes, |
|
||||||
sportType: number, |
|
||||||
} |
|
||||||
|
|
||||||
export const getProfileColor = async ({ |
|
||||||
profileId, |
|
||||||
profileType, |
|
||||||
sportType, |
|
||||||
}: Args): Promise<string> => { |
|
||||||
const config = { |
|
||||||
body: { |
|
||||||
profile_id: profileId, |
|
||||||
profile_type: profiles[profileType], |
|
||||||
sport_id: sportType, |
|
||||||
}, |
|
||||||
} |
|
||||||
|
|
||||||
const response: Response = await callApi({ |
|
||||||
config, |
|
||||||
url: `${API_ROOT}/profile/color`, |
|
||||||
}) |
|
||||||
|
|
||||||
return `rgba(${response.r}, ${response.g}, ${response.b}, 0.56)` |
|
||||||
} |
|
||||||
Loading…
Reference in new issue