fix: dashboard admin

Deskripsi:
- page list user dan list admin
- search list user dan list admin

No Issues
This commit is contained in:
amel
2024-05-23 16:36:48 +08:00
parent 759749f7df
commit ac432d1eb7
4 changed files with 334 additions and 27 deletions

View File

@@ -1,15 +1,38 @@
"use server"
import prisma from "@/app/lib/prisma"
import _, { ceil } from "lodash";
export default async function adminDeveloper_funGetListAllAdmin() {
const data = await prisma.user.findMany({
orderBy: {
updatedAt: "asc",
},
where: {
masterUserRoleId: "2",
},
});
return data;
export default async function adminDeveloper_funGetListAllAdmin({ search, page }: { search?: any, page: any }) {
const dataSkip = _.toNumber(page) * 9 - 9
const data = await prisma.user.findMany({
skip: dataSkip,
take: 9,
orderBy: {
updatedAt: "asc",
},
where: {
masterUserRoleId: "2",
username: {
contains: search,
mode: 'insensitive'
}
},
});
const nCount = await prisma.user.count({
where: {
masterUserRoleId: "2",
username: {
contains: search,
mode: 'insensitive'
}
}
})
const allData = {
data: data,
nPage: ceil(nCount / 9)
}
return allData;
}

View File

@@ -1,15 +1,39 @@
"use server";
import prisma from "@/app/lib/prisma";
import _, { ceil } from "lodash";
export default async function adminDeveloper_funGetListAllUser({ search, page }: { search?: any, page: any }) {
const dataSkip = _.toNumber(page) * 9 - 9
export default async function adminDeveloper_funGetListAllUser() {
const data = await prisma.user.findMany({
skip: dataSkip,
take: 9,
orderBy: {
updatedAt: "asc",
},
where: {
masterUserRoleId: "1",
username: {
contains: search,
mode: 'insensitive'
}
},
});
return data;
const nCount = await prisma.user.count({
where: {
masterUserRoleId: "1",
username: {
contains: search,
mode: 'insensitive'
}
}
})
const allData = {
data: data,
nPage: ceil(nCount / 9)
}
return allData;
}