diff --git a/frontend/src/components/video/VideoCard.tsx b/frontend/src/components/video/VideoCard.tsx index cd2bf2f..4bc544b 100644 --- a/frontend/src/components/video/VideoCard.tsx +++ b/frontend/src/components/video/VideoCard.tsx @@ -4,28 +4,28 @@ import {Link} from "react-router-dom"; type VideoCardProps = { title: string, - length: number, - thumbnailUrl: string, - videoUrl: string, + duration: number, + thumbnailPath: string, + videoPath: string, className?: string } const VideoCard = ({ title, - length, - thumbnailUrl, - videoUrl, + duration, + thumbnailPath, + videoPath, className}: VideoCardProps) => { return (
- Video Thumbnail + Video Thumbnail

{title}

-

{formatTime(length)}

+

{formatTime(duration)}

diff --git a/frontend/src/pages/MyClips.tsx b/frontend/src/pages/MyClips.tsx index ecedbb3..d03e343 100644 --- a/frontend/src/pages/MyClips.tsx +++ b/frontend/src/pages/MyClips.tsx @@ -1,17 +1,30 @@ import VideoCard from "../components/video/VideoCard"; +import {useEffect, useState} from "react"; +import { getClips } from "../utils/endpoints"; +import type { Clip } from "../utils/types"; const MyClips = () => { + const [clips, setClips] = useState([]); + const [error, setError] = useState(null); + + useEffect(() => { + getClips(setError).then((data) => setClips(data)); + }, []); + return ( -
- - +
+ {clips.map((clip) => ( + + ))} + {error}
); } diff --git a/frontend/src/utils/endpoints.ts b/frontend/src/utils/endpoints.ts index 43933d1..ae597a5 100644 --- a/frontend/src/utils/endpoints.ts +++ b/frontend/src/utils/endpoints.ts @@ -1,4 +1,4 @@ -import type {VideoMetadata, APIResponse, User} from "./types.ts"; +import type {VideoMetadata, APIResponse, User, Clip} from "./types.ts"; /** * Uploads a file to the backend. @@ -65,7 +65,9 @@ const editFile = async ( /** * Triggers file processing. */ -const processFile = async (uuid: string, setError: Function): Promise => { +const processFile = async ( + uuid: string, + setError: Function): Promise => { try { const response = await fetch(`/api/v1/process/${uuid}`); @@ -85,7 +87,8 @@ const processFile = async (uuid: string, setError: Function): Promise = /** * Fetches the processing progress percentage. */ -const getProgress = async (uuid: string): Promise => { +const getProgress = async ( + uuid: string): Promise => { try { const response = await fetch(`/api/v1/progress/${uuid}`); @@ -105,7 +108,8 @@ const getProgress = async (uuid: string): Promise => { /** * Fetches original metadata from the backend. */ -const getMetadata = async (uuid: string): Promise => { +const getMetadata = async ( + uuid: string): Promise => { try { const response = await fetch(`/api/v1/metadata/original/${uuid}`); @@ -143,11 +147,32 @@ const getUser = async (): Promise => { } } +const getClips = async (setError: Function): Promise< Clip[]> => { + try { + const response = await fetch('/api/v1/clips/', {credentials: "include",}); + + if (!response.ok) { + const errorResult: APIResponse = await response.json(); + setError(errorResult.message); + return []; + } + + const result: APIResponse = await response.json(); + return result.data; + + } catch (error: unknown) { + console.error('Error fetching clips:', error); + setError('Failed to fetch clips'); + return []; + } +} + export { uploadFile, editFile, processFile, getProgress, getMetadata, - getUser + getUser, + getClips }; \ No newline at end of file diff --git a/frontend/src/utils/types.ts b/frontend/src/utils/types.ts index c1af16b..b8feb56 100644 --- a/frontend/src/utils/types.ts +++ b/frontend/src/utils/types.ts @@ -21,8 +21,21 @@ type User = { profilePicture: string } +type Clip = { + title: string, + description: string, + duration: number, + thumbnailPath: string, + videoPath: string, + fps: number, + width: number, + height: number, + createdAt: string, +} + export type { APIResponse, VideoMetadata, - User + User, + Clip } \ No newline at end of file diff --git a/src/main/java/com/ddf/vodsystem/controllers/ClipController.java b/src/main/java/com/ddf/vodsystem/controllers/ClipController.java index 1910bda..3be57b9 100644 --- a/src/main/java/com/ddf/vodsystem/controllers/ClipController.java +++ b/src/main/java/com/ddf/vodsystem/controllers/ClipController.java @@ -4,7 +4,6 @@ import com.ddf.vodsystem.entities.APIResponse; import com.ddf.vodsystem.entities.Clip; import com.ddf.vodsystem.exceptions.NotAuthenticated; import com.ddf.vodsystem.services.ClipService; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.oauth2.core.user.OAuth2User;