feat: auth & admin
This commit is contained in:
@@ -15,25 +15,52 @@ export const playlistsApi = api.injectEndpoints({
|
||||
query: (id) => `/playlists/${id}/tracks`,
|
||||
providesTags: (_r, _e, id) => [{ type: 'Playlist', id }, 'Track'],
|
||||
}),
|
||||
createPlaylist: build.mutation<Playlist, { name: string; description?: string; isPublic?: boolean }>({
|
||||
createPlaylist: build.mutation<
|
||||
Playlist,
|
||||
{ name: string; description?: string; isPublic?: boolean }
|
||||
>({
|
||||
query: (body) => ({ url: '/playlists', method: 'POST', body }),
|
||||
invalidatesTags: ['Playlist'],
|
||||
}),
|
||||
updatePlaylist: build.mutation<Playlist, { id: string; name?: string; description?: string; isPublic?: boolean }>({
|
||||
query: ({ id, ...body }) => ({ url: `/playlists/${id}`, method: 'PATCH', body }),
|
||||
updatePlaylist: build.mutation<
|
||||
Playlist,
|
||||
{ id: string; name?: string; description?: string; isPublic?: boolean }
|
||||
>({
|
||||
query: ({ id, ...body }) => ({
|
||||
url: `/playlists/${id}`,
|
||||
method: 'PATCH',
|
||||
body,
|
||||
}),
|
||||
invalidatesTags: (_r, _e, { id }) => [{ type: 'Playlist', id }],
|
||||
}),
|
||||
deletePlaylist: build.mutation<void, string>({
|
||||
query: (id) => ({ url: `/playlists/${id}`, method: 'DELETE' }),
|
||||
invalidatesTags: ['Playlist'],
|
||||
}),
|
||||
addTrackToPlaylist: build.mutation<void, { playlistId: string; trackId: string }>({
|
||||
query: ({ playlistId, trackId }) => ({ url: `/playlists/${playlistId}/tracks`, method: 'POST', body: { trackId } }),
|
||||
invalidatesTags: (_r, _e, { playlistId }) => [{ type: 'Playlist', id: playlistId }],
|
||||
addTrackToPlaylist: build.mutation<
|
||||
void,
|
||||
{ playlistId: string; trackId: string }
|
||||
>({
|
||||
query: ({ playlistId, trackId }) => ({
|
||||
url: `/playlists/${playlistId}/tracks`,
|
||||
method: 'POST',
|
||||
body: { trackId },
|
||||
}),
|
||||
invalidatesTags: (_r, _e, { playlistId }) => [
|
||||
{ type: 'Playlist', id: playlistId },
|
||||
],
|
||||
}),
|
||||
removeTrackFromPlaylist: build.mutation<void, { playlistId: string; trackId: string; position: number }>({
|
||||
query: ({ playlistId, position }) => ({ url: `/playlists/${playlistId}/tracks/${position}`, method: 'DELETE' }),
|
||||
invalidatesTags: (_r, _e, { playlistId }) => [{ type: 'Playlist', id: playlistId }],
|
||||
removeTrackFromPlaylist: build.mutation<
|
||||
void,
|
||||
{ playlistId: string; trackId: string; position: number }
|
||||
>({
|
||||
query: ({ playlistId, position }) => ({
|
||||
url: `/playlists/${playlistId}/tracks/${position}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: (_r, _e, { playlistId }) => [
|
||||
{ type: 'Playlist', id: playlistId },
|
||||
],
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
|
||||
Reference in New Issue
Block a user