Skip to content

Commit

Permalink
chore: Update useState type in Page component to fix video state init…
Browse files Browse the repository at this point in the history
…ialization
  • Loading branch information
infinitel8p committed Aug 22, 2024
1 parent 330b5a4 commit 943d598
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
7 changes: 4 additions & 3 deletions server/src/app/archive/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useEffect, useState } from "react";

const Page = () => {
const [videos, setVideos] = useState([]);
const [videos, setVideos] = useState<string[]>([]);
const archiveUrl = `${window.location.protocol}//${window.location.hostname}:5005/archive`;

useEffect(() => {
Expand All @@ -19,7 +19,7 @@ const Page = () => {
fetchVideos();
}, []);

const handleDelete = (video) => {
const handleDelete = (video: any) => {
//! Implement delete functionality
console.log(`Delete video: ${video}`);
};
Expand All @@ -30,6 +30,7 @@ const Page = () => {
{videos.length > 0 ? (
videos.map((video, index) => {
const filename = video.split('/').pop();
if (!filename) return null;
const [datePart, timePart] = filename.match(/\d+/g); // Extract date and time from the filename
const date = `${datePart.slice(0, 4)}-${datePart.slice(4, 6)}-${datePart.slice(6, 8)}`;
const time = `${timePart.slice(0, 2)}:${timePart.slice(2, 4)}:${timePart.slice(4, 6)}`;
Expand All @@ -42,7 +43,7 @@ const Page = () => {
onLoadedMetadata={(e) => {
const target = e.target as HTMLVideoElement;
const duration = target.duration;
document.getElementById(`duration-${index}`).textContent = `Duration: ${Math.floor(duration / 60)}m ${Math.floor(duration % 60)}s`;
document.getElementById(`duration-${index}`)!.textContent = `Duration: ${Math.floor(duration / 60)}m ${Math.floor(duration % 60)}s`;
}}
>
<source
Expand Down
23 changes: 18 additions & 5 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -18,9 +22,18 @@
}
],
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}

0 comments on commit 943d598

Please sign in to comment.