upd: project
Deskripsi: - pembatasan user No Issues
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"use client"
|
||||
import { WARNA } from '@/module/_global';
|
||||
import { globalRole, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Avatar, Badge, Box, Card, Center, Divider, Flex, Grid, Group, Text, TextInput, Title } from '@mantine/core';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import React, { useState } from 'react';
|
||||
@@ -11,6 +11,7 @@ import toast from 'react-hot-toast';
|
||||
import { useShallowEffect } from '@mantine/hooks';
|
||||
import { IDataProject } from '../lib/type_project';
|
||||
import { funGetAllGroup, IDataGroup } from '@/module/group';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
|
||||
export default function ListProject() {
|
||||
const [isList, setIsList] = useState(false)
|
||||
@@ -21,23 +22,22 @@ export default function ListProject() {
|
||||
const status = searchParams.get('status')
|
||||
const group = searchParams.get('group')
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const roleLogin = useHookstate(globalRole)
|
||||
const [nameGroup, setNameGroup] = useState('')
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setData([]);
|
||||
setLoading(true);
|
||||
|
||||
setLoading(true)
|
||||
const response = await funGetAllProject('?status=' + status + '&search=' + searchQuery + '&group=' + group)
|
||||
|
||||
if (response.success) {
|
||||
setData(response?.data)
|
||||
setNameGroup(response.filter.name)
|
||||
} else {
|
||||
toast.error(response.message);
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
toast.error("Gagal mendapatkan Kegiatan, coba lagi nanti");
|
||||
toast.error("Gagal mendapatkan kegiatan, coba lagi nanti");
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -53,31 +53,6 @@ export default function ListProject() {
|
||||
setIsList(!isList)
|
||||
}
|
||||
|
||||
const [checked, setChecked] = useState<IDataGroup[]>([]);
|
||||
|
||||
const groupNameMap = (groupId: string) => {
|
||||
const groupName = checked.find((group) => group.id === groupId)?.name;
|
||||
return groupName || '-';
|
||||
};
|
||||
|
||||
async function getAllGroupFilter() {
|
||||
try {
|
||||
const response = await funGetAllGroup('?active=true')
|
||||
if (response.success) {
|
||||
setChecked(response.data);
|
||||
} else {
|
||||
toast.error(response.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
getAllGroupFilter();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Box mt={20}>
|
||||
<Grid justify='center' align='center'>
|
||||
@@ -109,7 +84,7 @@ export default function ListProject() {
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Box pt={20}>
|
||||
{group && <Text>Filter by: {groupNameMap(group)}</Text>}
|
||||
{roleLogin.get() == 'supadmin' && <Text>Filter by: {nameGroup}</Text>}
|
||||
<Box bg={"#DCEED8"} p={10} style={{ borderRadius: 10 }}>
|
||||
<Text fw={'bold'} c={WARNA.biruTua}>Total Kegiatan</Text>
|
||||
<Flex justify={'center'} align={'center'} h={'100%'}>
|
||||
@@ -121,7 +96,7 @@ export default function ListProject() {
|
||||
{isData.map((v, i) => {
|
||||
return (
|
||||
<Box key={i}>
|
||||
<Grid align='center'>
|
||||
<Grid align='center'>
|
||||
<Grid.Col span={{
|
||||
base: 2,
|
||||
xl: 1
|
||||
@@ -160,13 +135,13 @@ export default function ListProject() {
|
||||
</Box>
|
||||
|
||||
</Box>
|
||||
<RiCircleFill size={12} color={
|
||||
v.status === 0 ? '#1372C4' :
|
||||
v.status === 1 ? '#C5771A' :
|
||||
v.status === 2 ? '#0B6025' :
|
||||
v.status === 3 ? '#BB1F1F' :
|
||||
""
|
||||
} />
|
||||
<RiCircleFill size={12} color={
|
||||
v.status === 0 ? '#1372C4' :
|
||||
v.status === 1 ? '#C5771A' :
|
||||
v.status === 2 ? '#0B6025' :
|
||||
v.status === 3 ? '#BB1F1F' :
|
||||
""
|
||||
} />
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { WARNA } from '@/module/_global';
|
||||
import { globalRole, WARNA } from '@/module/_global';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { HiOutlineFilter } from 'react-icons/hi';
|
||||
import { IoAddCircle } from 'react-icons/io5';
|
||||
|
||||
export default function MenuDrawerProject() {
|
||||
const roleLogin = useHookstate(globalRole)
|
||||
return (
|
||||
<Box>
|
||||
<Stack pt={10}>
|
||||
@@ -19,14 +21,17 @@ export default function MenuDrawerProject() {
|
||||
<Text c={WARNA.biruTua}>Tambah Kegiatan</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
<Flex onClick={() => window.location.href = "/project?cat=filter"} justify={'center'} align={'center'} direction={'column'} >
|
||||
<Box>
|
||||
<HiOutlineFilter size={30} color={WARNA.biruTua} />
|
||||
</Box>
|
||||
<Box>
|
||||
<Text c={WARNA.biruTua}>Filter</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
{
|
||||
roleLogin.get() == "supadmin" &&
|
||||
<Flex onClick={() => window.location.href = "/project?cat=filter"} justify={'center'} align={'center'} direction={'column'} >
|
||||
<Box>
|
||||
<HiOutlineFilter size={30} color={WARNA.biruTua} />
|
||||
</Box>
|
||||
<Box>
|
||||
<Text c={WARNA.biruTua}>Filter</Text>
|
||||
</Box>
|
||||
</Flex>
|
||||
}
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
"use client"
|
||||
import { LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Avatar, Badge, Box, Card, Center, Divider, Flex, Grid, Group, rem, Tabs, Text, TextInput, Title } from '@mantine/core';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { globalRole, LayoutDrawer, LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||
import { ActionIcon, Box, rem, Tabs } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { HiMenu } from 'react-icons/hi';
|
||||
import { HiMagnifyingGlass, HiMiniPresentationChartBar, HiOutlineListBullet, HiSquares2X2 } from 'react-icons/hi2';
|
||||
import { MdAccountCircle } from 'react-icons/md';
|
||||
import { RiCircleFill, RiProgress3Line } from "react-icons/ri";
|
||||
import { RiProgress3Line } from "react-icons/ri";
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { TbClockPause } from 'react-icons/tb';
|
||||
import { IoIosCheckmarkCircleOutline } from 'react-icons/io';
|
||||
import { IoCloseCircleOutline } from 'react-icons/io5';
|
||||
import ListProject from './list_project';
|
||||
import MenuDrawerProject from './menu_drawer_project';
|
||||
import { useHookstate } from '@hookstate/core';
|
||||
|
||||
export default function TabProject() {
|
||||
const [openDrawer, setOpenDrawer] = useState(false)
|
||||
@@ -20,13 +19,17 @@ export default function TabProject() {
|
||||
const status = searchParams.get('status')
|
||||
const group = searchParams.get("group");
|
||||
const iconStyle = { width: rem(20), height: rem(20) };
|
||||
const roleLogin = useHookstate(globalRole)
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<LayoutNavbarNew back='/home' title='Kegiatan'
|
||||
menu={<ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||
<HiMenu size={20} color='white' />
|
||||
</ActionIcon>} />
|
||||
menu={(roleLogin.get() != "user" && roleLogin.get() != "coadmin") ?
|
||||
<ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={WARNA.bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||
<HiMenu size={20} color='white' />
|
||||
</ActionIcon>
|
||||
: <></>
|
||||
} />
|
||||
|
||||
<Box p={20}>
|
||||
<Tabs variant="pills" radius="xl" defaultValue={(status == "1" || status == "2" || status == "3") ? status : "0"}>
|
||||
|
||||
Reference in New Issue
Block a user