114 lines
2.1 KiB
JavaScript
114 lines
2.1 KiB
JavaScript
import { configureAxios, request } from "../requests"
|
|
|
|
export function fetchShows(url) {
|
|
return request(
|
|
"SHOW_LIST_FETCH",
|
|
configureAxios().get(url),
|
|
[
|
|
updateLastShowsFetchUrl(url),
|
|
]
|
|
)
|
|
}
|
|
|
|
export function getShowDetails(imdbId) {
|
|
return request(
|
|
"SHOW_GET_DETAILS",
|
|
configureAxios().post(`/shows/${imdbId}/refresh`),
|
|
null,
|
|
{ imdbId }
|
|
)
|
|
}
|
|
|
|
|
|
export function getEpisodeDetails(imdbId, season, episode) {
|
|
return request(
|
|
"EPISODE_GET_DETAILS",
|
|
configureAxios().post(`/shows/${imdbId}/seasons/${season}/episodes/${episode}`),
|
|
null,
|
|
{
|
|
imdbId,
|
|
season,
|
|
episode,
|
|
}
|
|
)
|
|
}
|
|
|
|
export function fetchShowDetails(imdbId) {
|
|
return request(
|
|
"SHOW_FETCH_DETAILS",
|
|
configureAxios().get(`/shows/${imdbId}`),
|
|
null,
|
|
{ imdbId }
|
|
)
|
|
}
|
|
|
|
export function addShowToWishlist(imdbId, season = null, episode = null) {
|
|
return request(
|
|
"SHOW_ADD_TO_WISHLIST",
|
|
configureAxios().post(`/wishlist/shows/${imdbId}`, {
|
|
season: season,
|
|
episode: episode,
|
|
}),
|
|
[
|
|
updateShowWishlistStore(imdbId, true, season, episode),
|
|
],
|
|
)
|
|
}
|
|
|
|
export function deleteShowFromWishlist(imdbId) {
|
|
return request(
|
|
"SHOW_DELETE_FROM_WISHLIST",
|
|
configureAxios().delete(`/wishlist/shows/${imdbId}`),
|
|
[
|
|
updateShowWishlistStore(imdbId, false),
|
|
],
|
|
)
|
|
}
|
|
|
|
export function updateShowWishlistStore(imdbId, wishlisted, season = null, episode = null) {
|
|
return {
|
|
type: "SHOW_UPDATE_STORE_WISHLIST",
|
|
payload: {
|
|
wishlisted: wishlisted,
|
|
imdbId,
|
|
season,
|
|
episode,
|
|
}
|
|
}
|
|
}
|
|
|
|
export function getShowExploreOptions() {
|
|
return request(
|
|
"SHOW_GET_EXPLORE_OPTIONS",
|
|
configureAxios().get("/shows/explore/options")
|
|
)
|
|
}
|
|
|
|
export function selectShow(imdbId) {
|
|
return {
|
|
type: "SELECT_SHOW",
|
|
payload: {
|
|
imdbId,
|
|
}
|
|
}
|
|
}
|
|
|
|
export function updateFilter(filter) {
|
|
return {
|
|
type: "SHOWS_UPDATE_FILTER",
|
|
payload: {
|
|
filter,
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
export function updateLastShowsFetchUrl(url) {
|
|
return {
|
|
type: "UPDATE_LAST_SHOWS_FETCH_URL",
|
|
payload: {
|
|
url: url,
|
|
},
|
|
}
|
|
}
|