Files
screenclipper/apps/frontend/app/users/page.tsx
T
ayrisdevandClaude Sonnet 5 5fef7460cf frontend: kullanıcı yönetimi sayfası
/users: kullanıcı listesi, ekleme formu, silme (kendi hesabını veya
son kalan tek kullanıcıyı silmeye izin verilmiyor). Nav'a link eklendi.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-01 12:28:19 +03:00

67 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { prisma } from "@streamclipper/db";
import { getSession } from "../../lib/auth";
import { addUser, deleteUser } from "./actions";
import { DeleteButton } from "../components/DeleteButton";
export const dynamic = "force-dynamic";
const fieldStyle = {
background: "var(--bg)",
border: "1px solid var(--border)",
borderRadius: "6px",
padding: "0.5rem 0.7rem",
color: "var(--text)",
fontSize: "0.9rem",
};
export default async function UsersPage() {
const [users, session] = await Promise.all([
prisma.user.findMany({ orderBy: { createdAt: "asc" } }),
getSession(),
]);
return (
<>
<h1>Kullanıcılar</h1>
<form
action={addUser}
className="card add-channel-form"
style={{ marginBottom: "1.5rem" }}
>
<input name="username" placeholder="Kullanıcı adı" required style={fieldStyle} />
<input name="password" type="password" placeholder="Şifre (en az 8 karakter)" required minLength={8} style={fieldStyle} />
<button type="submit">Kullanıcı Ekle</button>
</form>
<table>
<thead>
<tr>
<th>Kullanıcı Adı</th>
<th>Oluşturulma</th>
<th></th>
</tr>
</thead>
<tbody>
{users.map((u) => (
<tr key={u.id}>
<td>
{u.username}
{u.id === session?.sub && <span className="badge muted" style={{ marginLeft: "0.5rem" }}>sen</span>}
</td>
<td className="mono">{u.createdAt.toLocaleString("tr-TR")}</td>
<td>
{u.id !== session?.sub && users.length > 1 && (
<form action={deleteUser.bind(null, u.id)}>
<DeleteButton confirmText={`${u.username} kullanıcısını silmek istediğine emin misin?`} />
</form>
)}
</td>
</tr>
))}
</tbody>
</table>
</>
);
}