45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
// app/api/dashboard/admin/users/route.ts
|
|
import { NextRequest, NextResponse } from "next/server";
|
|
import { users } from "../mockData";
|
|
|
|
export async function GET() {
|
|
return NextResponse.json(users);
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const body = await request.json();
|
|
const { firstName, lastName, email, phone, role } = body;
|
|
|
|
// Add the new user to the existing users array (in-memory, not persistent)
|
|
const newUser = {
|
|
merchantId: 100987998,
|
|
name: "Jacob",
|
|
id: "382eed15-1e21-41fa-b1f3-0c1adb3af714",
|
|
username: "lsterence",
|
|
firstName,
|
|
lastName,
|
|
email,
|
|
phone,
|
|
jobTitle: "",
|
|
role,
|
|
enabled: true,
|
|
authorities: ["ROLE_IIN", "ROLE_FIRST_APPROVER", "ROLE_RULES_ADMIN"],
|
|
allowedMerchantIds: [100987998],
|
|
created: "2025-05-04T15:32:48.432Z",
|
|
disabledBy: null,
|
|
disabledDate: null,
|
|
disabledReason: null,
|
|
incidentNotes: false,
|
|
lastLogin: "",
|
|
lastMandatoryUpdated: "2025-05-04T15:32:48.332Z",
|
|
marketingNewsletter: false,
|
|
releaseNotes: false,
|
|
requiredActions: ["CONFIGURE_TOTP", "UPDATE_PASSWORD"],
|
|
twoFactorCondition: "required",
|
|
twoFactorCredentials: [],
|
|
};
|
|
users.push(newUser);
|
|
|
|
return NextResponse.json(users, { status: 201 });
|
|
}
|