Merge pull request #167 from bipproduction/amalia/29-agustus-24
Amalia/29 agustus 24
This commit is contained in:
@@ -4,12 +4,13 @@
|
|||||||
|
|
||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
import { funGetUserByCookies } from "@/module/auth";
|
||||||
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url)
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search")
|
||||||
const userId = await funGetUserByCookies()
|
const userId = await funGetUserByCookies()
|
||||||
if (userId.id == undefined) {
|
if (userId.id == undefined) {
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||||
@@ -69,31 +70,68 @@ export async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
email: true
|
email: true,
|
||||||
|
img: true,
|
||||||
|
Position: {
|
||||||
|
select: {
|
||||||
|
name: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group: {
|
||||||
|
select: {
|
||||||
|
name: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const userOmit = user.map((v: any) => ({
|
||||||
|
..._.omit(v, ["Position", "Group"]),
|
||||||
|
position: v.Position.name,
|
||||||
|
group: v.Group.name
|
||||||
|
}))
|
||||||
|
|
||||||
const divisions = await prisma.division.findMany({
|
const divisions = await prisma.division.findMany({
|
||||||
where: kondisi,
|
where: kondisi,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
desc: true
|
desc: true,
|
||||||
|
Group: {
|
||||||
|
select: {
|
||||||
|
name: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const divisionOmit = divisions.map((v: any) => ({
|
||||||
|
..._.omit(v, ["Group"]),
|
||||||
|
group: v.Group.name
|
||||||
|
}))
|
||||||
|
|
||||||
const projects = await prisma.project.findMany({
|
const projects = await prisma.project.findMany({
|
||||||
where: kondisiProject,
|
where: kondisiProject,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
Group: {
|
||||||
|
select: {
|
||||||
|
name: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const projectOmit = projects.map((v: any) => ({
|
||||||
|
..._.omit(v, ["Group"]),
|
||||||
|
group: v.Group.name
|
||||||
|
}))
|
||||||
|
|
||||||
const allDataSearch = {
|
const allDataSearch = {
|
||||||
user: user,
|
user: userOmit,
|
||||||
division: divisions,
|
division: divisionOmit,
|
||||||
project: projects
|
project: projectOmit
|
||||||
}
|
}
|
||||||
return NextResponse.json({ success: true, data: allDataSearch }, { status: 200 });
|
return NextResponse.json({ success: true, data: allDataSearch }, { status: 200 });
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,20 @@ export interface IDataUserSearch {
|
|||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
email: string
|
email: string
|
||||||
|
position: string
|
||||||
|
group: string
|
||||||
|
img: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDataProjectSearch {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
group: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDataDivisionSearch {
|
export interface IDataDivisionSearch {
|
||||||
id: string
|
|
||||||
title: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IDataProjectSearch {
|
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
desc: string
|
desc: string
|
||||||
}
|
group: string
|
||||||
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export default function ViewDetailFeature() {
|
|||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Center>
|
</Center>
|
||||||
<Center>
|
<Center>
|
||||||
<Text fz={15} c={WARNA.biruTua}>Group</Text>
|
<Text fz={15} c={WARNA.biruTua}>Grup</Text>
|
||||||
</Center>
|
</Center>
|
||||||
</Box>
|
</Box>
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { LayoutNavbarNew, WARNA } from '@/module/_global';
|
import { LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||||
import { ActionIcon, Box, Divider, Grid, Group, Text, TextInput } from '@mantine/core';
|
import { ActionIcon, Avatar, Box, Divider, Grid, Group, Text, TextInput } from '@mantine/core';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { HiMagnifyingGlass, HiMiniUser } from 'react-icons/hi2';
|
import { HiMagnifyingGlass, HiMiniPresentationChartBar, HiMiniUserGroup } from 'react-icons/hi2';
|
||||||
import { funGetSearchAll } from '../lib/api_search';
|
import { funGetSearchAll } from '../lib/api_search';
|
||||||
import { useShallowEffect } from '@mantine/hooks';
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
import { IDataDivisionSearch, IDataProjectSearch, IDataUserSearch } from '../lib/type_search';
|
import { IDataDivisionSearch, IDataProjectSearch, IDataUserSearch } from '../lib/type_search';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
export default function ViewSearch() {
|
export default function ViewSearch() {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const [dataUser, setDataUser] = useState<IDataUserSearch[]>([]);
|
const [dataUser, setDataUser] = useState<IDataUserSearch[]>([]);
|
||||||
const [dataProject, setDataProject] = useState<IDataDivisionSearch[]>([]);
|
const [dataProject, setDataProject] = useState<IDataProjectSearch[]>([]);
|
||||||
const [dataDivision, setDataDivision] = useState<IDataProjectSearch[]>([]);
|
const [dataDivision, setDataDivision] = useState<IDataDivisionSearch[]>([]);
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
async function featchSearch() {
|
async function featchSearch() {
|
||||||
try {
|
try {
|
||||||
@@ -26,8 +28,12 @@ export default function ViewSearch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (search !== '') {
|
if (search != '') {
|
||||||
featchSearch()
|
featchSearch()
|
||||||
|
} else {
|
||||||
|
setDataUser([]);
|
||||||
|
setDataProject([]);
|
||||||
|
setDataDivision([]);
|
||||||
}
|
}
|
||||||
}, [search])
|
}, [search])
|
||||||
|
|
||||||
@@ -58,32 +64,39 @@ export default function ViewSearch() {
|
|||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
}}>
|
}}>
|
||||||
<Text>ANGGOTA</Text>
|
<Text>ANGGOTA</Text>
|
||||||
{dataUser.length > 0 ? (
|
<Box style={{
|
||||||
<Box>
|
paddingLeft: 20,
|
||||||
{dataUser.map((v, i) => {
|
paddingRight: 20,
|
||||||
return (
|
paddingTop: 10,
|
||||||
<Box key={i}>
|
paddingBottom: 10,
|
||||||
<Group align='center' style={{
|
backgroundColor: `#E7EBF1`,
|
||||||
padding: 10,
|
borderRadius: 5
|
||||||
}} >
|
}}>
|
||||||
<Box>
|
{dataUser.length > 0 ? (
|
||||||
<ActionIcon variant="light" bg={WARNA.biruTua} size={50} radius={100} aria-label="icon">
|
<Box>
|
||||||
<HiMiniUser color={'white'} size={25} />
|
{dataUser.map((v, i) => {
|
||||||
</ActionIcon>
|
return (
|
||||||
</Box>
|
<Box key={i} onClick={() => router.push(`/member/${v.id}`)}>
|
||||||
<Box>
|
<Group align='center' style={{
|
||||||
<Text fw={'bold'} c={WARNA.biruTua}>{v.name}</Text>
|
padding: 5,
|
||||||
<Text fw={'lighter'} fz={12}>{v.email}</Text>
|
paddingLeft: 0,
|
||||||
</Box>
|
}} >
|
||||||
</Group>
|
<Avatar src={`/api/file/img?cat=user&file=${v.img}`} size="lg" />
|
||||||
<Divider my={5} />
|
<Box>
|
||||||
</Box>
|
<Text fw={'bold'} c={WARNA.biruTua}>{v.name}</Text>
|
||||||
)
|
<Text fw={'lighter'} fz={12}>{v.group + ' - ' + v.position}</Text>
|
||||||
})}
|
</Box>
|
||||||
</Box>
|
</Group>
|
||||||
) :
|
<Divider my={5} />
|
||||||
<Text>Tidak Ada Anggota</Text>
|
</Box>
|
||||||
}
|
)
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
) :
|
||||||
|
<Text>Tidak Ada Anggota</Text>
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
|
||||||
<Box mt={10}>
|
<Box mt={10}>
|
||||||
<Text>DIVISI</Text>
|
<Text>DIVISI</Text>
|
||||||
<Box style={{
|
<Box style={{
|
||||||
@@ -98,15 +111,16 @@ export default function ViewSearch() {
|
|||||||
<Box>
|
<Box>
|
||||||
{dataDivision.map((v, i) => {
|
{dataDivision.map((v, i) => {
|
||||||
return (
|
return (
|
||||||
<Box key={i}>
|
<Box key={i} onClick={() => router.push(`/division/${v.id}`)}>
|
||||||
<Grid justify='center' align='center' mt={15}>
|
<Grid justify='center' align='center' mt={15}>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<ActionIcon variant="light" bg={WARNA.biruTua} size={50} radius={100} aria-label="icon">
|
<ActionIcon variant="light" bg={WARNA.biruTua} size={50} radius={100} aria-label="icon">
|
||||||
<HiMiniUser color={'white'} size={25} />
|
<HiMiniUserGroup color={'white'} size={25} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={10}>
|
<Grid.Col span={10}>
|
||||||
<Text fw={'bold'} c={WARNA.biruTua}>{v.name.toUpperCase()}</Text>
|
<Text fw={'bold'} c={WARNA.biruTua}>{v.name.toUpperCase()}</Text>
|
||||||
|
<Text fw={'lighter'} fz={12}>{v.group}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Text fw={'lighter'} mt={5} mb={10} lineClamp={2}>{v.desc}</Text>
|
<Text fw={'lighter'} mt={5} mb={10} lineClamp={2}>{v.desc}</Text>
|
||||||
@@ -131,28 +145,29 @@ export default function ViewSearch() {
|
|||||||
borderRadius: 5
|
borderRadius: 5
|
||||||
}}>
|
}}>
|
||||||
{dataProject.length > 0 ? (
|
{dataProject.length > 0 ? (
|
||||||
<Box>
|
<Box>
|
||||||
{dataProject.map((v, i) => {
|
{dataProject.map((v, i) => {
|
||||||
return (
|
return (
|
||||||
<Box key={i}>
|
<Box key={i} onClick={() => router.push(`/project/${v.id}`)}>
|
||||||
<Grid justify='center' align='center' mt={10}>
|
<Grid justify='center' align='center' mt={10}>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<ActionIcon variant="light" bg={WARNA.biruTua} size={50} radius={100} aria-label="icon">
|
<ActionIcon variant="light" bg={WARNA.biruTua} size={50} radius={100} aria-label="icon">
|
||||||
<HiMiniUser color={'white'} size={25} />
|
<HiMiniPresentationChartBar color={'white'} size={25} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={10}>
|
<Grid.Col span={10}>
|
||||||
<Text fw={'bold'} c={WARNA.biruTua}>{v.title.toUpperCase()}</Text>
|
<Text fw={'bold'} c={WARNA.biruTua}>{v.title.toUpperCase()}</Text>
|
||||||
</Grid.Col>
|
<Text fw={'lighter'} fz={12}>{v.group}</Text>
|
||||||
</Grid>
|
</Grid.Col>
|
||||||
<Divider mt={10} />
|
</Grid>
|
||||||
</Box>
|
<Divider mt={10} />
|
||||||
)
|
</Box>
|
||||||
})}
|
)
|
||||||
</Box>
|
})}
|
||||||
|
</Box>
|
||||||
)
|
)
|
||||||
: <Text>Tidak Ada Kegiatan</Text>
|
: <Text>Tidak Ada Kegiatan</Text>
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { TypeUser } from './lib/type_user';
|
import { TypeUser } from './lib/type_user';
|
||||||
import createLogUser from "./log/fun/createLogUser";
|
import createLogUser from "./log/fun/createLogUser";
|
||||||
import ViewProfile from "./profile/view/view_profile";
|
|
||||||
import { funGetAllmember } from './member/lib/api_member';
|
import { funGetAllmember } from './member/lib/api_member';
|
||||||
import Profile from './profile/ui/profile';
|
import Profile from './profile/ui/profile';
|
||||||
import EditProfile from './profile/ui/edit_profile';
|
import EditProfile from './profile/ui/edit_profile';
|
||||||
|
|
||||||
export { ViewProfile };
|
|
||||||
export { createLogUser };
|
export { createLogUser };
|
||||||
export type { TypeUser }
|
export type { TypeUser }
|
||||||
export { funGetAllmember }
|
export { funGetAllmember }
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
'use client'
|
|
||||||
import { LayoutIconBack, LayoutNavbarHome, LayoutNavbarNew } from '@/module/_global';
|
|
||||||
import { Box, Grid, Text } from '@mantine/core';
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
export default function HeaderEditProfile() {
|
|
||||||
return (
|
|
||||||
<LayoutNavbarNew back='' title='Edit Profil' menu='' />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
'use client'
|
|
||||||
import { Group, Text } from "@mantine/core";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
|
|
||||||
export function InfoTitleProfile() {
|
|
||||||
const router = useRouter()
|
|
||||||
return (
|
|
||||||
<Group justify="space-between" grow py={5}>
|
|
||||||
<Text fw={'bold'} fz={20}>Informasi</Text>
|
|
||||||
<Text style={{ cursor: 'pointer' }} ta={"right"} c={"blue"} onClick={() => router.push('/profile/edit')}>Edit</Text>
|
|
||||||
</Group>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -107,7 +107,7 @@ export default function Profile() {
|
|||||||
<FaSquarePhone size={28} />
|
<FaSquarePhone size={28} />
|
||||||
<Text fz={18}>No Telepon</Text>
|
<Text fz={18}>No Telepon</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Text fz={18} fw={'bold'} ta={"right"}>{isData?.phone}</Text>
|
<Text fz={18} fw={'bold'} ta={"right"}>+62{isData?.phone}</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Group justify="space-between" grow py={5}>
|
<Group justify="space-between" grow py={5}>
|
||||||
<Group>
|
<Group>
|
||||||
@@ -119,7 +119,7 @@ export default function Profile() {
|
|||||||
<Group justify="space-between" grow py={5}>
|
<Group justify="space-between" grow py={5}>
|
||||||
<Group>
|
<Group>
|
||||||
<IoMaleFemale size={28} />
|
<IoMaleFemale size={28} />
|
||||||
<Text fz={18}>Gender</Text>
|
<Text fz={18}>Jenis Kelamin</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Text fz={18} fw={'bold'} ta={"right"}>
|
<Text fz={18} fw={'bold'} ta={"right"}>
|
||||||
{isData?.gender === 'M' ? 'Laki-laki' : isData?.gender === 'F' ? 'Perempuan' : ''}
|
{isData?.gender === 'M' ? 'Laki-laki' : isData?.gender === 'F' ? 'Perempuan' : ''}
|
||||||
@@ -130,7 +130,7 @@ export default function Profile() {
|
|||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
||||||
description="Apakah Anda yakin ingin Keluar?"
|
description="Apakah Anda yakin ingin keluar?"
|
||||||
onYes={(val) => onLogout(val)} />
|
onYes={(val) => onLogout(val)} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
"use client"
|
|
||||||
import { LayoutIconBack, LayoutNavbarHome, WARNA } from "@/module/_global";
|
|
||||||
import { ActionIcon, Anchor, Box, Button, Flex, Group, Stack, Text } from "@mantine/core";
|
|
||||||
import { BsInfo } from "react-icons/bs";
|
|
||||||
import { HiUser } from "react-icons/hi2";
|
|
||||||
import { RiIdCardFill } from "react-icons/ri";
|
|
||||||
import { FaSquarePhone } from "react-icons/fa6";
|
|
||||||
import { MdEmail } from "react-icons/md";
|
|
||||||
import { InfoTitleProfile } from "../component/ui/ui_profile";
|
|
||||||
import { IoMaleFemale } from "react-icons/io5";
|
|
||||||
import toast from "react-hot-toast";
|
|
||||||
import { LuLogOut } from "react-icons/lu";
|
|
||||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
export default function ViewProfile() {
|
|
||||||
const [openModal, setOpenModal] = useState(false);
|
|
||||||
|
|
||||||
async function onLogout(val: boolean) {
|
|
||||||
try {
|
|
||||||
if (val) {
|
|
||||||
await fetch('/api/auth/logout', {
|
|
||||||
method: 'DELETE',
|
|
||||||
});
|
|
||||||
toast.success('Logout Success')
|
|
||||||
window.location.href = '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
setOpenModal(false)
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<LayoutNavbarHome>
|
|
||||||
<Group justify="space-between">
|
|
||||||
<LayoutIconBack />
|
|
||||||
|
|
||||||
<ActionIcon onClick={() => { setOpenModal(true) }} variant="light" bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Info">
|
|
||||||
<LuLogOut size={20} color='white' />
|
|
||||||
</ActionIcon>
|
|
||||||
</Group>
|
|
||||||
<Stack
|
|
||||||
align="center"
|
|
||||||
justify="center"
|
|
||||||
gap="xs"
|
|
||||||
>
|
|
||||||
<HiUser size={100} color='white' />
|
|
||||||
<Text c={'white'} fw={'bold'} fz={25}>Fibra Marcell</Text>
|
|
||||||
<Text c={'white'} fw={'lighter'} fz={15}>Kepala Urusan Pengembangan</Text>
|
|
||||||
</Stack>
|
|
||||||
</LayoutNavbarHome>
|
|
||||||
<Box p={20}>
|
|
||||||
<InfoTitleProfile />
|
|
||||||
<Group justify="space-between" grow py={5}>
|
|
||||||
<Group>
|
|
||||||
<RiIdCardFill size={28} />
|
|
||||||
<Text fz={18}>NIK</Text>
|
|
||||||
</Group>
|
|
||||||
<Text fz={18} fw={'bold'} ta={"right"}>513177782899</Text>
|
|
||||||
</Group>
|
|
||||||
<Group justify="space-between" grow py={5}>
|
|
||||||
<Group>
|
|
||||||
<FaSquarePhone size={28} />
|
|
||||||
<Text fz={18}>NoTelepon</Text>
|
|
||||||
</Group>
|
|
||||||
<Text fz={18} fw={'bold'} ta={"right"}>+62038939293</Text>
|
|
||||||
</Group>
|
|
||||||
<Group justify="space-between" grow py={5}>
|
|
||||||
<Group>
|
|
||||||
<MdEmail size={28} />
|
|
||||||
<Text fz={18}>Email</Text>
|
|
||||||
</Group>
|
|
||||||
<Text fz={18} fw={'bold'} ta={"right"}>marcel@gmail.com</Text>
|
|
||||||
</Group>
|
|
||||||
<Group justify="space-between" grow py={5}>
|
|
||||||
<Group>
|
|
||||||
<IoMaleFemale size={28} />
|
|
||||||
<Text fz={18}>Gender</Text>
|
|
||||||
</Group>
|
|
||||||
<Text fz={18} fw={'bold'} ta={"right"}>Laki-laki</Text>
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
|
||||||
description="Apakah Anda yakin ingin Keluar?"
|
|
||||||
onYes={(val) => onLogout(val)} />
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user