Dashboard'a name/youtubeHandle/channelId alanlarıyla bir server action formu eklendi. Polling ve /status için channel_id gerçek bir YouTube UC... kimliği olmalı. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
21 lines
617 B
TypeScript
21 lines
617 B
TypeScript
"use server";
|
||
|
||
import { prisma } from "@streamclipper/db";
|
||
import { revalidatePath } from "next/cache";
|
||
|
||
export async function addChannel(formData: FormData) {
|
||
const name = String(formData.get("name") ?? "").trim();
|
||
const youtubeHandle = String(formData.get("youtubeHandle") ?? "").trim();
|
||
const channelId = String(formData.get("channelId") ?? "").trim();
|
||
|
||
if (!name || !youtubeHandle || !channelId) {
|
||
throw new Error("Kanal adı, handle ve channel_id alanları zorunlu.");
|
||
}
|
||
|
||
await prisma.channel.create({
|
||
data: { name, youtubeHandle, channelId, isActive: true },
|
||
});
|
||
|
||
revalidatePath("/");
|
||
}
|