upd: api mobile
Deskripsi: - update mobile load member - update mobile api create member nb : blm bisa upload gambar No Issues
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { DIR, funDeleteFile, funUploadFile, prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import { createLogUser } from "@/module/user";
|
||||
import { createLogUserMobile } from "@/module/user";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import sharp from "sharp";
|
||||
@@ -78,12 +77,13 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
// DELETE / ACTIVE & NON ACTIVE MEMBER / USER
|
||||
export async function DELETE(request: Request, context: { params: { id: string } }) {
|
||||
try {
|
||||
const user = await funGetUserByCookies()
|
||||
if (user.id == undefined) {
|
||||
const { id } = context.params;
|
||||
const { isActive, user } = (await request.json());
|
||||
|
||||
if (user == "null" || user == undefined || user == "") {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
}
|
||||
const { id } = context.params;
|
||||
const { isActive } = (await request.json());
|
||||
|
||||
const data = await prisma.user.count({
|
||||
where: {
|
||||
id: id,
|
||||
@@ -114,13 +114,12 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
});
|
||||
|
||||
// create log user
|
||||
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate status anggota', table: 'user', data: id })
|
||||
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate status anggota', table: 'user', data: id, user: user })
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Berhasil mengupdate status anggota",
|
||||
data: result,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
@@ -135,10 +134,6 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
// UPDATE MEMBER
|
||||
export async function PUT(request: Request, context: { params: { id: string } }) {
|
||||
try {
|
||||
const user = await funGetUserByCookies()
|
||||
if (user.id == undefined) {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
}
|
||||
const { id } = context.params;
|
||||
|
||||
const body = await request.formData()
|
||||
@@ -152,9 +147,14 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
||||
gender,
|
||||
idGroup,
|
||||
idPosition,
|
||||
idUserRole
|
||||
idUserRole,
|
||||
user
|
||||
} = JSON.parse(data as string)
|
||||
|
||||
if (user == "null" || user == undefined || user == "") {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
}
|
||||
|
||||
const cekNIK = await prisma.user.count({
|
||||
where: {
|
||||
nik: nik,
|
||||
@@ -234,7 +234,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
||||
}
|
||||
|
||||
// create log user
|
||||
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate data anggota', table: 'user', data: user.id })
|
||||
const log = await createLogUserMobile({ act: 'UPDATE', desc: 'User mengupdate data anggota', table: 'user', data: id, user: user })
|
||||
|
||||
return Response.json(
|
||||
{ success: true, message: "Sukses update anggota" },
|
||||
|
||||
Reference in New Issue
Block a user