diff --git a/frontend/app/components/Release/ReleaseInfo.jsx b/frontend/app/components/Release/ReleaseInfo.jsx index 8f643c8..6e87592 100644 --- a/frontend/app/components/Release/ReleaseInfo.jsx +++ b/frontend/app/components/Release/ReleaseInfo.jsx @@ -10,6 +10,7 @@ export const ReleaseInfo = (props) => { const userStore = useUserStore(); const [releaseInfo, setReleaseInfo] = useState(); const [list, setList] = useState(); + const [isFavorite, setIsFavorite] = useState(false); const [timer, seTimer] = useState(); useEffect(() => { @@ -24,6 +25,7 @@ export const ReleaseInfo = (props) => { setReleaseInfo(release); if (userStore.token) { setList(release.release.profile_list_status || 0); + setIsFavorite(release.release.is_favorite); } } @@ -59,6 +61,15 @@ export const ReleaseInfo = (props) => { } }, [userStore.token, list]); + function _setFav() { + async function __updateFavorite() { + const add_url = `${endpoints.user.favorites}/list/${props.id}/add?token=${userStore.token}`; + const delete_url = `${endpoints.user.favorites}/list/${props.id}/delete?token=${userStore.token}`; + await getData(!isFavorite ? add_url : delete_url); + } + __updateFavorite(); + } + const lists = [ { list: 0, name: "Не смотрю" }, { list: 1, name: "Смотрю" }, @@ -86,8 +97,8 @@ export const ReleaseInfo = (props) => { {releaseInfo.release.title_original} -