upd: divisi
Deskripsi: - info divisi No Issues
This commit is contained in:
12
src/app/(application)/division/add-member/[id]/page.tsx
Normal file
12
src/app/(application)/division/add-member/[id]/page.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { CreateAnggotaDivision } from "@/module/division_new";
|
||||
import { Box } from "@mantine/core";
|
||||
|
||||
function Page({ params }: { params: { id: string } }) {
|
||||
return (
|
||||
<Box>
|
||||
<CreateAnggotaDivision />
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default Page;
|
||||
@@ -1,10 +0,0 @@
|
||||
import { ViewCreateAnggotaDivision } from "@/module/division_new";
|
||||
|
||||
|
||||
function Page() {
|
||||
return (
|
||||
<ViewCreateAnggotaDivision/>
|
||||
)
|
||||
}
|
||||
|
||||
export default Page;
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ViewInformationDivision } from "@/module/division_new";
|
||||
import { InformationDivision } from "@/module/division_new";
|
||||
import { Box } from "@mantine/core";
|
||||
|
||||
function Page() {
|
||||
function Page({ params }: { params: { id: string } }) {
|
||||
return (
|
||||
<ViewInformationDivision/>
|
||||
<Box>
|
||||
<InformationDivision />
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -154,4 +154,105 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
console.log(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// MENGELUARKAN ANGGOTA DARI DIVISI
|
||||
export async function DELETE(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 idDivision = context.params.id;
|
||||
const { id } = (await request.json());
|
||||
|
||||
const data = await prisma.division.count({
|
||||
where: {
|
||||
id: idDivision,
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (data == 0) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Hapus anggota divisi gagal, data tidak ditemukan",
|
||||
},
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
const update = await prisma.divisionMember.delete({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Anggota divisi berhasil dihapus",
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MENGGANTIS STATUS ADMIN DIVISI
|
||||
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 idDivision = context.params.id;
|
||||
const { id, isAdmin } = (await request.json());
|
||||
|
||||
const data = await prisma.division.count({
|
||||
where: {
|
||||
id: idDivision,
|
||||
isActive: true
|
||||
},
|
||||
});
|
||||
|
||||
if (data == 0) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Perubahan status admin gagal, data tidak ditemukan",
|
||||
},
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
const update = await prisma.divisionMember.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
isAdmin: !isAdmin
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Status admin berhasil diupdate",
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
// GET ONE DATA DIVISI :: UNTUK TAMPIL DATA DI HALAMAN EDIT
|
||||
// GET ONE DATA DIVISI :: UNTUK TAMPIL DATA DI HALAMAN EDIT DAN INFO
|
||||
export async function GET(request: Request, context: { params: { id: string } }) {
|
||||
try {
|
||||
const { id } = context.params;
|
||||
@@ -20,11 +21,43 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
return NextResponse.json( { success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan", }, { status: 404 } );
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan", }, { status: 404 });
|
||||
}
|
||||
|
||||
return NextResponse.json( { success: true, message: "Berhasil mendapatkan divisi", data, }, { status: 200 } );
|
||||
|
||||
const member = await prisma.divisionMember.findMany({
|
||||
where: {
|
||||
idDivision: String(id),
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isAdmin: true,
|
||||
isLeader: true,
|
||||
idUser: true,
|
||||
User: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
}
|
||||
},
|
||||
orderBy: {
|
||||
isAdmin: 'desc',
|
||||
}
|
||||
})
|
||||
|
||||
const fixMember = member.map((v: any) => ({
|
||||
..._.omit(v, ["User"]),
|
||||
name: v.User.name
|
||||
}))
|
||||
|
||||
const dataFix = {
|
||||
division: data,
|
||||
member: fixMember
|
||||
}
|
||||
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan divisi", data: dataFix, }, { status: 200 });
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
|
||||
@@ -7,7 +7,6 @@ import { NextResponse } from "next/server";
|
||||
// GET ALL MEMBER / USER
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
|
||||
let fixGroup
|
||||
const { searchParams } = new URL(request.url);
|
||||
const name = searchParams.get('search')
|
||||
@@ -23,6 +22,7 @@ export async function GET(request: Request) {
|
||||
fixGroup = idGroup
|
||||
}
|
||||
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
isActive: active == "true" ? true : false,
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
"use client"
|
||||
import { LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||
import { API_ADDRESS, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||
import LayoutModal from '@/module/_global/layout/layout_modal';
|
||||
import { funGetUserByCookies } from '@/module/auth';
|
||||
import { TypeUser } from '@/module/user';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
import { Avatar, Box, Button, Divider, Group, Stack, Text, TextInput } from '@mantine/core';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
import React, { useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { FaCheck } from 'react-icons/fa6';
|
||||
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
||||
import { globalMemberDivision } from '../lib/val_division';
|
||||
import { useShallowEffect } from '@mantine/hooks';
|
||||
import { funGetAllmember } from '@/module/user/member/lib/api_member';
|
||||
|
||||
const dataUser = [
|
||||
{
|
||||
@@ -43,27 +49,53 @@ const dataUser = [
|
||||
|
||||
export default function CreateAnggotaDivision() {
|
||||
const router = useRouter()
|
||||
const [selectedFiles, setSelectedFiles] = useState<Record<number, boolean>>({});
|
||||
const [selectedFiles, setSelectedFiles] = useState<any>([]);
|
||||
const [dataMember, setDataMember] = useState<TypeUser>([])
|
||||
const [isOpen, setOpen] = useState(false)
|
||||
const param = useParams<{ id: string }>()
|
||||
const member = useHookstate(globalMemberDivision)
|
||||
|
||||
const handleFileClick = (index: number) => {
|
||||
setSelectedFiles((prevSelectedFiles) => ({
|
||||
...prevSelectedFiles,
|
||||
[index]: !prevSelectedFiles[index],
|
||||
}));
|
||||
if (selectedFiles.some((i: any) => i.id == dataMember[index].id)) {
|
||||
setSelectedFiles(selectedFiles.filter((i: any) => i.id != dataMember[index].id))
|
||||
} else {
|
||||
setSelectedFiles([...selectedFiles, { idUser: dataMember[index].id, name: dataMember[index].name }])
|
||||
}
|
||||
};
|
||||
|
||||
function onTrue(val: boolean) {
|
||||
if (val) {
|
||||
toast.success("Sukses! Data tersimpan");
|
||||
toast.success("Sukses! Data tersimpan");
|
||||
}
|
||||
setOpen(false)
|
||||
router.push("/division/info/1")
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
console.log("masuk")
|
||||
const res = await funGetAllmember('?active=true&group=group1');
|
||||
const user = await funGetUserByCookies();
|
||||
|
||||
console.log(res)
|
||||
// if(res.success){
|
||||
// setDataMember(res.data.filter((i: any) => i.id != user.id))
|
||||
// }else{
|
||||
// toast.error(res.message)
|
||||
// }
|
||||
|
||||
// cek data member sebelumnya
|
||||
if (member.length > 0) {
|
||||
setSelectedFiles(JSON.parse(JSON.stringify(member.get())))
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadData()
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<LayoutNavbarNew back="/division/info/1" title="tambah anggota"
|
||||
<LayoutNavbarNew back="" title="tambah anggota"
|
||||
menu
|
||||
/>
|
||||
<Box p={20}>
|
||||
@@ -115,8 +147,8 @@ export default function CreateAnggotaDivision() {
|
||||
</Box>
|
||||
</Box>
|
||||
<LayoutModal opened={isOpen} onClose={() => setOpen(false)}
|
||||
description="Apakah Anda yakin ingin menambahkan data?"
|
||||
onYes={(val) => { onTrue(val) }} />
|
||||
description="Apakah Anda yakin ingin menambahkan data?"
|
||||
onYes={(val) => { onTrue(val) }} />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ import { IoIosArrowDropright } from "react-icons/io";
|
||||
import { globalMemberDivision } from "../lib/val_division";
|
||||
import toast from "react-hot-toast";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import CreateAdminDivision from "./create_admin_division";
|
||||
import CreateUsers from "./create_users";
|
||||
import { funGetAllGroup, IDataGroup } from "@/module/group";
|
||||
import NavbarAdminDivision from "./navbar_admin_division";
|
||||
import NavbarCreateUsers from "./navbar_create_users";
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
"use client"
|
||||
import { WARNA } from "@/module/_global";
|
||||
import { Box, Stack, SimpleGrid, Flex, Text } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { BsInfoCircle } from "react-icons/bs";
|
||||
import { FaPencil } from "react-icons/fa6";
|
||||
import { TbReportAnalytics } from "react-icons/tb";
|
||||
|
||||
export default function DrawerDetailDivision() {
|
||||
const param = useParams<{ id: string }>()
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Stack pt={10}>
|
||||
<SimpleGrid
|
||||
cols={{ base: 2, sm: 2, lg: 3 }}
|
||||
>
|
||||
<Flex onClick={() => router.push('/division/info/1')} justify={'center'} align={'center'} direction={'column'} >
|
||||
<Flex onClick={() => router.push('/division/info/' + param.id)} justify={'center'} align={'center'} direction={'column'} >
|
||||
<Box>
|
||||
<BsInfoCircle size={30} color={WARNA.biruTua} />
|
||||
</Box>
|
||||
@@ -23,7 +25,7 @@ export default function DrawerDetailDivision() {
|
||||
</Box>
|
||||
</Flex>
|
||||
<Flex onClick={() => {
|
||||
router.push('/division/report/1')
|
||||
router.push('/division/report/' + param.id)
|
||||
}} justify={'center'} align={'center'} direction={'column'} >
|
||||
<Box>
|
||||
<TbReportAnalytics size={30} color={WARNA.biruTua} />
|
||||
|
||||
@@ -1,63 +1,106 @@
|
||||
"use client"
|
||||
import { LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Avatar, Box, Button, Divider, Flex, Group, Modal, SimpleGrid, Text, Title } from '@mantine/core';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { LayoutDrawer, LayoutNavbarNew, SkeletonSingle, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Avatar, Box, Button, Divider, Flex, Group, Skeleton, Stack, Text } from '@mantine/core';
|
||||
import { useShallowEffect } from '@mantine/hooks';
|
||||
import { useParams, useRouter } from 'next/navigation';
|
||||
import React, { useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { AiOutlineUserAdd } from 'react-icons/ai';
|
||||
import { FaUserTie } from 'react-icons/fa6';
|
||||
import { HiUserAdd } from 'react-icons/hi';
|
||||
import { IoIosCloseCircle } from 'react-icons/io';
|
||||
import { LuClipboardEdit } from 'react-icons/lu';
|
||||
import { MdAccountCircle } from 'react-icons/md';
|
||||
import { funDeleteMemberDivision, funEditStatusAdminDivision, funGetDivisionById } from '../lib/api_division';
|
||||
import { IDataMemberDivision } from '../lib/type_division';
|
||||
import LayoutModal from '@/module/_global/layout/layout_modal';
|
||||
|
||||
const dataUser = [
|
||||
{
|
||||
id: 1,
|
||||
img: "https://i.pravatar.cc/1000?img=3",
|
||||
name: "Doni Setiawan",
|
||||
role: "Admin"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
img: "https://i.pravatar.cc/1000?img=10",
|
||||
name: "Ilham Udin",
|
||||
role: "Anggota"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
img: "https://i.pravatar.cc/1000?img=11",
|
||||
name: "Didin Anang",
|
||||
role: "Anggota"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
img: "https://i.pravatar.cc/1000?img=21",
|
||||
name: "Angga Saputra",
|
||||
role: "Anggota"
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
img: "https://i.pravatar.cc/1000?img=32",
|
||||
name: "Marcel Widianto",
|
||||
role: "Anggota"
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
img: "https://i.pravatar.cc/1000?img=37",
|
||||
name: "Bagas Nusantara",
|
||||
role: "Anggota"
|
||||
},
|
||||
];
|
||||
|
||||
export default function InformationDivision() {
|
||||
const router = useRouter()
|
||||
const [openDrawer, setDrawer] = useState(false)
|
||||
const param = useParams<{ id: string }>()
|
||||
const [name, setName] = useState('')
|
||||
const [deskripsi, setDeskripsi] = useState('')
|
||||
const [member, setMember] = useState<IDataMemberDivision[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [valChooseMember, setChooseMember] = useState("")
|
||||
const [valChooseMemberStatus, setChooseMemberStatus] = useState<boolean>(false)
|
||||
const [valChooseMemberName, setChooseMemberName] = useState("")
|
||||
const [isOpenModal, setOpenModal] = useState(false)
|
||||
|
||||
async function getOneData() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await funGetDivisionById(param.id);
|
||||
if (res.success) {
|
||||
setName(res.data.division.name);
|
||||
setDeskripsi(res.data.division.desc);
|
||||
setMember(res.data.member)
|
||||
} else {
|
||||
toast.error(res.message);
|
||||
}
|
||||
setLoading(false);
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan divisi, coba lagi nanti");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
getOneData();
|
||||
}, [param.id])
|
||||
|
||||
|
||||
async function onClickMember(id: string, status: boolean) {
|
||||
setChooseMember(id)
|
||||
setChooseMemberStatus(status)
|
||||
setDrawer(true)
|
||||
}
|
||||
|
||||
|
||||
async function deleteMember() {
|
||||
try {
|
||||
const res = await funDeleteMemberDivision(param.id, { id: valChooseMember })
|
||||
if (res.success) {
|
||||
toast.success(res.message)
|
||||
setDrawer(false)
|
||||
getOneData()
|
||||
} else {
|
||||
toast.error(res.message)
|
||||
}
|
||||
setOpenModal(false)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setOpenModal(false)
|
||||
toast.error("Gagal mendapatkan divisi, coba lagi nanti");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function editStatusAdmin() {
|
||||
try {
|
||||
const res = await funEditStatusAdminDivision(param.id, { id: valChooseMember, isAdmin: valChooseMemberStatus })
|
||||
if (res.success) {
|
||||
toast.success(res.message)
|
||||
getOneData()
|
||||
} else {
|
||||
toast.error(res.message)
|
||||
}
|
||||
setDrawer(false)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan divisi, coba lagi nanti");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<LayoutNavbarNew back="/division/1" title="divisi kerohanian"
|
||||
<LayoutNavbarNew back={""} title={name}
|
||||
menu={
|
||||
<ActionIcon variant="light" onClick={() => {
|
||||
router.push('/division/edit/1')
|
||||
router.push('/division/edit/' + param.id)
|
||||
}} bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||
<LuClipboardEdit size={20} color='white' />
|
||||
</ActionIcon>}
|
||||
@@ -69,7 +112,20 @@ export default function InformationDivision() {
|
||||
borderRadius: 10,
|
||||
border: `1px solid ${WARNA.borderBiruMuda}`,
|
||||
}}>
|
||||
<Text ta={"justify"}>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. </Text>
|
||||
{
|
||||
loading ?
|
||||
Array(3)
|
||||
.fill(null)
|
||||
.map((_, i) => (
|
||||
<Stack align="stretch" justify="center" key={i} mb={10}>
|
||||
<Skeleton height={10} radius="md" m={0} />
|
||||
</Stack>
|
||||
))
|
||||
:
|
||||
(deskripsi != null && deskripsi != undefined) ?
|
||||
<Text ta={"justify"}>{deskripsi}</Text>
|
||||
: <></>
|
||||
}
|
||||
</Box>
|
||||
</Box>
|
||||
<Box mt={20}>
|
||||
@@ -78,10 +134,10 @@ export default function InformationDivision() {
|
||||
border: `1px solid ${WARNA.borderBiruMuda}`,
|
||||
}}>
|
||||
<Box>
|
||||
<Text>20 Anggota</Text>
|
||||
<Text>{member.length} Anggota</Text>
|
||||
</Box>
|
||||
<Box mt={15}>
|
||||
<Group align='center' onClick={() => router.push('/division/create-anggota/1')}>
|
||||
<Group align='center' onClick={() => router.push('/division/add-member/' + param.id)}>
|
||||
<Avatar size="lg">
|
||||
<AiOutlineUserAdd size={30} color={WARNA.biruTua} />
|
||||
</Avatar>
|
||||
@@ -90,55 +146,74 @@ export default function InformationDivision() {
|
||||
</Box>
|
||||
<Box pt={10}>
|
||||
<Box mb={10}>
|
||||
{dataUser.map((v, i) => {
|
||||
return (
|
||||
<Box key={i}>
|
||||
<Flex
|
||||
justify={"space-between"}
|
||||
align={"center"}
|
||||
mt={10}
|
||||
onClick={() => setDrawer(true)}
|
||||
>
|
||||
<Group>
|
||||
<Avatar src={v.img} alt="it's me" size="lg" />
|
||||
<Box>
|
||||
<Text c={WARNA.biruTua} fw={"bold"}>
|
||||
{v.name}
|
||||
</Text>
|
||||
</Box>
|
||||
</Group>
|
||||
<Text c={WARNA.biruTua} fw={"bold"}>
|
||||
{v.role}
|
||||
</Text>
|
||||
</Flex>
|
||||
<Box mt={10}>
|
||||
<Divider size={"xs"} />
|
||||
{loading
|
||||
? Array(3)
|
||||
.fill(null)
|
||||
.map((_, i) => (
|
||||
<Box key={i}>
|
||||
<SkeletonSingle />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
))
|
||||
: member.map((v, i) => {
|
||||
return (
|
||||
<Box key={i}>
|
||||
<Flex
|
||||
justify={"space-between"}
|
||||
align={"center"}
|
||||
mt={10}
|
||||
onClick={() => { onClickMember(v.id, (v.isAdmin) ? true : false), setChooseMemberName(v.name) }}
|
||||
>
|
||||
<Group>
|
||||
<Avatar src={"v.img"} alt="it's me" size="lg" />
|
||||
<Box>
|
||||
<Text c={WARNA.biruTua} fw={"bold"}>
|
||||
{v.name}
|
||||
</Text>
|
||||
</Box>
|
||||
</Group>
|
||||
<Text c={WARNA.biruTua} fw={"bold"}>
|
||||
{(v.isAdmin) ? 'Admin' : 'Anggota'}
|
||||
</Text>
|
||||
</Flex>
|
||||
<Box mt={10}>
|
||||
<Divider size={"xs"} />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
<LayoutDrawer opened={openDrawer} onClose={() => setDrawer(false)} title="">
|
||||
<LayoutDrawer opened={openDrawer} onClose={() => setDrawer(false)} title={valChooseMemberName}>
|
||||
<Box>
|
||||
<Group align='center' mb={20} onClick={() => setDrawer(false)}>
|
||||
<Group align='center' mb={20} onClick={() => editStatusAdmin()}>
|
||||
<ActionIcon variant="light" size={60} aria-label="admin" radius="xl">
|
||||
<FaUserTie size={30} color={WARNA.biruTua} />
|
||||
</ActionIcon>
|
||||
<Text c={WARNA.biruTua}>Jadikan Admin</Text>
|
||||
<Text c={WARNA.biruTua}>{(valChooseMemberStatus == false) ? "Jadikan admin" : "Memberhentikan sebagai admin"}</Text>
|
||||
</Group>
|
||||
<Group align='center' onClick={() => setDrawer(false)}>
|
||||
<Group align='center' onClick={() => setOpenModal(true)}>
|
||||
<ActionIcon variant="light" size={60} aria-label="admin" radius="xl">
|
||||
<IoIosCloseCircle size={40} color={WARNA.biruTua} />
|
||||
</ActionIcon>
|
||||
<Text c={WARNA.biruTua}>Keluarkan dari Group</Text>
|
||||
<Text c={WARNA.biruTua}>Keluarkan dari divisi</Text>
|
||||
</Group>
|
||||
</Box>
|
||||
</LayoutDrawer>
|
||||
|
||||
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin mengeluarkan anggota?"
|
||||
onYes={(val) => {
|
||||
if (!val) {
|
||||
setOpenModal(false)
|
||||
} else {
|
||||
deleteMember()
|
||||
}
|
||||
}} />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function NavbarDetailDivision() {
|
||||
try {
|
||||
const res = await funGetDivisionById(param.id);
|
||||
if (res.success) {
|
||||
setName(res.data.name);
|
||||
setName(res.data.division.name);
|
||||
} else {
|
||||
toast.error(res.message);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IFormDivision, IFormMemberDivision, IFormFixDivision, IDataDivison } from './lib/type_division';
|
||||
import { IFormDivision, IFormMemberDivision, IFormFixDivision, IDataDivison, IDataMemberDivision } from './lib/type_division';
|
||||
import CreateUserDivisionCalender from "./_division_fitur/calender/components/create_user_division_calender";
|
||||
import UlangiEvent from "./_division_fitur/calender/components/ulangi_event";
|
||||
import UpdateUlangiEvent from "./_division_fitur/calender/components/update_calander/update_ulangi_event";
|
||||
@@ -21,10 +21,8 @@ import ViewUpdateProgressDivisionTask from "./_division_fitur/task/view/view_upd
|
||||
import { apiDivision } from "./api/api_division";
|
||||
import CreateAdminDivision from "./components/create_admin_division";
|
||||
import CreateUsers from "./components/create_users";
|
||||
import ViewCreateAnggotaDivision from "./view/view_create_anggota_division";
|
||||
import ViewCreateReport from "./view/view_create_report";
|
||||
import ViewEditDivision from "./view/view_edit_division";
|
||||
import ViewInformationDivision from "./view/view_Information_division";
|
||||
import ViewReportDivision from "./view/view_report_division";
|
||||
import ListDivision from './components/list_division';
|
||||
import CreateDivision from './components/create_division';
|
||||
@@ -34,6 +32,8 @@ import FeatureDetailDivision from './components/feature_detail_division';
|
||||
import ListTaskOnDetailDivision from './components/list_task';
|
||||
import ListDocumentOnDetailDivision from './components/list_document';
|
||||
import ListDiscussionOnDetailDivision from './components/list_discussion';
|
||||
import InformationDivision from './components/information_division';
|
||||
import CreateAnggotaDivision from './components/create_anggota_division';
|
||||
|
||||
export { CreateUsers };
|
||||
export { CreateAdminDivision };
|
||||
@@ -57,12 +57,10 @@ export { ViewDetailDiscussion };
|
||||
export { ViewEditDiscussion };
|
||||
export { ViewDocumentDivision };
|
||||
export { ViewReportDivision };
|
||||
export { ViewInformationDivision };
|
||||
export { ViewEditDivision };
|
||||
export { ViewCreateAnggotaDivision };
|
||||
export { apiDivision }
|
||||
export { apiDiscussion }
|
||||
export type { IFormDivision, IFormMemberDivision, IFormFixDivision, IDataDivison }
|
||||
export type { IFormDivision, IFormMemberDivision, IFormFixDivision, IDataDivison, IDataMemberDivision }
|
||||
export { ListDivision }
|
||||
export { CreateDivision }
|
||||
export { NavbarDetailDivision }
|
||||
@@ -71,3 +69,5 @@ export { FeatureDetailDivision }
|
||||
export { ListTaskOnDetailDivision }
|
||||
export { ListDocumentOnDetailDivision }
|
||||
export { ListDiscussionOnDetailDivision }
|
||||
export { InformationDivision }
|
||||
export { CreateAnggotaDivision }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IFormFixDivision } from "./type_division";
|
||||
import { IFormFixDivision, IFormMemberDivision } from "./type_division";
|
||||
|
||||
export const funGetAllDivision = async (path?: string) => {
|
||||
const response = await fetch(`/api/division${(path) ? path : ''}`, { next: { tags: ['division'] } });
|
||||
@@ -24,4 +24,27 @@ export const funCreateDivision = async (data: IFormFixDivision) => {
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
}
|
||||
|
||||
export const funDeleteMemberDivision = async (path: string, data: { id: string }) => {
|
||||
const response = await fetch(`/api/division/${path}/detail`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
|
||||
export const funEditStatusAdminDivision = async (path: string, data: { id: string, isAdmin: boolean }) => {
|
||||
const response = await fetch(`/api/division/${path}/detail`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
@@ -47,4 +47,12 @@ export interface IDataDiscussionOnDetailDivision {
|
||||
title: string,
|
||||
date: string,
|
||||
user: string
|
||||
}
|
||||
|
||||
export interface IDataMemberDivision {
|
||||
id: string,
|
||||
idUser: string,
|
||||
isAdmin: string,
|
||||
isLeader: string,
|
||||
name: string
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import React from 'react';
|
||||
import InformationDivision from '../components/information_division';
|
||||
import { Box } from '@mantine/core';
|
||||
|
||||
export default function ViewInformationDivision() {
|
||||
return (
|
||||
<Box>
|
||||
<InformationDivision/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Box } from '@mantine/core';
|
||||
import React from 'react';
|
||||
import CreateAnggotaDivision from '../components/create_anggota_division';
|
||||
|
||||
export default function ViewCreateAnggotaDivision() {
|
||||
return (
|
||||
<Box>
|
||||
<CreateAnggotaDivision/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user