frontend: kanal ekleme formu
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>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
"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("/");
|
||||
}
|
||||
@@ -91,6 +91,43 @@ th {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.add-channel-form {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.add-channel-form input {
|
||||
flex: 1;
|
||||
min-width: 160px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
padding: 0.5rem 0.7rem;
|
||||
color: var(--text);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.add-channel-form input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.add-channel-form button {
|
||||
background: var(--accent);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 0.5rem 1rem;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.add-channel-form button:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.card-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prisma } from "@streamclipper/db";
|
||||
import { addChannel } from "./actions";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -17,10 +18,16 @@ export default async function DashboardPage() {
|
||||
return (
|
||||
<>
|
||||
<h1>Kanal Durumu</h1>
|
||||
|
||||
<form action={addChannel} className="card add-channel-form">
|
||||
<input name="name" placeholder="Kanal adı" required />
|
||||
<input name="youtubeHandle" placeholder="@handle" required />
|
||||
<input name="channelId" placeholder="channel_id (UC...)" required />
|
||||
<button type="submit">Kanal Ekle</button>
|
||||
</form>
|
||||
|
||||
{channels.length === 0 ? (
|
||||
<p className="empty">
|
||||
Henüz kanal eklenmedi. `channels` tablosuna bir kayıt ekleyin (Prisma Studio veya seed script).
|
||||
</p>
|
||||
<p className="empty">Henüz kanal eklenmedi.</p>
|
||||
) : (
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user