jbilcke-hf HF staff commited on
Commit
e411e71
β€’
1 Parent(s): 2f34958

ready for public release

Browse files
next.config.js CHANGED
@@ -5,18 +5,6 @@ const nextConfig = {
5
  experimental: {
6
  serverActions: true,
7
  },
8
-
9
- /*
10
- async redirects() {
11
- return [
12
- {
13
- source: '/api/download/:id*',
14
- destination: `${process.env.VC_VIDEOCHAIN_API_URL}/download/:id*`,
15
- permanent: true,
16
- },
17
- ]
18
- },
19
- */
20
  }
21
 
22
  module.exports = nextConfig
 
5
  experimental: {
6
  serverActions: true,
7
  },
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
 
10
  module.exports = nextConfig
src/components/business/videos/change-status-button.tsx ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client"
2
+
3
+ import { ReactNode, useTransition } from "react"
4
+
5
+ import { Video, VideoStatus } from "@/app/types"
6
+ import { setVideoStatus } from "@/server"
7
+
8
+ export function ChangeStatusButton({ video, children, status }: { video: Video; children: ReactNode; status: VideoStatus }) {
9
+ let [isPending, startTransition] = useTransition()
10
+
11
+ return (
12
+ <div
13
+ className="hover:underline cursor-pointer"
14
+ onClick={() => {
15
+ startTransition(async () => {
16
+ await setVideoStatus(video.ownerId, video.id, status)
17
+ })
18
+ }}>{children}</div>
19
+ )
20
+ }
src/components/business/videos/columns.tsx CHANGED
@@ -4,11 +4,10 @@ import { ColumnDef } from "@tanstack/react-table"
4
  import { Checkbox } from "@/components/ui/checkbox"
5
 
6
  import { DataTableColumnHeader } from "./column-header"
7
- import { VideoActions } from "./video-actions"
8
 
9
  import { Video } from "@/app/types"
10
- import { deleteVideo } from "@/server"
11
  import { triggerDownload } from "@/lib/triggerDownload"
 
12
 
13
  export const columns: ColumnDef<Video>[] = [
14
  {
@@ -83,7 +82,7 @@ export const columns: ColumnDef<Video>[] = [
83
  enableHiding: false,
84
  },
85
  {
86
- id: "save",
87
  header: ({ column }) => null,
88
  cell: ({ row: { original } }) => {
89
  const scene = JSON.stringify({
@@ -113,9 +112,8 @@ export const columns: ColumnDef<Video>[] = [
113
  {
114
  id: "delete",
115
  header: ({ column }) => null, // no header
116
- cell: ({ row: { original } }) => <div
117
- className="hover:underline cursor-pointer"
118
- onClick={() => { deleteVideo(original.ownerId, original.id) }}>Delete</div>,
119
  enableSorting: false,
120
  enableHiding: false,
121
  },
 
4
  import { Checkbox } from "@/components/ui/checkbox"
5
 
6
  import { DataTableColumnHeader } from "./column-header"
 
7
 
8
  import { Video } from "@/app/types"
 
9
  import { triggerDownload } from "@/lib/triggerDownload"
10
+ import { ChangeStatusButton } from "./change-status-button"
11
 
12
  export const columns: ColumnDef<Video>[] = [
13
  {
 
82
  enableHiding: false,
83
  },
84
  {
85
+ id: "scene",
86
  header: ({ column }) => null,
87
  cell: ({ row: { original } }) => {
88
  const scene = JSON.stringify({
 
112
  {
113
  id: "delete",
114
  header: ({ column }) => null, // no header
115
+ cell: ({ row: { original } }) =>
116
+ <ChangeStatusButton video={original} status="delete">Delete</ChangeStatusButton>,
 
117
  enableSorting: false,
118
  enableHiding: false,
119
  },
src/components/business/videos/video-table.tsx CHANGED
@@ -90,7 +90,7 @@ export function VideosQueue({
90
  {table.getRowModel().rows?.length ? (
91
  table.getRowModel().rows.map((row) => (
92
  <TableRow
93
- key={row.id}
94
  data-state={row.getIsSelected() && "selected"}
95
  >
96
  {row.getVisibleCells().map((cell) => (
 
90
  {table.getRowModel().rows?.length ? (
91
  table.getRowModel().rows.map((row) => (
92
  <TableRow
93
+ key={row.original.id}
94
  data-state={row.getIsSelected() && "selected"}
95
  >
96
  {row.getVisibleCells().map((cell) => (
src/server/index.ts CHANGED
@@ -34,12 +34,13 @@ export const setVideoStatus = async (ownerId: string, videoId: string, status: V
34
  return task
35
  }
36
 
 
37
  export const deleteVideo = async (ownerId: string, videoId: string) => {
38
- const task = await DELETE<GenericAPIResponse>(`${ownerId}/${videoId}`, { success: true })
39
-
40
  return task
41
  }
42
 
 
43
  /*
44
  export async function deleteVideos(ownerId: string, videoIds: string[]) {
45
  const task = await DELETE<GenericAPIResponse>(ownerAndVideoId, { success: true })
@@ -49,6 +50,7 @@ export async function deleteVideos(ownerId: string, videoIds: string[]) {
49
  */
50
 
51
  export const createNewVideo = async (ownerId: string, taskRequest: VideoAPIRequest) => {
 
52
  const task = await POST<VideoAPIRequest, Video>(
53
  ownerId,
54
  taskRequest,
 
34
  return task
35
  }
36
 
37
+ /*
38
  export const deleteVideo = async (ownerId: string, videoId: string) => {
39
+ const task = await DELETE<GenericAPIResponse>(`${ownerId}/${videoId}`, { success: false })
 
40
  return task
41
  }
42
 
43
+ */
44
  /*
45
  export async function deleteVideos(ownerId: string, videoIds: string[]) {
46
  const task = await DELETE<GenericAPIResponse>(ownerAndVideoId, { success: true })
 
50
  */
51
 
52
  export const createNewVideo = async (ownerId: string, taskRequest: VideoAPIRequest) => {
53
+ console.log("create new video")
54
  const task = await POST<VideoAPIRequest, Video>(
55
  ownerId,
56
  taskRequest,