Merge pull request #208 from bipproduction/amalia/06-september-24
upd: division
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
|
import { createLogUser } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import "moment/locale/id";
|
import "moment/locale/id";
|
||||||
@@ -195,6 +196,9 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUser({ act: 'DELETE', desc: 'User mengeluarkan anggota divisi', table: 'division', data: idDivision })
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
@@ -246,6 +250,9 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate status anggota divisi', table: 'division', data: idDivision })
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
@@ -300,6 +307,9 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
data: dataMember
|
data: dataMember
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUser({ act: 'CREATE', desc: 'User menambah anggota divisi', table: 'division', data: idDivision })
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil menambahkan anggota divisi" }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil menambahkan anggota divisi" }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
// GET MEMBER BY ID
|
|
||||||
|
|
||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
|
||||||
|
// GET MEMBER BY ID
|
||||||
export async function GET(request: Request, context: { params: { id: string } }) {
|
export async function GET(request: Request, context: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
const { id } = context.params;
|
const { id } = context.params;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
|
import { createLogUser } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
@@ -104,6 +105,9 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate data divisi', table: 'division', data: id })
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
|
import { createLogUser } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { revalidatePath, revalidateTag } from "next/cache";
|
import { revalidatePath, revalidateTag } from "next/cache";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
@@ -140,6 +141,9 @@ export async function POST(request: Request) {
|
|||||||
revalidatePath('/divisi', 'page')
|
revalidatePath('/divisi', 'page')
|
||||||
revalidateTag('divisi')
|
revalidateTag('divisi')
|
||||||
|
|
||||||
|
// create log user
|
||||||
|
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data divisi', table: 'division', data: data.id })
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil menambahkan divisi", data, }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil menambahkan divisi", data, }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export default function InformationDivision() {
|
|||||||
setName(res.data.division.name);
|
setName(res.data.division.name);
|
||||||
setDeskripsi(res.data.division.desc);
|
setDeskripsi(res.data.division.desc);
|
||||||
setMember(res.data.member)
|
setMember(res.data.member)
|
||||||
const cek = res.data.member.some((i: any) => i.id == login.id && i.isAdmin == true)
|
const cek = res.data.member.some((i: any) => i.idUser == login.id && i.isAdmin == true)
|
||||||
setAdmin(cek)
|
setAdmin(cek)
|
||||||
} else {
|
} else {
|
||||||
toast.error(res.message);
|
toast.error(res.message);
|
||||||
@@ -106,11 +106,14 @@ export default function InformationDivision() {
|
|||||||
<Box>
|
<Box>
|
||||||
<LayoutNavbarNew back={"/division/" + param.id} title={name}
|
<LayoutNavbarNew back={"/division/" + param.id} title={name}
|
||||||
menu={
|
menu={
|
||||||
|
((roleLogin.get() != 'user' && roleLogin.get() != 'coadmin') || isAdmin) ?
|
||||||
<ActionIcon variant="light" onClick={() => {
|
<ActionIcon variant="light" onClick={() => {
|
||||||
router.push('/division/edit/' + param.id)
|
router.push('/division/edit/' + param.id)
|
||||||
}} bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
}} bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||||
<LuClipboardEdit size={20} color='white' />
|
<LuClipboardEdit size={20} color='white' />
|
||||||
</ActionIcon>}
|
</ActionIcon>
|
||||||
|
: <></>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Box p={20}>
|
<Box p={20}>
|
||||||
<Box>
|
<Box>
|
||||||
@@ -195,7 +198,12 @@ export default function InformationDivision() {
|
|||||||
return (
|
return (
|
||||||
<Box key={i}>
|
<Box key={i}>
|
||||||
<Grid align='center' mt={10}
|
<Grid align='center' mt={10}
|
||||||
onClick={() => { onClickMember(v.id, (v.isAdmin) ? true : false), setChooseMemberName(v.name) }}
|
onClick={() => {
|
||||||
|
if ((roleLogin.get() != 'user' && roleLogin.get() != 'coadmin') || isAdmin) {
|
||||||
|
onClickMember(v.id, (v.isAdmin) ? true : false)
|
||||||
|
setChooseMemberName(v.name)
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Grid.Col span={9}>
|
<Grid.Col span={9}>
|
||||||
<Group>
|
<Group>
|
||||||
|
|||||||
Reference in New Issue
Block a user