- Login copy describes the event CRM instead of orders and payouts.
- Role dialog has no parent field; the role routes require a trimmed name and forward only {name}.
- New-user banner says a temporary password was emailed; TEMP_PASSWORD_NOT_SENT shows a message and a link back to users.
- Username is read-only when editing.
- Password hint and an 8-character minimum match the backend admin password rules.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { callMobileApi } from "@/app/lib/server/mobileApi";
|
|
import { getToken } from "@/app/lib/server/session";
|
|
import { errorResponse, unauthorized, badRequest } from "@/app/lib/server/apiRoute";
|
|
import type { AdminRoleEntity } from "@/app/lib/types";
|
|
|
|
export async function GET(_req: NextRequest) {
|
|
const token = await getToken();
|
|
if (!token) return unauthorized();
|
|
const result = await callMobileApi<AdminRoleEntity[]>("/api/admin/roles", { token });
|
|
if (!result.ok) return errorResponse(result);
|
|
return NextResponse.json(result.data);
|
|
}
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const token = await getToken();
|
|
if (!token) return unauthorized();
|
|
const body = await req.json().catch(() => ({}));
|
|
// The backend takes only {name}; new roles are always filed under the super admin.
|
|
const name = (body as Partial<AdminRoleEntity>).name?.trim();
|
|
if (!name) {
|
|
return badRequest("Role name is required.");
|
|
}
|
|
const result = await callMobileApi<AdminRoleEntity>("/api/admin/roles", { method: "POST", body: { name }, token });
|
|
if (!result.ok) return errorResponse(result);
|
|
return NextResponse.json(result.data);
|
|
}
|