# Developer
## feat - Memberi akses pada user menjadi admin ### No issue
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAdminDeveloper } from "@/app/lib/router_admin/router_admin_developer";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function adminDeveloper_funEditUserAksesById(
|
||||
userId: string,
|
||||
roleId: string
|
||||
) {
|
||||
const updt = await prisma.user.update({
|
||||
where: {
|
||||
id: userId,
|
||||
},
|
||||
data: {
|
||||
masterUserRoleId: roleId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Gagal Update Akses" };
|
||||
revalidatePath(RouterAdminDeveloper.main);
|
||||
return { status: 200, message: "Berhasil Update Akses" };
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
"use server"
|
||||
|
||||
import prisma from "@/app/lib/prisma"
|
||||
|
||||
export default async function adminDeveloper_funGetListAllAdmin() {
|
||||
const data = await prisma.user.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "asc",
|
||||
},
|
||||
where: {
|
||||
masterUserRoleId: "2",
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function adminDeveloper_funGetListAllUser() {
|
||||
const data = await prisma.user.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "asc",
|
||||
},
|
||||
where: {
|
||||
masterUserRoleId: "1",
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user