Add Discovery Videos feature
Let users upload videos, tag them with one or more entries, and watch them from a new Discovery Videos page. Backend: - Add Video and VideoEntry models and relations - Add video controller and /video routes - Add video thumbnail generation service (ffmpeg-static) - Add video upload storage location and config Frontend: - Add DiscoveryVideosPage with sidebar link and route - Add AddVideoDialog, VideoDropzone, EntryMultiSelect, VideoCard and VideoPlayerDialog components - Add discoveryVideos API client and useDiscoveryVideos hook - Add format helpers, video types and normalizers - Add skeleton for the page Docs: - Document the feature in docs-vault
This commit is contained in:
1 parent
4d88747649
commit
eb3a12f6cb
41 files changed
+2163
-15
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { api } from "@/lib/api";
|
||||
import { normalizeDiscoveryVideo } from "@/lib/normalizers";
|
||||
import type {
|
||||
DiscoveryVideo,
|
||||
DiscoveryVideoPaginatedResponse,
|
||||
} from "@/types";
|
||||
|
||||
export interface UpdateVideoData {
|
||||
title?: string;
|
||||
description?: string;
|
||||
entryIds: number[];
|
||||
}
|
||||
|
||||
export const discoveryVideosApi = {
|
||||
getAll: (page = 1, limit = 24) =>
|
||||
api
|
||||
.get<DiscoveryVideoPaginatedResponse>("/discovery-videos", {
|
||||
params: { page, limit },
|
||||
})
|
||||
.then((r) => ({
|
||||
...r.data,
|
||||
videos: r.data.videos.map(normalizeDiscoveryVideo),
|
||||
})),
|
||||
|
||||
create: (formData: FormData, onProgress?: (percent: number) => void) =>
|
||||
api
|
||||
.post<DiscoveryVideo[]>("/discovery-videos", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
onUploadProgress: (e) => {
|
||||
if (onProgress && e.total) {
|
||||
onProgress(Math.round((e.loaded / e.total) * 100));
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((r) => r.data.map(normalizeDiscoveryVideo)),
|
||||
|
||||
update: (id: number, data: UpdateVideoData) =>
|
||||
api
|
||||
.put<DiscoveryVideo>(`/discovery-videos/${id}`, data)
|
||||
.then((r) => normalizeDiscoveryVideo(r.data)),
|
||||
|
||||
remove: (id: number) => api.delete(`/discovery-videos/${id}`).then((r) => r.data),
|
||||
};
|
||||
Reference in new issue
Block a user