feat : add group

This commit is contained in:
lukman
2024-08-02 14:59:21 +08:00
parent ad59566cdf
commit 31bc53ccf3
5 changed files with 15 additions and 4 deletions

View File

@@ -118,7 +118,7 @@ Content-Type: application/json
// USERS // USERS
### ###
GET http://localhost:3000/api/user/get?path=get-all-users&roleID=dev&villageID=121212&groupID=2&positionID=clz24bff70001w01in64dd9ea HTTP/1.1 GET http://localhost:3000/api/user/get?path=get-all-users&active=true HTTP/1.1
### ###
GET http://localhost:3000/api/user/get?path=get-one-users&userID=devAmalia HTTP/1.1 GET http://localhost:3000/api/user/get?path=get-one-users&userID=devAmalia HTTP/1.1

View File

@@ -12,6 +12,7 @@ export const API_ADDRESS = {
"apiCreateUser": "/api/user/post?path=create-users", "apiCreateUser": "/api/user/post?path=create-users",
"apiUpdateUser": "/api/user/post?path=update-users", "apiUpdateUser": "/api/user/post?path=update-users",
"apiDeleteUser": "/api/user/post?path=delete-users", "apiDeleteUser": "/api/user/post?path=delete-users",
"apiGetRoleUser": "/api/user/get?path=get-role-user",
// Announcement // Announcement
"apiGetAllAnnouncement": "/api/announcement/get?path=get-all-announcement", "apiGetAllAnnouncement": "/api/announcement/get?path=get-all-announcement",

View File

@@ -5,7 +5,7 @@ export async function listGroups(req: NextRequest): Promise<Response> {
try { try {
const searchParams = req.nextUrl.searchParams const searchParams = req.nextUrl.searchParams
const villaId = "121212" const villaId = "desa1"
const active = searchParams.get('active'); const active = searchParams.get('active');
const groups = await prisma.group.findMany({ const groups = await prisma.group.findMany({
where: { where: {

View File

@@ -4,7 +4,7 @@ import { revalidatePath } from "next/cache";
export async function createGroup(req: Request) { export async function createGroup(req: Request) {
try { try {
const data = await req.json(); const data = await req.json();
const villaId = "121212"; const villaId = "desa1";
if (!data || !data.name) { if (!data || !data.name) {
return Response.json( return Response.json(

View File

@@ -1,12 +1,22 @@
import { prisma } from "@/module/_global"; import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import _, { omit } from "lodash"; import _, { omit } from "lodash";
import { NextRequest } from "next/server"; import { NextRequest } from "next/server";
export async function getAllPosition(req: NextRequest) { export async function getAllPosition(req: NextRequest) {
try { try {
let grupFix
const searchParams = req.nextUrl.searchParams const searchParams = req.nextUrl.searchParams
const groupID = "3"; const groupID = searchParams.get('groupId');
const active = searchParams.get('active'); const active = searchParams.get('active');
const user = await funGetUserByCookies()
console.log(groupID)
// if(user.)
const positions = await prisma.position.findMany({ const positions = await prisma.position.findMany({
where: { where: {
idGroup: String(groupID), idGroup: String(groupID),