upd: apaa aja aku lupa
This commit is contained in:
@@ -3,9 +3,9 @@ import React from 'react';
|
|||||||
|
|
||||||
function Page({ searchParams }: { searchParams: { page: string } }) {
|
function Page({ searchParams }: { searchParams: { page: string } }) {
|
||||||
if (searchParams.page == "anggota")
|
if (searchParams.page == "anggota")
|
||||||
return <CreateUsers />
|
return <CreateUsers grup=''/>
|
||||||
if (searchParams.page == "pilih-admin")
|
// if (searchParams.page == "pilih-admin")
|
||||||
return <CreateAdminDivision />
|
// return <CreateAdminDivision />
|
||||||
return (
|
return (
|
||||||
<ViewCreateDivision/>
|
<ViewCreateDivision/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -35,5 +35,6 @@ export const API_ADDRESS = {
|
|||||||
"apiDeletePosition": "/api/position/post?path=delete-position",
|
"apiDeletePosition": "/api/position/post?path=delete-position",
|
||||||
|
|
||||||
|
|
||||||
|
// Division
|
||||||
|
"apiGetAllDivision": "/api/division/get?path=get-all-division",
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ import { WARNA } from '../fun/WARNA';
|
|||||||
import LayoutIconBack from './layout_icon_back';
|
import LayoutIconBack from './layout_icon_back';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
export const LayoutNavbarNew = ({ back, title, menu }: { back: string, title: string, menu: React.ReactNode }) => {
|
export const LayoutNavbarNew = ({ back, title, menu }: { back?: string, title: string, menu: React.ReactNode }) => {
|
||||||
return (
|
return (
|
||||||
<Box pt={25} pl={20} pr={20} m={0} pos={'sticky'} top={0} pb={25} bg={WARNA.biruTua}
|
<Box pt={25} pl={20} pr={20} m={0} pos={'sticky'} top={0} pb={25} bg={WARNA.biruTua}
|
||||||
style={{
|
style={{
|
||||||
@@ -17,7 +17,9 @@ export const LayoutNavbarNew = ({ back, title, menu }: { back: string, title: st
|
|||||||
>
|
>
|
||||||
<Grid justify='center' align='center'>
|
<Grid justify='center' align='center'>
|
||||||
<Grid.Col span="auto">
|
<Grid.Col span="auto">
|
||||||
<LayoutIconBack back={back} />
|
{
|
||||||
|
back!=undefined && (<LayoutIconBack back={back} />)
|
||||||
|
}
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={8}>
|
<Grid.Col span={8}>
|
||||||
<Title c={WARNA.bgWhite} ta={'center'} order={5}>{_.startCase(title)}</Title>
|
<Title c={WARNA.bgWhite} ta={'center'} order={5}>{_.startCase(title)}</Title>
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ export default async function funGetUserByCookies() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { id: user?.id, name: user?.name, idVillage: user?.idVillage };
|
return { id: user?.id, idUserRole: user?.idUserRole, name: user?.name, idVillage: user?.idVillage, idGroup: user?.idGroup, idPosition: user?.idPosition };
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,27 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
import { NextRequest } from "next/server";
|
import { NextRequest } from "next/server";
|
||||||
|
|
||||||
export default async function getAllDivision(req: NextRequest) {
|
export default async function getAllDivision(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
|
let grup
|
||||||
|
const user = await funGetUserByCookies()
|
||||||
const searchParams = req.nextUrl.searchParams
|
const searchParams = req.nextUrl.searchParams
|
||||||
const groupID = searchParams.get('groupID');
|
let groupID = searchParams.get('groupID');
|
||||||
|
if (groupID == null || groupID == undefined) {
|
||||||
|
grup = user.idGroup
|
||||||
|
} else {
|
||||||
|
grup = groupID
|
||||||
|
}
|
||||||
|
|
||||||
const division = await prisma.division.findMany({
|
const division = await prisma.division.findMany({
|
||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idGroup: String(groupID)
|
idGroup: grup
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return Response.json(division);
|
return Response.json(division);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import NavbarAdminDivision from './ui/navbar_admin_division';
|
import NavbarAdminDivision from './ui/navbar_admin_division';
|
||||||
|
|
||||||
export default function CreateAdminDivision() {
|
export default function CreateAdminDivision({ data }: { data: any }) {
|
||||||
return (
|
return (
|
||||||
<NavbarAdminDivision />
|
<NavbarAdminDivision />
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { LayoutNavbarNew, WARNA } from "@/module/_global";
|
import { API_ADDRESS, LayoutNavbarNew, WARNA } from "@/module/_global";
|
||||||
|
import { TypeGroup } from "@/module/group";
|
||||||
|
import { useHookstate } from "@hookstate/core";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Box,
|
Box,
|
||||||
@@ -12,65 +14,108 @@ import {
|
|||||||
Textarea,
|
Textarea,
|
||||||
TextInput,
|
TextInput,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { IoIosArrowDropright } from "react-icons/io";
|
import { IoIosArrowDropright } from "react-icons/io";
|
||||||
const dataUser = [
|
import { globalMemberDivision } from "../lib/val_division";
|
||||||
{
|
import toast from "react-hot-toast";
|
||||||
id: 1,
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
img: "https://i.pravatar.cc/1000?img=3",
|
import CreateAdminDivision from "./create_admin_division";
|
||||||
name: "Doni Setiawan",
|
import CreateUsers from "./create_users";
|
||||||
},
|
import NavbarCreateUsers from "./ui/navbar_create_users";
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
img: "https://i.pravatar.cc/1000?img=10",
|
|
||||||
name: "Ilham Udin",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
img: "https://i.pravatar.cc/1000?img=11",
|
|
||||||
name: "Didin Anang",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
img: "https://i.pravatar.cc/1000?img=21",
|
|
||||||
name: "Angga Saputra",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 5,
|
|
||||||
img: "https://i.pravatar.cc/1000?img=32",
|
|
||||||
name: "Marcel Widianto",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 6,
|
|
||||||
img: "https://i.pravatar.cc/1000?img=37",
|
|
||||||
name: "Bagas Nusantara",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function CreateDivision() {
|
export default function CreateDivision() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const [dataGroup, setDataGroup] = useState<TypeGroup>();
|
||||||
|
const [roleUser, setRoleUser] = useState<any>("")
|
||||||
|
const [isChooseAnggota, setChooseAnggota] = useState(false)
|
||||||
|
const [isChooseAdmin, setChooseAdmin] = useState(false)
|
||||||
|
const member = useHookstate(globalMemberDivision)
|
||||||
|
const [body, setBody] = useState<any>({
|
||||||
|
idGroup: "",
|
||||||
|
name: "",
|
||||||
|
desc: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadData() {
|
||||||
|
const loadGroup = await fetch(API_ADDRESS.apiGetAllGroup + '&active=true');
|
||||||
|
const dataGroup = await loadGroup.json();
|
||||||
|
setDataGroup(dataGroup);
|
||||||
|
|
||||||
|
const loadUser = await funGetUserByCookies();
|
||||||
|
setRoleUser(loadUser.idUserRole)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit() {
|
||||||
|
if (roleUser == "supadmin" && (body.idGroup == "" || body.idGroup == null)) {
|
||||||
|
return toast.error("Error! grup harus diisi")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.name == "") {
|
||||||
|
return toast.error("Error! nama divisi harus diisi")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (member.length == 0) {
|
||||||
|
return toast.error("Error! belum ada anggota yang terdaftar")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setChooseAdmin(true)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onToChooseAnggota() {
|
||||||
|
if (roleUser == "supadmin" && body.idGroup == "")
|
||||||
|
return toast.error("Error! grup harus diisi")
|
||||||
|
setChooseAnggota(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
loadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (isChooseAdmin) return <CreateAdminDivision data={body} />
|
||||||
|
|
||||||
|
if (isChooseAnggota) return <NavbarCreateUsers grup={body.idGroup} />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<LayoutNavbarNew back="/division" title="Tambah Divisi" menu />
|
<LayoutNavbarNew back="/division" title="Tambah Divisi" menu />
|
||||||
<Box p={20}>
|
<Box p={20}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Select
|
{
|
||||||
placeholder="Grup"
|
(roleUser == "supadmin") && (
|
||||||
label="Grup"
|
<Select
|
||||||
size="md"
|
placeholder="Grup"
|
||||||
required
|
label="Grup"
|
||||||
radius={40}
|
size="md"
|
||||||
/>
|
required
|
||||||
|
radius={40}
|
||||||
|
data={dataGroup?.map((pro: any) => ({
|
||||||
|
value: String(pro.id),
|
||||||
|
label: pro.name
|
||||||
|
}))}
|
||||||
|
onChange={(val) => {
|
||||||
|
setBody({ ...body, idGroup: val })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder="Judul"
|
placeholder="Nama Divisi"
|
||||||
label="Judul"
|
label="Nama Divisi"
|
||||||
size="md"
|
size="md"
|
||||||
required
|
required
|
||||||
radius={40}
|
radius={40}
|
||||||
|
onChange={(val) => { setBody({ ...body, name: val.target.value }) }}
|
||||||
/>
|
/>
|
||||||
<Textarea placeholder="Deskripsi" label="Deskripsi" radius={10} />
|
<Textarea size="md" placeholder="Deskripsi" label="Deskripsi" radius={10} onChange={(val) => { setBody({ ...body, desc: val }) }} />
|
||||||
<Box onClick={() => router.push("/division/create?page=anggota")}>
|
<Box onClick={() => { onToChooseAnggota() }}>
|
||||||
<Group
|
<Group
|
||||||
justify="space-between"
|
justify="space-between"
|
||||||
p={10}
|
p={10}
|
||||||
@@ -86,7 +131,7 @@ export default function CreateDivision() {
|
|||||||
<Box pt={20}>
|
<Box pt={20}>
|
||||||
<Group justify="space-between">
|
<Group justify="space-between">
|
||||||
<Text c={WARNA.biruTua}>Anggota Terpilih</Text>
|
<Text c={WARNA.biruTua}>Anggota Terpilih</Text>
|
||||||
<Text c={WARNA.biruTua}>Total 10 Anggota</Text>
|
<Text c={WARNA.biruTua}>Total {member.length} Anggota</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Box pt={10}>
|
<Box pt={10}>
|
||||||
<Box mb={20}>
|
<Box mb={20}>
|
||||||
@@ -98,7 +143,9 @@ export default function CreateDivision() {
|
|||||||
px={20}
|
px={20}
|
||||||
py={10}
|
py={10}
|
||||||
>
|
>
|
||||||
{dataUser.map((v, i) => {
|
{(member.length === 0) ? (
|
||||||
|
<Text c="dimmed" ta={"center"} fs={"italic"}>Belum ada anggota</Text>
|
||||||
|
) : member.get().map((v: any, i: any) => {
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
justify={"space-between"}
|
justify={"space-between"}
|
||||||
@@ -131,7 +178,10 @@ export default function CreateDivision() {
|
|||||||
size="lg"
|
size="lg"
|
||||||
radius={30}
|
radius={30}
|
||||||
fullWidth
|
fullWidth
|
||||||
onClick={() => router.push("/division/create?page=pilih-admin")}
|
onClick={() => {
|
||||||
|
onSubmit()
|
||||||
|
// router.push("/division/create?page=pilih-admin")
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import NavbarCreateUsers from './ui/navbar_create_users';
|
import NavbarCreateUsers from './ui/navbar_create_users';
|
||||||
|
|
||||||
export default function CreateUsers() {
|
export default function CreateUsers({ grup }: { grup: string }) {
|
||||||
return (
|
return (
|
||||||
<NavbarCreateUsers/>
|
<NavbarCreateUsers grup={grup} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { LayoutNavbarNew, WARNA } from '@/module/_global';
|
import { API_ADDRESS, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||||
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { Avatar, Box, Button, Center, Input, SimpleGrid, Stack, Text, TextInput } from '@mantine/core';
|
import { Avatar, Box, Button, Center, Input, SimpleGrid, Stack, Text, TextInput } from '@mantine/core';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { BsFiletypeCsv } from 'react-icons/bs';
|
|
||||||
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
||||||
|
import { globalMemberDivision } from '../../lib/val_division';
|
||||||
|
|
||||||
const dataUser = [
|
const dataUser = [
|
||||||
{
|
{
|
||||||
@@ -40,9 +42,10 @@ const dataUser = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
export default function NavbarCreateUsers() {
|
export default function NavbarCreateUsers({ grup }: { grup?: string }) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [selectedFiles, setSelectedFiles] = useState<Record<number, boolean>>({});
|
const [selectedFiles, setSelectedFiles] = useState<Record<number, boolean>>({});
|
||||||
|
const member = useHookstate(globalMemberDivision)
|
||||||
|
|
||||||
const handleFileClick = (index: number) => {
|
const handleFileClick = (index: number) => {
|
||||||
setSelectedFiles((prevSelectedFiles) => ({
|
setSelectedFiles((prevSelectedFiles) => ({
|
||||||
@@ -51,9 +54,17 @@ export default function NavbarCreateUsers() {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function loadData() {
|
||||||
|
const loadMember = await fetch(API_ADDRESS.apiGetAllUser + '&active=true&idGroup=' + grup);
|
||||||
|
}
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<LayoutNavbarNew back="/division/create" title="Pilih Anggota" menu />
|
<LayoutNavbarNew title="Pilih Anggota" menu />
|
||||||
<Box p={20}>
|
<Box p={20}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global';
|
import { API_ADDRESS, LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||||
import { ActionIcon, Avatar, Box, Card, Center, Divider, Flex, Grid, Group, Text, TextInput, Title } from '@mantine/core';
|
import { ActionIcon, Avatar, Box, Card, Center, Divider, Flex, Grid, Group, Text, TextInput, Title } from '@mantine/core';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
@@ -7,49 +7,39 @@ import { HiMenu } from 'react-icons/hi';
|
|||||||
import { HiMagnifyingGlass, HiMiniPresentationChartBar, HiMiniUserGroup, HiOutlineListBullet, HiSquares2X2 } from 'react-icons/hi2';
|
import { HiMagnifyingGlass, HiMiniPresentationChartBar, HiMiniUserGroup, HiOutlineListBullet, HiSquares2X2 } from 'react-icons/hi2';
|
||||||
import { MdAccountCircle } from 'react-icons/md';
|
import { MdAccountCircle } from 'react-icons/md';
|
||||||
import DrawerDivision from './drawer_division';
|
import DrawerDivision from './drawer_division';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
|
|
||||||
const dataDivisi = [
|
type TypeDivision = {
|
||||||
{
|
id: string
|
||||||
id: 1,
|
name: string
|
||||||
title: 'DIVISI 1',
|
idGroup: string
|
||||||
description: 'Tempat berkumpul semua anggota / staff perbekal darmasaba',
|
idVillage: string
|
||||||
},
|
desc: string
|
||||||
{
|
isActive: boolean
|
||||||
id: 2,
|
}[]
|
||||||
title: 'DIVISI 2',
|
|
||||||
description: 'Tempat berkumpul semua anggota / staff perbekal darmasaba',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
title: 'DIVISI 3',
|
|
||||||
description: 'Tempat berkumpul semua anggota / staff perbekal darmasaba',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
title: 'DIVISI 4',
|
|
||||||
description: 'Tempat berkumpul semua anggota / staff perbekal darmasaba',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 5,
|
|
||||||
title: 'DIVISI5',
|
|
||||||
description: 'Tempat berkumpul semua anggota / staff perbekal darmasaba',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 6,
|
|
||||||
title: 'DIVISI 6',
|
|
||||||
description: 'Tempat berkumpul semua anggota / staff perbekal darmasaba',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export default function NavbarDivision() {
|
export default function NavbarDivision() {
|
||||||
const [isList, setIsList] = useState(false)
|
const [isList, setIsList] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [openDrawer, setOpenDrawer] = useState(false)
|
const [openDrawer, setOpenDrawer] = useState(false)
|
||||||
|
const [data, setData] = useState<TypeDivision>()
|
||||||
|
const [jumlah, setJumlah] = useState(0)
|
||||||
|
|
||||||
const handleList = () => {
|
const handleList = () => {
|
||||||
setIsList(!isList)
|
setIsList(!isList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadData() {
|
||||||
|
const response = await fetch(API_ADDRESS.apiGetAllDivision)
|
||||||
|
const data = await response.json()
|
||||||
|
setData(data)
|
||||||
|
setJumlah(data.length)
|
||||||
|
}
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
loadData()
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<LayoutNavbarNew back='/home' title='Divisi'
|
<LayoutNavbarNew back='/home' title='Divisi'
|
||||||
@@ -87,13 +77,13 @@ export default function NavbarDivision() {
|
|||||||
<Box bg={WARNA.biruTua} p={10} style={{ borderRadius: 10 }}>
|
<Box bg={WARNA.biruTua} p={10} style={{ borderRadius: 10 }}>
|
||||||
<Text fw={'bold'} c={'white'}>Total Divisi</Text>
|
<Text fw={'bold'} c={'white'}>Total Divisi</Text>
|
||||||
<Flex justify={'center'} align={'center'} h={'100%'}>
|
<Flex justify={'center'} align={'center'} h={'100%'}>
|
||||||
<Text fz={40} fw={'bold'} c={'white'}>35</Text>
|
<Text fz={40} fw={'bold'} c={'white'}>{jumlah}</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{isList ? (
|
{isList ? (
|
||||||
<Box pt={20}>
|
<Box pt={20}>
|
||||||
{dataDivisi.map((v, i) => {
|
{data?.map((v: any, i: any) => {
|
||||||
return (
|
return (
|
||||||
<Box key={i}>
|
<Box key={i}>
|
||||||
<Group justify="space-between" mb={10} onClick={() => router.push(`/division/${v.id}`)}>
|
<Group justify="space-between" mb={10} onClick={() => router.push(`/division/${v.id}`)}>
|
||||||
@@ -113,7 +103,7 @@ export default function NavbarDivision() {
|
|||||||
<HiMiniUserGroup size={25} color={WARNA.biruTua} />
|
<HiMiniUserGroup size={25} color={WARNA.biruTua} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Center>
|
</Center>
|
||||||
<Text>{v.title}</Text>
|
<Text>{v.name}</Text>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<Divider my="sm" />
|
<Divider my="sm" />
|
||||||
@@ -123,19 +113,19 @@ export default function NavbarDivision() {
|
|||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Box pt={20}>
|
<Box pt={20}>
|
||||||
{dataDivisi.map((v, i) => {
|
{data?.map((v: any, i: any) => {
|
||||||
return (
|
return (
|
||||||
<Box key={i} mb={20}>
|
<Box key={i} mb={20}>
|
||||||
<Card shadow="sm" padding="md" component="a" radius={10} onClick={() => router.push(`/division/${v.id}`)}>
|
<Card shadow="sm" padding="md" component="a" radius={10} onClick={() => router.push(`/division/${v.id}`)}>
|
||||||
<Card.Section>
|
<Card.Section>
|
||||||
<Box h={120} bg={WARNA.biruTua}>
|
<Box h={120} bg={WARNA.biruTua}>
|
||||||
<Flex justify={'center'} align={'center'} h={"100%"}>
|
<Flex justify={'center'} align={'center'} h={"100%"}>
|
||||||
<Title order={3} c={"white"}>{v.title}</Title>
|
<Title order={3} c={"white"}>{v.name}</Title>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
</Card.Section>
|
</Card.Section>
|
||||||
<Box pt={10}>
|
<Box pt={10}>
|
||||||
<Text>{v.description}</Text>
|
<Text>{v.desc}</Text>
|
||||||
<Group align='center' pt={10} justify='flex-end'>
|
<Group align='center' pt={10} justify='flex-end'>
|
||||||
<Avatar.Group>
|
<Avatar.Group>
|
||||||
<Avatar>
|
<Avatar>
|
||||||
@@ -153,7 +143,7 @@ export default function NavbarDivision() {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
||||||
<DrawerDivision/>
|
<DrawerDivision />
|
||||||
</LayoutDrawer>
|
</LayoutDrawer>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
4
src/module/division_new/lib/val_division.ts
Normal file
4
src/module/division_new/lib/val_division.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import { TypeUser } from "@/module/user";
|
||||||
|
import { hookstate } from "@hookstate/core";
|
||||||
|
|
||||||
|
export const globalMemberDivision = hookstate<TypeUser>([]);
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
import { NextRequest } from "next/server";
|
import { NextRequest } from "next/server";
|
||||||
|
|
||||||
export async function listGroups(req: NextRequest): Promise<Response> {
|
export async function listGroups(req: NextRequest): Promise<Response> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const user = await funGetUserByCookies()
|
||||||
const searchParams = req.nextUrl.searchParams
|
const searchParams = req.nextUrl.searchParams
|
||||||
const villaId = "121212"
|
const villaId = user.idVillage
|
||||||
const active = searchParams.get('active');
|
const active = searchParams.get('active');
|
||||||
const groups = await prisma.group.findMany({
|
const groups = await prisma.group.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import { TypeGroup } from './lib/type_group';
|
||||||
import { apiGroup } from "./api/api_group";
|
import { apiGroup } from "./api/api_group";
|
||||||
import ViewGroup from "./view/view_group";
|
import ViewGroup from "./view/view_group";
|
||||||
|
|
||||||
export { ViewGroup };
|
export { ViewGroup };
|
||||||
export { apiGroup };
|
export { apiGroup };
|
||||||
|
export type { TypeGroup }
|
||||||
|
|||||||
5
src/module/group/lib/type_group.ts
Normal file
5
src/module/group/lib/type_group.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export type TypeGroup = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
isActive: boolean
|
||||||
|
}[]
|
||||||
@@ -4,7 +4,7 @@ import { NextRequest } from "next/server";
|
|||||||
export async function getAllUser(req: NextRequest) {
|
export async function getAllUser(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const searchParams = req.nextUrl.searchParams;
|
const searchParams = req.nextUrl.searchParams;
|
||||||
const idGroup = "2";
|
const idGroup = searchParams.get("idGroup");;
|
||||||
const idVillage = "121212";
|
const idVillage = "121212";
|
||||||
const active = searchParams.get("active");
|
const active = searchParams.get("active");
|
||||||
const idPosition = searchParams.get("idPosition");
|
const idPosition = searchParams.get("idPosition");
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { TypeUser } from './lib/type_user';
|
||||||
import { apiUser } from "./api/api_user";
|
import { apiUser } from "./api/api_user";
|
||||||
import createLogUser from "./log/fun/createLogUser";
|
import createLogUser from "./log/fun/createLogUser";
|
||||||
import ViewEditProfile from "./profile/view/view_edit_profile";
|
import ViewEditProfile from "./profile/view/view_edit_profile";
|
||||||
@@ -7,3 +8,4 @@ export { ViewProfile };
|
|||||||
export { ViewEditProfile };
|
export { ViewEditProfile };
|
||||||
export { apiUser };
|
export { apiUser };
|
||||||
export { createLogUser };
|
export { createLogUser };
|
||||||
|
export type { TypeUser }
|
||||||
|
|||||||
11
src/module/user/lib/type_user.ts
Normal file
11
src/module/user/lib/type_user.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export type TypeUser = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
nik: string
|
||||||
|
phone: string
|
||||||
|
email: string
|
||||||
|
gender: string
|
||||||
|
isActive: boolean,
|
||||||
|
group: string,
|
||||||
|
position: string
|
||||||
|
}[]
|
||||||
Reference in New Issue
Block a user