Implemented the new react version of the frontend
This commit is contained in:
1 parent
236e6e06fb
commit
ffe7e52527
65 files changed
+5228
-177
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { api } from '@/lib/api';
|
||||
import { normalizeCollection } from '@/lib/normalizers';
|
||||
import type { Collection } from '@/types';
|
||||
|
||||
export const collectionsApi = {
|
||||
getAll: () =>
|
||||
api
|
||||
.get<Collection[]>('/collections')
|
||||
.then((r) => r.data.map(normalizeCollection)),
|
||||
|
||||
getById: (id: number) =>
|
||||
api
|
||||
.get<Collection>(`/collections/${id}`)
|
||||
.then((r) => normalizeCollection(r.data)),
|
||||
|
||||
create: (data: Partial<Collection>) =>
|
||||
api.post<Collection>('/collections', data).then((r) => r.data),
|
||||
|
||||
update: (id: number, data: Partial<Collection>) =>
|
||||
api.put<Collection>(`/collections/${id}`, data).then((r) => normalizeCollection(r.data)),
|
||||
|
||||
updateWithMedia: (id: number, formData: FormData) =>
|
||||
api
|
||||
.put<Collection>(`/collections/${id}`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
.then((r) => normalizeCollection(r.data)),
|
||||
|
||||
delete: (id: number) =>
|
||||
api.delete(`/collections/${id}`).then((r) => r.data),
|
||||
|
||||
addEntry: (collectionId: number, entryId: number) =>
|
||||
api
|
||||
.post(`/collections/${collectionId}/entries`, { entry_id: entryId })
|
||||
.then((r) => r.data),
|
||||
|
||||
removeEntry: (collectionId: number, entryId: number) =>
|
||||
api
|
||||
.delete(`/collections/${collectionId}/entries/${entryId}`)
|
||||
.then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
import { api } from '@/lib/api';
|
||||
import { normalizeEntry } from '@/lib/normalizers';
|
||||
import type { Entry } from '@/types';
|
||||
|
||||
export const entriesApi = {
|
||||
getAll: () =>
|
||||
api.get<Entry[]>('/entries').then((r) => r.data.map(normalizeEntry)),
|
||||
|
||||
getById: (id: number) =>
|
||||
api.get<Entry>(`/entries/${id}`).then((r) => normalizeEntry(r.data)),
|
||||
|
||||
create: (tmdb_id: number, is_tvserie: boolean) =>
|
||||
api.post<Entry>('/entries', { tmdb_id, is_tvserie }).then((r) => normalizeEntry(r.data)),
|
||||
|
||||
update: (id: number, data: Partial<Entry>) =>
|
||||
api.put<Entry>(`/entries/${id}`, data).then((r) => normalizeEntry(r.data)),
|
||||
|
||||
updateRatings: (
|
||||
id: number,
|
||||
ratings: {
|
||||
user_rating?: number | null;
|
||||
tmdb_rating?: number | null;
|
||||
imdb_rating?: number | null;
|
||||
rotten_tomatoes_rating?: number | null;
|
||||
}
|
||||
) => api.put(`/entries/${id}/ratings`, ratings).then((r) => r.data),
|
||||
|
||||
updateIds: (
|
||||
id: number,
|
||||
ids: { tmdb_id?: number; imdb_id?: string; tvdb_id?: number }
|
||||
) => api.put(`/entries/${id}/ids`, ids).then((r) => r.data),
|
||||
|
||||
delete: (id: number) => api.delete(`/entries/${id}`).then((r) => r.data),
|
||||
|
||||
refresh: (id: number) =>
|
||||
api.put<Entry>(`/entries/${id}/refresh`).then((r) => normalizeEntry(r.data)),
|
||||
|
||||
fetchCollection: (id: number) =>
|
||||
api.put(`/entries/${id}/fetch-collection`).then((r) => r.data),
|
||||
|
||||
getSeasons: (id: number) =>
|
||||
api.get(`/entries/${id}/seasons`).then((r) => Array.isArray(r.data) ? r.data : []),
|
||||
|
||||
syncSeries: () => api.get('/entries/sync-series').then((r) => r.data),
|
||||
|
||||
uploadMedia: (id: number, formData: FormData) =>
|
||||
api
|
||||
.post(`/entries/${id}/media`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
setMediaSelected: (entryId: number, mediaId: number) =>
|
||||
api.put(`/entries/${entryId}/media/${mediaId}`).then((r) => r.data),
|
||||
|
||||
deleteMedia: (entryId: number, mediaId: number) =>
|
||||
api.delete(`/entries/${entryId}/media/${mediaId}`).then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { EntrySeen } from '@/types';
|
||||
|
||||
export const entrySeenApi = {
|
||||
getAll: () => api.get<EntrySeen[]>('/entry-seen').then((r) => r.data),
|
||||
|
||||
getById: (id: number) =>
|
||||
api.get<EntrySeen>(`/entry-seen/${id}`).then((r) => r.data),
|
||||
|
||||
getByEntry: (entryId: number) =>
|
||||
api.get<EntrySeen[]>(`/entry-seen/by-entry/${entryId}`).then((r) => r.data),
|
||||
|
||||
create: (data: { entry_id: number; date_seen: string; seen_with?: string }) =>
|
||||
api.post<EntrySeen>('/entry-seen', data).then((r) => r.data),
|
||||
|
||||
update: (id: number, data: Partial<EntrySeen>) =>
|
||||
api.put<EntrySeen>(`/entry-seen/${id}`, data).then((r) => r.data),
|
||||
|
||||
delete: (id: number) => api.delete(`/entry-seen/${id}`).then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { EpisodeSeen } from '@/types';
|
||||
|
||||
export const episodeSeenApi = {
|
||||
getAll: () => api.get<EpisodeSeen[]>('/episode-seen').then((r) => r.data),
|
||||
|
||||
getById: (id: number) =>
|
||||
api.get<EpisodeSeen>(`/episode-seen/${id}`).then((r) => r.data),
|
||||
|
||||
getByEpisode: (episodeId: number) =>
|
||||
api
|
||||
.get<EpisodeSeen[]>(`/episode-seen/by-episode/${episodeId}`)
|
||||
.then((r) => r.data),
|
||||
|
||||
create: (data: {
|
||||
entry_id: number;
|
||||
episode_id: number;
|
||||
date_seen: string;
|
||||
seen_with?: string;
|
||||
}) => api.post<EpisodeSeen>('/episode-seen', data).then((r) => r.data),
|
||||
|
||||
update: (id: number, data: Partial<EpisodeSeen>) =>
|
||||
api.put<EpisodeSeen>(`/episode-seen/${id}`, data).then((r) => r.data),
|
||||
|
||||
delete: (id: number) =>
|
||||
api.delete(`/episode-seen/${id}`).then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { Episode } from '@/types';
|
||||
|
||||
export const episodesApi = {
|
||||
getByMonth: (startDate: string, endDate: string) =>
|
||||
api
|
||||
.get<Episode[]>(`/episodes/month/${startDate}/${endDate}`)
|
||||
.then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { People } from '@/types';
|
||||
|
||||
export const peopleApi = {
|
||||
getAll: () => api.get<People[]>('/people').then((r) => r.data),
|
||||
|
||||
getById: (id: number) =>
|
||||
api.get<People>(`/people/${id}`).then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { Season } from '@/types';
|
||||
|
||||
export const seasonsApi = {
|
||||
getAll: () => api.get<Season[]>('/seasons').then((r) => r.data),
|
||||
|
||||
getById: (id: number) =>
|
||||
api.get<Season>(`/seasons/${id}`).then((r) => r.data),
|
||||
|
||||
getEpisodes: (id: number) =>
|
||||
api.get(`/seasons/${id}/episodes`).then((r) => r.data),
|
||||
|
||||
create: (data: Partial<Season>) =>
|
||||
api.post<Season>('/seasons', data).then((r) => r.data),
|
||||
|
||||
update: (id: number, data: Partial<Season>) =>
|
||||
api.put<Season>(`/seasons/${id}`, data).then((r) => r.data),
|
||||
|
||||
delete: (id: number) => api.delete(`/seasons/${id}`).then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { Settings } from '@/types';
|
||||
|
||||
export const settingsApi = {
|
||||
get: () => api.get<Settings>('/settings').then((r) => r.data),
|
||||
|
||||
update: (data: Partial<Settings>) =>
|
||||
api.put<Settings>('/settings', data).then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
import { api } from '@/lib/api';
|
||||
|
||||
export const statisticsApi = {
|
||||
get: () => api.get('/statistics').then((r) => r.data),
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
import { api } from '@/lib/api';
|
||||
import type { TmdbEntry, TmdbPaginatedResponse, TmdbPerson } from '@/types';
|
||||
|
||||
export const tmdbApi = {
|
||||
getPopularMovies: (page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbEntry>>('/entries/tmdb/popular/movie', {
|
||||
params: { page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
getPopularTv: (page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbEntry>>('/entries/tmdb/popular/tv', {
|
||||
params: { page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
getTrendingMovies: (page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbEntry>>('/entries/tmdb/trending/movie', {
|
||||
params: { page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
getTrendingTv: (page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbEntry>>('/entries/tmdb/trending/tv', {
|
||||
params: { page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
search: (query: string, page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbEntry>>('/entries/tmdb/search', {
|
||||
params: { query, page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
getPopularPeople: (page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbPerson>>('/people/tmdb/popular', {
|
||||
params: { page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
searchPeople: (query: string, page = 1) =>
|
||||
api
|
||||
.get<TmdbPaginatedResponse<TmdbPerson>>('/people/tmdb/search', {
|
||||
params: { query, page },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
};
|
||||
Reference in new issue
Block a user