-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender-button.tsx
More file actions
35 lines (27 loc) · 1.05 KB
/
render-button.tsx
File metadata and controls
35 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use client';
import { useVideoStoryStore } from '@/store/useVideoStoryStore';
import { useState } from 'react';
import { Button } from './ui/button';
export function RenderButton() {
const [isRendering, setIsRendering] = useState(false);
const getRenderData = useVideoStoryStore(state => state.getRenderData);
const handleRender = async () => {
setIsRendering(true);
// get plain json from zustand
const renderData = getRenderData();
// send to /api/render-video
const response = await fetch('/api/render-video', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(renderData) // <-- this is plain json data no zustand
});
const result = await response.json();
console.log('Video rendered:', result.videoPath);
setIsRendering(false);
};
return (
<Button onClick={handleRender} disabled={isRendering}>
{isRendering ? 'Rendering...' : 'Generate Final Video'}
</Button>
);
}