|
|
|
@ -9,13 +9,18 @@ import { |
|
|
|
|
|
|
|
|
|
|
|
import debounce from 'lodash/debounce' |
|
|
|
import debounce from 'lodash/debounce' |
|
|
|
|
|
|
|
|
|
|
|
import { useRecoilState, useSetRecoilState } from 'recoil' |
|
|
|
import { |
|
|
|
|
|
|
|
useRecoilState, |
|
|
|
|
|
|
|
useSetRecoilState, |
|
|
|
|
|
|
|
useRecoilValue, |
|
|
|
|
|
|
|
} from 'recoil' |
|
|
|
|
|
|
|
|
|
|
|
import { useUserFavoritesStore } from 'features/UserFavorites/store' |
|
|
|
import { useUserFavoritesStore } from 'features/UserFavorites/store' |
|
|
|
|
|
|
|
|
|
|
|
import type { Match } from 'requests/getMatches/types' |
|
|
|
import type { Match } from 'requests/getMatches/types' |
|
|
|
|
|
|
|
|
|
|
|
import { getSportList } from 'requests/getSportList' |
|
|
|
import { getSportList } from 'requests/getSportList' |
|
|
|
|
|
|
|
import { getSounds } from 'requests/getSounds' |
|
|
|
import { |
|
|
|
import { |
|
|
|
getSportTeams, |
|
|
|
getSportTeams, |
|
|
|
Team, |
|
|
|
Team, |
|
|
|
@ -25,6 +30,7 @@ import { getPlayerMatches } from 'requests/getMatches/getPlayerMatches' |
|
|
|
import { getTeamPlayers, Player } from 'requests/getTeamPlayers' |
|
|
|
import { getTeamPlayers, Player } from 'requests/getTeamPlayers' |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
|
|
|
|
checkedMatches, |
|
|
|
playerMatchesState, |
|
|
|
playerMatchesState, |
|
|
|
dataForPayHighlights, |
|
|
|
dataForPayHighlights, |
|
|
|
fetchingMatches, |
|
|
|
fetchingMatches, |
|
|
|
@ -51,9 +57,9 @@ type TeamType = Team & { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Sound = { |
|
|
|
type Sound = { |
|
|
|
|
|
|
|
asset?: string | null, |
|
|
|
id: number, |
|
|
|
id: number, |
|
|
|
name: string, |
|
|
|
name: string, |
|
|
|
src?: string, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type StatsType = { |
|
|
|
type StatsType = { |
|
|
|
@ -73,82 +79,6 @@ type FormType = { |
|
|
|
teamValue: string, |
|
|
|
teamValue: string, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const sounds = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 0, |
|
|
|
|
|
|
|
name: 'No', |
|
|
|
|
|
|
|
src: '', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 1, |
|
|
|
|
|
|
|
lexic: 19469, |
|
|
|
|
|
|
|
name: 'Main theme', |
|
|
|
|
|
|
|
src: '/sounds/background_track.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 2, |
|
|
|
|
|
|
|
lexic: 19470, |
|
|
|
|
|
|
|
name: 'First music', |
|
|
|
|
|
|
|
src: 'sounds/1.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 3, |
|
|
|
|
|
|
|
lexic: 19471, |
|
|
|
|
|
|
|
name: 'Basement by Monako', |
|
|
|
|
|
|
|
src: '/sounds/basement by monako Artlist.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 4, |
|
|
|
|
|
|
|
lexic: 19472, |
|
|
|
|
|
|
|
name: 'Buss-it by Yarin Primak', |
|
|
|
|
|
|
|
src: '/sounds/buss-it---instrumental-version by yarin-primak Artlist.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 5, |
|
|
|
|
|
|
|
lexic: 19473, |
|
|
|
|
|
|
|
name: "Can't stop me now by Brightout", |
|
|
|
|
|
|
|
src: |
|
|
|
|
|
|
|
'/sounds/cant-stop-me-now-instrumental-brightout-musicbed-licensed.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 6, |
|
|
|
|
|
|
|
lexic: 19474, |
|
|
|
|
|
|
|
name: 'Follow me by ShyGhy', |
|
|
|
|
|
|
|
src: '/sounds/follow-me-shyghy-musicbed-licensed.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 7, |
|
|
|
|
|
|
|
lexic: 19475, |
|
|
|
|
|
|
|
name: 'Gravity by Stanley Gurvich', |
|
|
|
|
|
|
|
src: '/sounds/gravity by stanley-gurvich Artlist.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 8, |
|
|
|
|
|
|
|
lexic: 19476, |
|
|
|
|
|
|
|
name: 'Light it up by Bloom & the Bliss', |
|
|
|
|
|
|
|
src: |
|
|
|
|
|
|
|
'/sounds/light-it-up-instrumental-bloom-the-bliss-musicbed-licensed.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 9, |
|
|
|
|
|
|
|
lexic: 19477, |
|
|
|
|
|
|
|
name: 'Living future memories by Generdyn', |
|
|
|
|
|
|
|
src: '/sounds/living-future-memories-generdyn-musicbed-licensed.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 10, |
|
|
|
|
|
|
|
lexic: 19478, |
|
|
|
|
|
|
|
name: 'Look at me now by Paper kings', |
|
|
|
|
|
|
|
src: |
|
|
|
|
|
|
|
'/sounds/look-at-me-now-instrumental-paper-kings-musicbed-licensed.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 11, |
|
|
|
|
|
|
|
lexic: 19479, |
|
|
|
|
|
|
|
name: 'Unbroken by Roary', |
|
|
|
|
|
|
|
src: '/sounds/unbroken-roary-musicbed-licensed.mp3', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
const summaryStats = [ |
|
|
|
const summaryStats = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
id: 0, |
|
|
|
id: 0, |
|
|
|
@ -176,12 +106,16 @@ export const useHighlightsForm = () => { |
|
|
|
const { playerHighlight } = useUserFavoritesStore() |
|
|
|
const { playerHighlight } = useUserFavoritesStore() |
|
|
|
|
|
|
|
|
|
|
|
const [sports, setSports] = useState<Array<SportTypeName>>([]) |
|
|
|
const [sports, setSports] = useState<Array<SportTypeName>>([]) |
|
|
|
|
|
|
|
const [sounds, setSounds] = useState<any>([]) |
|
|
|
const [isFetchingTeams, setIsFetchingTeams] = useState(false) |
|
|
|
const [isFetchingTeams, setIsFetchingTeams] = useState(false) |
|
|
|
const [teams, setTeams] = useState<Array<TeamType>>([]) |
|
|
|
const [teams, setTeams] = useState<Array<TeamType>>([]) |
|
|
|
const [playersData, setPlayersData] = useState<Array<PlayerType>>([]) |
|
|
|
const [playersData, setPlayersData] = useState<Array<PlayerType>>([]) |
|
|
|
const [players, setPlayers] = useState<Array<PlayerType>>([]) |
|
|
|
const [players, setPlayers] = useState<Array<PlayerType>>([]) |
|
|
|
const [formState, setFormState] = useState<FormType>(defaultValues) |
|
|
|
const [formState, setFormState] = useState<FormType>(defaultValues) |
|
|
|
const [playerMatches, setPlayerMatches] = useRecoilState(playerMatchesState) |
|
|
|
const [playerMatches, setPlayerMatches] = useRecoilState(playerMatchesState) |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
checkedMatchesLength, |
|
|
|
|
|
|
|
} = useRecoilValue(checkedMatches) |
|
|
|
const setDatahighlights = useSetRecoilState(dataForPayHighlights) |
|
|
|
const setDatahighlights = useSetRecoilState(dataForPayHighlights) |
|
|
|
const setIsFetching = useSetRecoilState(fetchingMatches) |
|
|
|
const setIsFetching = useSetRecoilState(fetchingMatches) |
|
|
|
|
|
|
|
|
|
|
|
@ -283,6 +217,25 @@ export const useHighlightsForm = () => { |
|
|
|
name: sport?.name_eng, |
|
|
|
name: sport?.name_eng, |
|
|
|
})), |
|
|
|
})), |
|
|
|
)) |
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getSounds() |
|
|
|
|
|
|
|
.then((state) => { |
|
|
|
|
|
|
|
setSounds([{ |
|
|
|
|
|
|
|
asset: null, |
|
|
|
|
|
|
|
id: 100, |
|
|
|
|
|
|
|
name: 'No', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
...state, |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
setFormState((prev) => ({ |
|
|
|
|
|
|
|
...prev, |
|
|
|
|
|
|
|
selectedSound: { |
|
|
|
|
|
|
|
asset: null, |
|
|
|
|
|
|
|
id: 100, |
|
|
|
|
|
|
|
name: 'No', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
}) |
|
|
|
}, []) |
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
@ -328,6 +281,16 @@ export const useHighlightsForm = () => { |
|
|
|
[formState.teamValue], |
|
|
|
[formState.teamValue], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if (Number(formState?.duration) < checkedMatchesLength * 2) { |
|
|
|
|
|
|
|
setFormState((prev) => ({ |
|
|
|
|
|
|
|
...prev, |
|
|
|
|
|
|
|
duration: (checkedMatchesLength * 2).toString(), |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
}, [checkedMatchesLength]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (formState?.teamValue?.length >= 3 && formState?.sport) { |
|
|
|
if (formState?.teamValue?.length >= 3 && formState?.sport) { |
|
|
|
fetchTeams() |
|
|
|
fetchTeams() |
|
|
|
@ -339,12 +302,12 @@ export const useHighlightsForm = () => { |
|
|
|
if (formState?.selectedPlayer?.id && formState?.sport) { |
|
|
|
if (formState?.selectedPlayer?.id && formState?.sport) { |
|
|
|
setDatahighlights({ |
|
|
|
setDatahighlights({ |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
background_music: formState?.selectedSound?.src, |
|
|
|
background_music: formState?.selectedSound?.asset || null, |
|
|
|
duration: Number(formState?.duration) * 60, |
|
|
|
duration: Number(formState?.duration) * 60, |
|
|
|
lang: 'en', |
|
|
|
lang: 'en', |
|
|
|
matches: playerMatches?.filter(({ isChecked }) => (isChecked)).map(({ id }) => id), |
|
|
|
matches: playerMatches?.filter(({ isChecked }) => (isChecked)).map(({ id }) => id), |
|
|
|
player_id: formState?.selectedPlayer?.id, |
|
|
|
player_id: formState?.selectedPlayer?.id, |
|
|
|
price: playerMatches?.length * 25, |
|
|
|
price: checkedMatchesLength * 25, |
|
|
|
sport_id: formState?.sport.id, |
|
|
|
sport_id: formState?.sport.id, |
|
|
|
stats: Boolean(formState?.stats?.id), |
|
|
|
stats: Boolean(formState?.stats?.id), |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -378,6 +341,7 @@ export const useHighlightsForm = () => { |
|
|
|
&& getPlayerMatches({ |
|
|
|
&& getPlayerMatches({ |
|
|
|
limit: 1000, |
|
|
|
limit: 1000, |
|
|
|
offset: 0, |
|
|
|
offset: 0, |
|
|
|
|
|
|
|
p_match_completed: true, |
|
|
|
playerId: formState?.selectedPlayer?.id, |
|
|
|
playerId: formState?.selectedPlayer?.id, |
|
|
|
sportType: formState?.sport?.id, |
|
|
|
sportType: formState?.sport?.id, |
|
|
|
sub_only: false, |
|
|
|
sub_only: false, |
|
|
|
@ -391,6 +355,7 @@ export const useHighlightsForm = () => { |
|
|
|
}, [formState?.selectedPlayer, formState?.selectedTeam]) |
|
|
|
}, [formState?.selectedPlayer, formState?.selectedTeam]) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
checkedMatchesLength, |
|
|
|
formRef, |
|
|
|
formRef, |
|
|
|
formState, |
|
|
|
formState, |
|
|
|
handleSubmit, |
|
|
|
handleSubmit, |
|
|
|
|