@@ -1,10 +1,14 @@
|
|||||||
import { ViewFilter } from '@/module/_global';
|
import { ViewFilter, ViewFilterData } from '@/module/_global';
|
||||||
import { TabProject } from '@/module/project';
|
import { TabProject } from '@/module/project';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
function Page({ searchParams }: { searchParams: { page: string } }) {
|
function Page({ searchParams }: { searchParams: { page: string } }) {
|
||||||
if (searchParams.page == 'filter')
|
if (searchParams.page == 'filter')
|
||||||
return <ViewFilter linkFilter='project' />
|
return <ViewFilter linkFilter='project' />
|
||||||
|
|
||||||
|
if (searchParams.page == 'filter-data')
|
||||||
|
return <ViewFilterData linkFilter='project' />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabProject />
|
<TabProject />
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export async function GET(request: Request) {
|
|||||||
const roleUser = user.idUserRole
|
const roleUser = user.idUserRole
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const idGroup = searchParams.get("group");
|
const idGroup = searchParams.get("group");
|
||||||
|
const kategori = searchParams.get("cat");
|
||||||
const name = searchParams.get('search');
|
const name = searchParams.get('search');
|
||||||
const page = searchParams.get('page');
|
const page = searchParams.get('page');
|
||||||
const active = searchParams.get("active");
|
const active = searchParams.get("active");
|
||||||
@@ -30,6 +31,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// JIKA (ROLE BUKAN USER DAN COADMIN) ATAU SEMUA ROLE DG KATEGORI == SEMUA
|
||||||
let kondisi: any = {
|
let kondisi: any = {
|
||||||
isActive: active == 'false' ? false : true,
|
isActive: active == 'false' ? false : true,
|
||||||
idVillage: String(villaId),
|
idVillage: String(villaId),
|
||||||
@@ -40,7 +42,10 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// JIKA ROLE = USER ATAU COADMIN DAN KATEGORI != SEMUA (DIVISI SAYA)
|
||||||
if (roleUser != "supadmin" && roleUser != "cosupadmin" && roleUser != "admin") {
|
if (roleUser != "supadmin" && roleUser != "cosupadmin" && roleUser != "admin") {
|
||||||
|
if (kategori != "semua") {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: active == 'false' ? false : true,
|
isActive: active == 'false' ? false : true,
|
||||||
idVillage: String(villaId),
|
idVillage: String(villaId),
|
||||||
@@ -57,6 +62,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const totalData = await prisma.division.count({
|
const totalData = await prisma.division.count({
|
||||||
where: kondisi
|
where: kondisi
|
||||||
|
|||||||
@@ -133,13 +133,13 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const member = await prisma.user.findMany({
|
const member = await prisma.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
idGroup: String(groupId),
|
idGroup: String(groupId),
|
||||||
id: {
|
// id: {
|
||||||
not: String(userId)
|
// not: String(userId)
|
||||||
},
|
// },
|
||||||
OR: [
|
// OR: [
|
||||||
{ idUserRole: 'coadmin', },
|
// { idUserRole: 'coadmin', },
|
||||||
{ idUserRole: 'user', }
|
// { idUserRole: 'user', }
|
||||||
],
|
// ],
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: {
|
name: {
|
||||||
contains: (name == undefined || name == "null") ? "" : name,
|
contains: (name == undefined || name == "null") ? "" : name,
|
||||||
@@ -149,6 +149,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
idUserRole: true,
|
||||||
name: true,
|
name: true,
|
||||||
email: true,
|
email: true,
|
||||||
img: true,
|
img: true,
|
||||||
@@ -172,7 +173,8 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
idUser: v.id,
|
idUser: v.id,
|
||||||
name: v.name,
|
name: v.name,
|
||||||
email: v.email,
|
email: v.email,
|
||||||
img: v.img
|
img: v.img,
|
||||||
|
idUserRole: v.idUserRole
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const dataFix = {
|
const dataFix = {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export async function GET(request: Request) {
|
|||||||
const status = searchParams.get('status');
|
const status = searchParams.get('status');
|
||||||
const idGroup = searchParams.get("group");
|
const idGroup = searchParams.get("group");
|
||||||
const page = searchParams.get('page');
|
const page = searchParams.get('page');
|
||||||
|
const kategori = searchParams.get('cat');
|
||||||
const dataSkip = Number(page) * 10 - 10;
|
const dataSkip = Number(page) * 10 - 10;
|
||||||
const villageId = user.idVillage
|
const villageId = user.idVillage
|
||||||
const userId = user.id
|
const userId = user.id
|
||||||
@@ -41,6 +42,8 @@ export async function GET(request: Request) {
|
|||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data kegiatan, data tidak ditemukan", }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan data kegiatan, data tidak ditemukan", }, { status: 404 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// JIKA (ROLE BUKAN USER DAN COADMIN) ATAU SEMUA ROLE DG KATEGORI == SEMUA
|
||||||
let kondisi: any = {
|
let kondisi: any = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idVillage: String(villageId),
|
idVillage: String(villageId),
|
||||||
@@ -52,7 +55,10 @@ export async function GET(request: Request) {
|
|||||||
status: (status == "0" || status == "1" || status == "2" || status == "3") ? Number(status) : 0
|
status: (status == "0" || status == "1" || status == "2" || status == "3") ? Number(status) : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// JIKA ROLE = USER ATAU COADMIN DAN KATEGORI != SEMUA (KEGIATAN SAYA)
|
||||||
if (roleUser != "supadmin" && roleUser != "cosupadmin" && roleUser != "admin") {
|
if (roleUser != "supadmin" && roleUser != "cosupadmin" && roleUser != "admin") {
|
||||||
|
if (kategori != "semua") {
|
||||||
kondisi = {
|
kondisi = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idVillage: String(villageId),
|
idVillage: String(villageId),
|
||||||
@@ -69,6 +75,7 @@ export async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const data = await prisma.project.findMany({
|
const data = await prisma.project.findMany({
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export async function PUT(request: Request) {
|
|||||||
const file = body.get("file") as File;
|
const file = body.get("file") as File;
|
||||||
const data = body.get("data");
|
const data = body.get("data");
|
||||||
|
|
||||||
const { name, email, phone, nik, gender } = JSON.parse(data as string)
|
const { name, email, phone, nik, gender, idPosition } = JSON.parse(data as string)
|
||||||
|
|
||||||
const cekNIK = await prisma.user.count({
|
const cekNIK = await prisma.user.count({
|
||||||
where: {
|
where: {
|
||||||
@@ -108,7 +108,8 @@ export async function PUT(request: Request) {
|
|||||||
email: email,
|
email: email,
|
||||||
phone: "62" + phone,
|
phone: "62" + phone,
|
||||||
nik: nik,
|
nik: nik,
|
||||||
gender: gender
|
gender: gender,
|
||||||
|
idPosition: idPosition
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
img: true
|
img: true
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
return NextResponse.json({ success: true, version: "0.2.8", tahap: "beta" }, { status: 200 });
|
return NextResponse.json({ success: true, version: "0.2.9", tahap: "beta" }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import SkeletonUser from "./components/skeleton_user";
|
|||||||
import SkeletonList from "./components/skeleton_list";
|
import SkeletonList from "./components/skeleton_list";
|
||||||
import { funViewDir } from "./fun/view_dir";
|
import { funViewDir } from "./fun/view_dir";
|
||||||
import { funSendWebPush } from "./fun/send_web_push";
|
import { funSendWebPush } from "./fun/send_web_push";
|
||||||
|
import ViewFilterData from "./view/view_filter_kategori_data";
|
||||||
|
|
||||||
export { WARNA };
|
export { WARNA };
|
||||||
export { LayoutLogin };
|
export { LayoutLogin };
|
||||||
@@ -63,3 +64,4 @@ export { SkeletonList }
|
|||||||
export { keyWibu }
|
export { keyWibu }
|
||||||
export { funViewDir }
|
export { funViewDir }
|
||||||
export { funSendWebPush }
|
export { funSendWebPush }
|
||||||
|
export { ViewFilterData }
|
||||||
|
|||||||
84
src/module/_global/view/view_filter_kategori_data.tsx
Normal file
84
src/module/_global/view/view_filter_kategori_data.tsx
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
'use client'
|
||||||
|
import { useHookstate } from "@hookstate/core";
|
||||||
|
import { Box, Button, Divider, Group, rem, Text } from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { FaCheck } from "react-icons/fa6";
|
||||||
|
import { TEMA } from "../bin/val_global";
|
||||||
|
import LayoutNavbarNew from "../layout/layout_navbar_new";
|
||||||
|
|
||||||
|
export default function ViewFilterData({ linkFilter }: { linkFilter: string }) {
|
||||||
|
const [selectedFilter, setSelectedFilter] = useState<any>('');
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
data: "data-saya",
|
||||||
|
name: "Kegiatan Saya",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
data: "semua",
|
||||||
|
name: "Semua Kegiatan",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const searchParams = useSearchParams()
|
||||||
|
const kategori = searchParams.get('cat')
|
||||||
|
const tema = useHookstate(TEMA)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (kategori == "null" || kategori == "undefined" || kategori == '') {
|
||||||
|
setSelectedFilter("data-saya")
|
||||||
|
} else {
|
||||||
|
setSelectedFilter(kategori)
|
||||||
|
}
|
||||||
|
}, [kategori]);
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<LayoutNavbarNew back='' title='Filter' menu />
|
||||||
|
<Box p={20}>
|
||||||
|
{
|
||||||
|
data.map((filter) => (
|
||||||
|
<Box key={filter.id}>
|
||||||
|
<Group
|
||||||
|
justify="space-between"
|
||||||
|
align="center"
|
||||||
|
mb={10}
|
||||||
|
onClick={() => setSelectedFilter(filter.data)}
|
||||||
|
>
|
||||||
|
<Text fw={selectedFilter === filter.data ? 'bold' : 'normal'}>
|
||||||
|
{filter.name}
|
||||||
|
</Text>
|
||||||
|
{selectedFilter === filter.data && <FaCheck size={25} />}
|
||||||
|
</Group>
|
||||||
|
<Divider my={"sm"} />
|
||||||
|
</Box>
|
||||||
|
))
|
||||||
|
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
<Box pos={'fixed'} bottom={0} p={rem(20)} w={"100%"} style={{
|
||||||
|
maxWidth: rem(550),
|
||||||
|
zIndex: 999,
|
||||||
|
backgroundColor: `${tema.get().bgUtama}`,
|
||||||
|
}}>
|
||||||
|
<Button
|
||||||
|
fullWidth
|
||||||
|
radius={100}
|
||||||
|
size="lg"
|
||||||
|
color={tema.get().utama}
|
||||||
|
onClick={() => {
|
||||||
|
router.push(`/${linkFilter}?cat=` + selectedFilter)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Terapkan
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -51,8 +51,9 @@ export default function CreateAnggotaDivision() {
|
|||||||
const user = await funGetUserByCookies();
|
const user = await funGetUserByCookies();
|
||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
const dariUserLogin = res.data.filter((i: any) => i.id != user.id)
|
// const dariUserLogin = res.data.filter((i: any) => i.id != user.id)
|
||||||
const fixListUser = dariUserLogin.filter((i: any) => i.idUserRole == 'coadmin' || i.idUserRole == 'user')
|
// const fixListUser = dariUserLogin.filter((i: any) => i.idUserRole == 'coadmin' || i.idUserRole == 'user')
|
||||||
|
const fixListUser = res.data.filter((i: any) => i.idUserRole != 'supadmin')
|
||||||
setDataMember(fixListUser)
|
setDataMember(fixListUser)
|
||||||
} else {
|
} else {
|
||||||
toast.error(res.message)
|
toast.error(res.message)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export default function ListDivision() {
|
|||||||
const [isRefresh, setRefresh] = useState(false)
|
const [isRefresh, setRefresh] = useState(false)
|
||||||
const notifLoadPage = useHookstate(globalNotifPage)
|
const notifLoadPage = useHookstate(globalNotifPage)
|
||||||
const status = searchParams.get('active')
|
const status = searchParams.get('active')
|
||||||
|
const kategori = searchParams.get('cat')
|
||||||
|
|
||||||
|
|
||||||
const handleList = () => {
|
const handleList = () => {
|
||||||
@@ -43,7 +44,7 @@ export default function ListDivision() {
|
|||||||
if (isPage == 1) {
|
if (isPage == 1) {
|
||||||
setData([])
|
setData([])
|
||||||
}
|
}
|
||||||
const response = await funGetAllDivision('?active=' + status + '&search=' + searchQuery + '&group=' + group + '&page=' + isPage)
|
const response = await funGetAllDivision('?active=' + status + '&search=' + searchQuery + '&group=' + group + '&page=' + isPage + '&cat=' + kategori);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setJumlah(response.total)
|
setJumlah(response.total)
|
||||||
setNameGroup(response.filter.name)
|
setNameGroup(response.filter.name)
|
||||||
@@ -72,7 +73,7 @@ export default function ListDivision() {
|
|||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
fetchData(true)
|
fetchData(true)
|
||||||
}, [status, searchQuery])
|
}, [status, searchQuery, kategori])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ export default function ListDivision() {
|
|||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box pt={20}>
|
<Box pt={20}>
|
||||||
{roleLogin.get() == 'supadmin' && <Text>Filter by: {nameGroup}</Text>}
|
{roleLogin.get() == 'supadmin' && <Text>Filter : {nameGroup}</Text>}
|
||||||
<Box bg={tema.get().bgTotalKegiatan} p={10} style={{ borderRadius: 10 }}>
|
<Box bg={tema.get().bgTotalKegiatan} p={10} style={{ borderRadius: 10 }}>
|
||||||
<Text fw={'bold'} c={tema.get().utama}>Total Divisi</Text>
|
<Text fw={'bold'} c={tema.get().utama}>Total Divisi</Text>
|
||||||
<Flex justify={'center'} align={'center'} h={'100%'}>
|
<Flex justify={'center'} align={'center'} h={'100%'}>
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { LayoutNavbarNew, SkeletonList, SkeletonSingle, TEMA } from '@/module/_global';
|
import { LayoutNavbarNew, SkeletonList, TEMA } from '@/module/_global';
|
||||||
import { useHookstate } from '@hookstate/core';
|
|
||||||
import { ActionIcon, Avatar, Box, Button, Center, Divider, Flex, Grid, Indicator, Input, rem, SimpleGrid, Skeleton, Stack, Text, TextInput } from '@mantine/core';
|
|
||||||
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import React, { useState } from 'react';
|
|
||||||
import { HiChevronLeft, HiMagnifyingGlass } from 'react-icons/hi2';
|
|
||||||
import { funGetAllmember, TypeUser } from '@/module/user';
|
import { funGetAllmember, TypeUser } from '@/module/user';
|
||||||
import { funGetUserByCookies } from '@/module/auth';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import toast from 'react-hot-toast';
|
|
||||||
import { globalMemberDivision } from '../lib/val_division';
|
|
||||||
import { IoArrowBackOutline, IoClose } from 'react-icons/io5';
|
|
||||||
import { Carousel } from '@mantine/carousel';
|
import { Carousel } from '@mantine/carousel';
|
||||||
|
import { ActionIcon, Avatar, Box, Button, Center, Divider, Flex, Grid, Indicator, rem, Stack, Text, TextInput } from '@mantine/core';
|
||||||
|
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
import { FaCheck } from 'react-icons/fa6';
|
import { FaCheck } from 'react-icons/fa6';
|
||||||
|
import { HiChevronLeft, HiMagnifyingGlass } from 'react-icons/hi2';
|
||||||
|
import { IoArrowBackOutline, IoClose } from 'react-icons/io5';
|
||||||
|
import { globalMemberDivision } from '../lib/val_division';
|
||||||
|
|
||||||
|
|
||||||
export default function NavbarCreateUsers({ grup, onClose }: { grup?: string, onClose: (val: any) => void }) {
|
export default function NavbarCreateUsers({ grup, onClose }: { grup?: string, onClose: (val: any) => void }) {
|
||||||
const router = useRouter()
|
|
||||||
const member = useHookstate(globalMemberDivision)
|
const member = useHookstate(globalMemberDivision)
|
||||||
const [selectedFiles, setSelectedFiles] = useState<any>([]);
|
const [selectedFiles, setSelectedFiles] = useState<any>([]);
|
||||||
const [dataMember, setDataMember] = useState<TypeUser>([])
|
const [dataMember, setDataMember] = useState<TypeUser>([])
|
||||||
@@ -37,10 +34,11 @@ export default function NavbarCreateUsers({ grup, onClose }: { grup?: string, on
|
|||||||
async function loadData(search: string) {
|
async function loadData(search: string) {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await funGetAllmember('?active=true&group=' + grup + '&search=' + search);
|
const res = await funGetAllmember('?active=true&group=' + grup + '&search=' + search);
|
||||||
const user = await funGetUserByCookies();
|
// const user = await funGetUserByCookies();
|
||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setDataMember(res.data.filter((i: any) => i.id != user.id))
|
// setDataMember(res.data.filter((i: any) => i.id != user.id))
|
||||||
|
setDataMember(res.data.filter((i: any) => i.idUserRole != "supadmin"))
|
||||||
|
|
||||||
// cek data member sebelumnya
|
// cek data member sebelumnya
|
||||||
if (member.length > 0) {
|
if (member.length > 0) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useHookstate } from "@hookstate/core";
|
|||||||
import { Box, rem, Tabs } from "@mantine/core";
|
import { Box, rem, Tabs } from "@mantine/core";
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
import { IoMdCheckmarkCircleOutline } from "react-icons/io";
|
import { IoMdCheckmarkCircleOutline } from "react-icons/io";
|
||||||
import { IoCloseCircleOutline } from "react-icons/io5";
|
import { IoCloseCircleOutline, IoFileTrayOutline, IoFileTrayStackedOutline } from "react-icons/io5";
|
||||||
import ListDivision from "./list_division";
|
import ListDivision from "./list_division";
|
||||||
|
|
||||||
export default function TabListDivision() {
|
export default function TabListDivision() {
|
||||||
@@ -13,6 +13,7 @@ export default function TabListDivision() {
|
|||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const status = searchParams.get("active");
|
const status = searchParams.get("active");
|
||||||
const group = searchParams.get("group");
|
const group = searchParams.get("group");
|
||||||
|
const kategori = searchParams.get("cat");
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
const roleLogin = useHookstate(globalRole)
|
const roleLogin = useHookstate(globalRole)
|
||||||
|
|
||||||
@@ -22,11 +23,13 @@ export default function TabListDivision() {
|
|||||||
variant="pills"
|
variant="pills"
|
||||||
color={tema.get().bgFiturHome}
|
color={tema.get().bgFiturHome}
|
||||||
radius="xl"
|
radius="xl"
|
||||||
defaultValue={status == "false" ? "false" : "true"}
|
defaultValue={status == "false" || kategori == "semua" ? "false" : "true"}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
roleLogin.get() != '' ?
|
roleLogin.get() != ''
|
||||||
(roleLogin.get() != "user" && roleLogin.get() != "coadmin") &&
|
?
|
||||||
|
(roleLogin.get() != "user" && roleLogin.get() != "coadmin")
|
||||||
|
?
|
||||||
<Tabs.List
|
<Tabs.List
|
||||||
bg={"white"}
|
bg={"white"}
|
||||||
style={{
|
style={{
|
||||||
@@ -56,6 +59,36 @@ export default function TabListDivision() {
|
|||||||
Tidak Aktif
|
Tidak Aktif
|
||||||
</Tabs.Tab>
|
</Tabs.Tab>
|
||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
:
|
||||||
|
<Tabs.List
|
||||||
|
bg={"white"}
|
||||||
|
style={{
|
||||||
|
border: `1px solid ${"#EDEDED"}`,
|
||||||
|
padding: 5,
|
||||||
|
borderRadius: 100,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="true"
|
||||||
|
w={"45%"}
|
||||||
|
leftSection={<IoFileTrayOutline style={iconStyle} />}
|
||||||
|
onClick={() => {
|
||||||
|
router.push("/division");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Divisi Saya
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="false"
|
||||||
|
w={"53%"}
|
||||||
|
leftSection={<IoFileTrayStackedOutline style={iconStyle} />}
|
||||||
|
onClick={() => {
|
||||||
|
router.push("/division?cat=semua");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Semua Divisi
|
||||||
|
</Tabs.Tab>
|
||||||
|
</Tabs.List>
|
||||||
: <></>
|
: <></>
|
||||||
}
|
}
|
||||||
<ListDivision />
|
<ListDivision />
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export default function ViewSearch() {
|
|||||||
c={tema.get().utama}
|
c={tema.get().utama}
|
||||||
truncate="end"
|
truncate="end"
|
||||||
>
|
>
|
||||||
{_.startCase(v.name)}
|
{_.upperFirst(v.name)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text fw={"lighter"} fz={12} truncate="end">
|
<Text fw={"lighter"} fz={12} truncate="end">
|
||||||
{v.group + " - " + v.position}
|
{v.group + " - " + v.position}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default function ListPositionActive() {
|
|||||||
placeholder="Pencarian"
|
placeholder="Pencarian"
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
/>
|
/>
|
||||||
{roleLogin.get() == 'supadmin' && <Text mt={10}>Filter by: {nameGroup}</Text>}
|
{roleLogin.get() == 'supadmin' && <Text mt={10}>Filter : {nameGroup}</Text>}
|
||||||
{loading ? Array(6).fill(null).map((_, i) => (
|
{loading ? Array(6).fill(null).map((_, i) => (
|
||||||
<Box key={i} mb={roleLogin.get() == 'supadmin' ? "20" : "0"} mt={roleLogin.get() == 'supadmin' ? "0" : "20"}>
|
<Box key={i} mb={roleLogin.get() == 'supadmin' ? "20" : "0"} mt={roleLogin.get() == 'supadmin' ? "0" : "20"}>
|
||||||
<Group
|
<Group
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ export default function AddMemberDetailProject() {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
const response = await funGetAllMemberById('?search=' + searchQuery, param.id)
|
const response = await funGetAllMemberById('?search=' + searchQuery, param.id)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data.member)
|
// setData(response.data.member)
|
||||||
|
setData(response.data.member.filter((i: any) => i.idUserRole != 'supadmin'))
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message)
|
toast.error(response.message)
|
||||||
}
|
}
|
||||||
@@ -243,7 +244,7 @@ export default function AddMemberDetailProject() {
|
|||||||
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada anggota</Text>
|
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada anggota</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
:
|
:
|
||||||
<Box mt={15} mb={100}>
|
<Box mt={100} mb={100}>
|
||||||
{isData.map((v, i) => {
|
{isData.map((v, i) => {
|
||||||
const isSelected = selectedFiles.some((i: any) => i?.idUser == v.idUser);
|
const isSelected = selectedFiles.some((i: any) => i?.idUser == v.idUser);
|
||||||
const found = isDataMember.some((i: any) => i.idUser == v.idUser)
|
const found = isDataMember.some((i: any) => i.idUser == v.idUser)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { LayoutNavbarNew, SkeletonList, TEMA } from '@/module/_global';
|
import { LayoutNavbarNew, SkeletonList, TEMA } from '@/module/_global';
|
||||||
import { funGetUserByCookies } from '@/module/auth';
|
|
||||||
import { funGetAllmember, TypeUser } from '@/module/user';
|
import { funGetAllmember, TypeUser } from '@/module/user';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { Carousel } from '@mantine/carousel';
|
import { Carousel } from '@mantine/carousel';
|
||||||
@@ -36,9 +35,10 @@ export default function CreateUsersProject({ grup, onClose }: { grup?: string, o
|
|||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await funGetAllmember('?active=true&group=' + grup + '&search=' + search);
|
const res = await funGetAllmember('?active=true&group=' + grup + '&search=' + search);
|
||||||
const user = await funGetUserByCookies();
|
// const user = await funGetUserByCookies();
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setDataMember(res.data.filter((i: any) => i.id != user.id && i.idUserRole != 'supadmin' && i.idUserRole != 'cosupadmin'))
|
// setDataMember(res.data.filter((i: any) => i.id != user.id && i.idUserRole != 'supadmin' && i.idUserRole != 'cosupadmin'))
|
||||||
|
setDataMember(res.data.filter((i: any) => i.idUserRole != 'supadmin'))
|
||||||
// cek data member sebelumnya
|
// cek data member sebelumnya
|
||||||
if (member.length > 0) {
|
if (member.length > 0) {
|
||||||
setSelectedFiles(JSON.parse(JSON.stringify(member.get())))
|
setSelectedFiles(JSON.parse(JSON.stringify(member.get())))
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default function ListProject() {
|
|||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const status = searchParams.get('status')
|
const status = searchParams.get('status')
|
||||||
const group = searchParams.get('group')
|
const group = searchParams.get('group')
|
||||||
|
const kategori = searchParams.get('cat')
|
||||||
const [searchQuery, setSearchQuery] = useState('')
|
const [searchQuery, setSearchQuery] = useState('')
|
||||||
const roleLogin = useHookstate(globalRole)
|
const roleLogin = useHookstate(globalRole)
|
||||||
const [nameGroup, setNameGroup] = useState('')
|
const [nameGroup, setNameGroup] = useState('')
|
||||||
@@ -43,7 +44,7 @@ export default function ListProject() {
|
|||||||
if (isPage == 1) {
|
if (isPage == 1) {
|
||||||
setData([])
|
setData([])
|
||||||
}
|
}
|
||||||
const response = await funGetAllProject('?status=' + status + '&search=' + searchQuery + '&group=' + group + '&page=' + isPage)
|
const response = await funGetAllProject('?status=' + status + '&search=' + searchQuery + '&group=' + group + '&page=' + isPage + '&cat=' + kategori);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setNameGroup(response.filter.name)
|
setNameGroup(response.filter.name)
|
||||||
setTotalData(response.total)
|
setTotalData(response.total)
|
||||||
@@ -67,7 +68,7 @@ export default function ListProject() {
|
|||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
fetchData(true);
|
fetchData(true);
|
||||||
}, [status, searchQuery]);
|
}, [status, searchQuery, kategori]);
|
||||||
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
@@ -152,7 +153,8 @@ export default function ListProject() {
|
|||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box pt={20}>
|
<Box pt={20}>
|
||||||
{roleLogin.get() == 'supadmin' && <Text mb={5}>Filter by: {nameGroup}</Text>}
|
{roleLogin.get() == 'supadmin' && <Text mb={5}>Filter : {nameGroup}</Text>}
|
||||||
|
{(roleLogin.get() == 'user' || roleLogin.get() == 'coadmin') && <Text mb={5}>Filter : {(kategori == null || kategori == undefined || kategori == '') ? 'Kegiatan Saya' : 'Semua Kegiatan'}</Text>}
|
||||||
<Box bg={tema.get().bgTotalKegiatan} p={10} style={{ borderRadius: 10 }}>
|
<Box bg={tema.get().bgTotalKegiatan} p={10} style={{ borderRadius: 10 }}>
|
||||||
<Text fw={'bold'} c={tema.get().utama}>Total Kegiatan</Text>
|
<Text fw={'bold'} c={tema.get().utama}>Total Kegiatan</Text>
|
||||||
<Flex justify={'center'} align={'center'} h={'100%'}>
|
<Flex justify={'center'} align={'center'} h={'100%'}>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { globalRole, TEMA, WARNA } from '@/module/_global';
|
import { globalRole, TEMA } from '@/module/_global';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
|
import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
|
||||||
import { useSearchParams } from 'next/navigation';
|
import { useSearchParams } from 'next/navigation';
|
||||||
import React, { useState } from 'react';
|
|
||||||
import { HiOutlineFilter } from 'react-icons/hi';
|
import { HiOutlineFilter } from 'react-icons/hi';
|
||||||
import { IoAddCircle } from 'react-icons/io5';
|
import { IoAddCircle } from 'react-icons/io5';
|
||||||
|
|
||||||
@@ -10,14 +9,15 @@ export default function MenuDrawerProject() {
|
|||||||
const roleLogin = useHookstate(globalRole)
|
const roleLogin = useHookstate(globalRole)
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const group = searchParams.get('group')
|
const group = searchParams.get('group')
|
||||||
|
const kategori = searchParams.get('cat')
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Stack pt={10}>
|
<Stack pt={10}>
|
||||||
<SimpleGrid
|
<SimpleGrid cols={{ base: 2, sm: 2, lg: 3 }} >
|
||||||
cols={{ base: 2, sm: 2, lg: 3 }}
|
{
|
||||||
>
|
(roleLogin.get() != "user" && roleLogin.get() != "coadmin") &&
|
||||||
<Flex onClick={() => window.location.href = "/project/create"} justify={'center'} align={'center'} direction={'column'} >
|
<Flex onClick={() => window.location.href = "/project/create"} justify={'center'} align={'center'} direction={'column'} >
|
||||||
<Box>
|
<Box>
|
||||||
<IoAddCircle size={30} color={tema.get().utama} />
|
<IoAddCircle size={30} color={tema.get().utama} />
|
||||||
@@ -26,6 +26,8 @@ export default function MenuDrawerProject() {
|
|||||||
<Text c={tema.get().utama}>Tambah Kegiatan</Text>
|
<Text c={tema.get().utama}>Tambah Kegiatan</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
roleLogin.get() == "supadmin" &&
|
roleLogin.get() == "supadmin" &&
|
||||||
<Flex onClick={() => window.location.href = "/project?page=filter&group=" + group} justify={'center'} align={'center'} direction={'column'} >
|
<Flex onClick={() => window.location.href = "/project?page=filter&group=" + group} justify={'center'} align={'center'} direction={'column'} >
|
||||||
@@ -37,6 +39,18 @@ export default function MenuDrawerProject() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
(roleLogin.get() == "user" || roleLogin.get() == "coadmin") &&
|
||||||
|
<Flex onClick={() => window.location.href = "/project?page=filter-data&cat=" + kategori} justify={'center'} align={'center'} direction={'column'} >
|
||||||
|
<Box>
|
||||||
|
<HiOutlineFilter size={30} color={tema.get().utama} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text c={tema.get().utama}>Filter</Text>
|
||||||
|
</Box>
|
||||||
|
</Flex>
|
||||||
|
}
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { globalRole, LayoutDrawer, LayoutNavbarNew, TEMA } from '@/module/_global';
|
import { LayoutDrawer, LayoutNavbarNew, TEMA } from '@/module/_global';
|
||||||
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { ActionIcon, Box, Button, Flex, rem } from '@mantine/core';
|
import { ActionIcon, Box, Button, Flex, rem } from '@mantine/core';
|
||||||
import React, { useState } from 'react';
|
|
||||||
import { HiMenu } from 'react-icons/hi';
|
|
||||||
import { RiProgress3Line } from "react-icons/ri";
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import { TbClockPause } from 'react-icons/tb';
|
import { useState } from 'react';
|
||||||
|
import { HiMenu } from 'react-icons/hi';
|
||||||
import { IoIosCheckmarkCircleOutline } from 'react-icons/io';
|
import { IoIosCheckmarkCircleOutline } from 'react-icons/io';
|
||||||
import { IoCloseCircleOutline } from 'react-icons/io5';
|
import { IoCloseCircleOutline } from 'react-icons/io5';
|
||||||
|
import { RiProgress3Line } from "react-icons/ri";
|
||||||
|
import { TbClockPause } from 'react-icons/tb';
|
||||||
import ListProject from './list_project';
|
import ListProject from './list_project';
|
||||||
import MenuDrawerProject from './menu_drawer_project';
|
import MenuDrawerProject from './menu_drawer_project';
|
||||||
import { useHookstate } from '@hookstate/core';
|
|
||||||
|
|
||||||
export default function TabProject() {
|
export default function TabProject() {
|
||||||
const [openDrawer, setOpenDrawer] = useState(false)
|
const [openDrawer, setOpenDrawer] = useState(false)
|
||||||
@@ -18,8 +18,8 @@ export default function TabProject() {
|
|||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const status = searchParams.get('status')
|
const status = searchParams.get('status')
|
||||||
const group = searchParams.get("group");
|
const group = searchParams.get("group");
|
||||||
|
const kategori = searchParams.get("cat");
|
||||||
const iconStyle = { width: rem(20), height: rem(20) };
|
const iconStyle = { width: rem(20), height: rem(20) };
|
||||||
const roleLogin = useHookstate(globalRole)
|
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
|
||||||
const dataStatus = [
|
const dataStatus = [
|
||||||
@@ -48,11 +48,10 @@ export default function TabProject() {
|
|||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<LayoutNavbarNew back='/home' title='Kegiatan'
|
<LayoutNavbarNew back='/home' title='Kegiatan'
|
||||||
menu={(roleLogin.get() != "user" && roleLogin.get() != "coadmin") ?
|
menu={
|
||||||
<ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
|
<ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||||
<HiMenu size={20} color='white' />
|
<HiMenu size={20} color='white' />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
: <></>
|
|
||||||
} />
|
} />
|
||||||
|
|
||||||
<Box p={20}>
|
<Box p={20}>
|
||||||
@@ -76,7 +75,7 @@ export default function TabProject() {
|
|||||||
: (status == null && item.id == "0") ? "white" : tema.get().utama
|
: (status == null && item.id == "0") ? "white" : tema.get().utama
|
||||||
}
|
}
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => { router.push("?status=" + item.id + "&group=" + group) }}
|
onClick={() => { router.push("?status=" + item.id + "&group=" + group+"&cat="+kategori) }}
|
||||||
defaultValue={(status == "1" || status == "2" || status == "3") ? status : "0"}
|
defaultValue={(status == "1" || status == "2" || status == "3") ? status : "0"}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
bg={
|
bg={
|
||||||
@@ -92,7 +91,6 @@ export default function TabProject() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
<ListProject />
|
<ListProject />
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ export default function CreateMember() {
|
|||||||
nilai = false
|
nilai = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listData.phone == "" || !(listData.phone.length >= 10 && listData.phone.length <= 15)) {
|
if (listData.phone == "" || !(listData.phone.length >= 9 && listData.phone.length <= 15)) {
|
||||||
setTouched(touched => ({ ...touched, phone: true }))
|
setTouched(touched => ({ ...touched, phone: true }))
|
||||||
nilai = false
|
nilai = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export default function EditMember({ id }: { id: string }) {
|
|||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const roleLogin = useHookstate(globalRole)
|
const roleLogin = useHookstate(globalRole)
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const [loadingPosition, setLoadingPosition] = useState(true)
|
||||||
const [touched, setTouched] = useState({
|
const [touched, setTouched] = useState({
|
||||||
nik: false,
|
nik: false,
|
||||||
name: false,
|
name: false,
|
||||||
@@ -83,6 +84,7 @@ export default function EditMember({ id }: { id: string }) {
|
|||||||
|
|
||||||
async function getAllPosition(val: any) {
|
async function getAllPosition(val: any) {
|
||||||
try {
|
try {
|
||||||
|
setLoadingPosition(true)
|
||||||
const res = await funGetAllPosition(
|
const res = await funGetAllPosition(
|
||||||
"?active=true" + "&group=" + `${val}`
|
"?active=true" + "&group=" + `${val}`
|
||||||
);
|
);
|
||||||
@@ -90,6 +92,8 @@ export default function EditMember({ id }: { id: string }) {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoadingPosition(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +159,7 @@ export default function EditMember({ id }: { id: string }) {
|
|||||||
}
|
}
|
||||||
} else if (kategori == 'phone') {
|
} else if (kategori == 'phone') {
|
||||||
setData({ ...data, phone: val })
|
setData({ ...data, phone: val })
|
||||||
if (val == "" || !(val.length >= 10 && val.length <= 15)) {
|
if (val == "" || !(val.length >= 9 && val.length <= 15)) {
|
||||||
setTouched({ ...touched, phone: true })
|
setTouched({ ...touched, phone: true })
|
||||||
} else {
|
} else {
|
||||||
setTouched({ ...touched, phone: false })
|
setTouched({ ...touched, phone: false })
|
||||||
@@ -233,19 +237,14 @@ export default function EditMember({ id }: { id: string }) {
|
|||||||
</Indicator>
|
</Indicator>
|
||||||
}
|
}
|
||||||
{loading ?
|
{loading ?
|
||||||
<>
|
[...Array(6)].map((_, index) => (
|
||||||
<Skeleton height={40} mt={20} radius={30} />
|
<Skeleton key={index} height={40} mt={20} radius={30} />
|
||||||
<Skeleton height={40} mt={10} radius={30} />
|
))
|
||||||
<Skeleton height={40} mt={10} radius={30} />
|
|
||||||
<Skeleton height={40} mt={10} radius={30} />
|
|
||||||
<Skeleton height={40} mt={10} radius={30} />
|
|
||||||
<Skeleton height={40} mt={10} radius={30} />
|
|
||||||
<Skeleton height={40} mt={10} radius={30} />
|
|
||||||
</>
|
|
||||||
:
|
:
|
||||||
<>
|
<>
|
||||||
<Select
|
<Select
|
||||||
placeholder="Pilih Jabatan" label="Jabatan" w={"100%"} size="md" required withAsterisk radius={30}
|
placeholder={loadingPosition ? "Loading.. " : "Pilih Jabatan"}
|
||||||
|
label="Jabatan" w={"100%"} size="md" required withAsterisk radius={30}
|
||||||
styles={{
|
styles={{
|
||||||
input: {
|
input: {
|
||||||
color: tema.get().utama,
|
color: tema.get().utama,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { HiMagnifyingGlass } from "react-icons/hi2"
|
|||||||
import { useWibuRealtime } from "wibu-realtime"
|
import { useWibuRealtime } from "wibu-realtime"
|
||||||
import { funGetAllmember } from "../lib/api_member"
|
import { funGetAllmember } from "../lib/api_member"
|
||||||
import { IListMember } from "../lib/type_member"
|
import { IListMember } from "../lib/type_member"
|
||||||
|
import { funGetUserByCookies } from "@/module/auth"
|
||||||
|
|
||||||
|
|
||||||
export default function TabListMember() {
|
export default function TabListMember() {
|
||||||
@@ -32,16 +33,18 @@ export default function TabListMember() {
|
|||||||
project: "sdm"
|
project: "sdm"
|
||||||
})
|
})
|
||||||
const [isRefresh, setRefresh] = useState(false)
|
const [isRefresh, setRefresh] = useState(false)
|
||||||
|
const [userLogin, setUserLogin] = useState<any>('')
|
||||||
|
|
||||||
|
|
||||||
async function getAllUser(loading: boolean) {
|
async function getAllUser(loading: boolean) {
|
||||||
try {
|
try {
|
||||||
if (loading)
|
setLoading(loading)
|
||||||
setLoading(true)
|
|
||||||
const res = await funGetAllmember('?active=' + status + '&group=' + group + '&search=' + searchQuery + '&page=' + isPage)
|
const res = await funGetAllmember('?active=' + status + '&group=' + group + '&search=' + searchQuery + '&page=' + isPage)
|
||||||
|
const user = await funGetUserByCookies()
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setNameGroup(res.filter.name)
|
setNameGroup(res.filter.name)
|
||||||
setIdGroup(res.filter.id)
|
setIdGroup(res.filter.id)
|
||||||
|
setUserLogin(user.id)
|
||||||
if (isPage == 1) {
|
if (isPage == 1) {
|
||||||
setDataMember(res.data)
|
setDataMember(res.data)
|
||||||
} else {
|
} else {
|
||||||
@@ -128,7 +131,7 @@ export default function TabListMember() {
|
|||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
my={20}
|
my={20}
|
||||||
/>
|
/>
|
||||||
{roleLogin.get() == 'supadmin' && <Text mt={10}>Filter by: {nameGroup}</Text>}
|
{roleLogin.get() == 'supadmin' && <Text mt={10}>Filter : {nameGroup}</Text>}
|
||||||
{loading
|
{loading
|
||||||
?
|
?
|
||||||
Array(6)
|
Array(6)
|
||||||
@@ -148,9 +151,7 @@ export default function TabListMember() {
|
|||||||
dataMember.map((v, i) => {
|
dataMember.map((v, i) => {
|
||||||
return (
|
return (
|
||||||
<Box my={10} key={i}>
|
<Box my={10} key={i}>
|
||||||
<Box onClick={() => {
|
<Box onClick={() => { userLogin == v.id ? router.push(`/profile`) : router.push(`/member/${v.id}`) }}>
|
||||||
router.push(`/member/${v.id}`)
|
|
||||||
}}>
|
|
||||||
<Grid p={5} align="center">
|
<Grid p={5} align="center">
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
span={{
|
span={{
|
||||||
@@ -174,7 +175,7 @@ export default function TabListMember() {
|
|||||||
xl: 11,
|
xl: 11,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text fw={'bold'} pl={isMobile2 ? 40 : 30} c={tema.get().utama} lineClamp={1}>{_.startCase(v.name)}</Text>
|
<Text fw={'bold'} pl={isMobile2 ? 40 : 30} c={tema.get().utama} lineClamp={1}>{_.upperFirst(v.name)}</Text>
|
||||||
<Text fw={'lighter'} pl={isMobile2 ? 40 : 30} fz={12}>{v.group + ' - ' + v.position}</Text>
|
<Text fw={'lighter'} pl={isMobile2 ? 40 : 30} fz={12}>{v.group + ' - ' + v.position}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -18,5 +18,6 @@ export interface IEditDataProfile {
|
|||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
gender: string;
|
gender: string;
|
||||||
|
idPosition: string;
|
||||||
img: string;
|
img: string;
|
||||||
}
|
}
|
||||||
@@ -12,10 +12,13 @@ import toast from "react-hot-toast";
|
|||||||
import { FaCamera } from "react-icons/fa6";
|
import { FaCamera } from "react-icons/fa6";
|
||||||
import { funEditProfileByCookies, funGetProfileByCookies, } from "../lib/api_profile";
|
import { funEditProfileByCookies, funGetProfileByCookies, } from "../lib/api_profile";
|
||||||
import { IEditDataProfile, IProfileById } from "../lib/type_profile";
|
import { IEditDataProfile, IProfileById } from "../lib/type_profile";
|
||||||
|
import { IDataPositionMember } from "../../member/lib/type_member";
|
||||||
|
import { funGetAllPosition } from "@/module/position/lib/api_position";
|
||||||
|
|
||||||
export default function EditProfile() {
|
export default function EditProfile() {
|
||||||
const [isValModal, setValModal] = useState(false);
|
const [isValModal, setValModal] = useState(false);
|
||||||
const [isDataEdit, setDataEdit] = useState<IProfileById[]>([]);
|
const [isDataEdit, setDataEdit] = useState<IProfileById[]>([]);
|
||||||
|
const [listPosition, setListPosition] = useState<IDataPositionMember[]>([])
|
||||||
const openRef = useRef<() => void>(null);
|
const openRef = useRef<() => void>(null);
|
||||||
const [img, setIMG] = useState<any | null>();
|
const [img, setIMG] = useState<any | null>();
|
||||||
const [imgForm, setImgForm] = useState<any>();
|
const [imgForm, setImgForm] = useState<any>();
|
||||||
@@ -23,6 +26,7 @@ export default function EditProfile() {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const tema = useHookstate(TEMA);
|
const tema = useHookstate(TEMA);
|
||||||
const [loadingKonfirmasi, setLoadingKonfirmasi] = useState(false);
|
const [loadingKonfirmasi, setLoadingKonfirmasi] = useState(false);
|
||||||
|
const [loadingPosition, setLoadingPosition] = useState(true)
|
||||||
|
|
||||||
const [touched, setTouched] = useState({
|
const [touched, setTouched] = useState({
|
||||||
nik: false,
|
nik: false,
|
||||||
@@ -30,6 +34,7 @@ export default function EditProfile() {
|
|||||||
phone: false,
|
phone: false,
|
||||||
email: false,
|
email: false,
|
||||||
gender: false,
|
gender: false,
|
||||||
|
idPosition: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const [data, setData] = useState<IEditDataProfile>({
|
const [data, setData] = useState<IEditDataProfile>({
|
||||||
@@ -40,13 +45,30 @@ export default function EditProfile() {
|
|||||||
email: "",
|
email: "",
|
||||||
gender: "",
|
gender: "",
|
||||||
img: "",
|
img: "",
|
||||||
|
idPosition: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function getAllPosition(val: any) {
|
||||||
|
try {
|
||||||
|
setLoadingPosition(true)
|
||||||
|
const res = await funGetAllPosition(
|
||||||
|
"?active=true" + "&group=" + `${val}`
|
||||||
|
);
|
||||||
|
setListPosition(res.data);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoadingPosition(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getAllProfile() {
|
async function getAllProfile() {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const res = await funGetProfileByCookies();
|
const res = await funGetProfileByCookies();
|
||||||
setData(res.data);
|
setData(res.data);
|
||||||
|
getAllPosition(res.data.idGroup);
|
||||||
setIMG(`https://wibu-storage.wibudev.com/api/files/${res.data.img}`);
|
setIMG(`https://wibu-storage.wibudev.com/api/files/${res.data.img}`);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -111,7 +133,7 @@ export default function EditProfile() {
|
|||||||
}
|
}
|
||||||
} else if (kategori == 'phone') {
|
} else if (kategori == 'phone') {
|
||||||
setData({ ...data, phone: val })
|
setData({ ...data, phone: val })
|
||||||
if (val == "" || !(val.length >= 10 && val.length <= 15)) {
|
if (val == "" || !(val.length >= 9 && val.length <= 15)) {
|
||||||
setTouched({ ...touched, phone: true })
|
setTouched({ ...touched, phone: true })
|
||||||
} else {
|
} else {
|
||||||
setTouched({ ...touched, phone: false })
|
setTouched({ ...touched, phone: false })
|
||||||
@@ -130,6 +152,13 @@ export default function EditProfile() {
|
|||||||
} else {
|
} else {
|
||||||
setTouched({ ...touched, gender: false })
|
setTouched({ ...touched, gender: false })
|
||||||
}
|
}
|
||||||
|
} else if (kategori == 'idPosition') {
|
||||||
|
setData({ ...data, idPosition: val })
|
||||||
|
if (val == "" || String(val) == "null") {
|
||||||
|
setTouched({ ...touched, idPosition: true })
|
||||||
|
} else {
|
||||||
|
setTouched({ ...touched, idPosition: false })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,16 +210,38 @@ export default function EditProfile() {
|
|||||||
/>
|
/>
|
||||||
</Indicator>
|
</Indicator>
|
||||||
)}
|
)}
|
||||||
{loading ? (
|
{loading ?
|
||||||
<>
|
[...Array(6)].map((_, index) => (
|
||||||
<Skeleton height={40} mt={20} radius={10} />
|
<Skeleton key={index} height={40} mt={20} radius={10} />
|
||||||
<Skeleton height={40} mt={20} radius={10} />
|
))
|
||||||
<Skeleton height={40} mt={20} radius={10} />
|
: (
|
||||||
<Skeleton height={40} mt={20} radius={10} />
|
|
||||||
<Skeleton height={40} mt={20} radius={10} />
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
<>
|
||||||
|
<Select
|
||||||
|
placeholder={loadingPosition ? "Loading.. " : "Pilih Jabatan"}
|
||||||
|
label="Jabatan" w={"100%"} size="md" required withAsterisk radius={10}
|
||||||
|
styles={{
|
||||||
|
input: {
|
||||||
|
color: tema.get().utama,
|
||||||
|
borderRadius: tema.get().utama,
|
||||||
|
borderColor: tema.get().utama,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
data={
|
||||||
|
listPosition
|
||||||
|
? listPosition.map((data) => ({
|
||||||
|
value: data.id,
|
||||||
|
label: data.name,
|
||||||
|
}))
|
||||||
|
: []
|
||||||
|
}
|
||||||
|
onChange={(val: any) => { onValidation('idPosition', val) }}
|
||||||
|
value={(data?.idPosition == "") ? null : data.idPosition}
|
||||||
|
error={
|
||||||
|
touched.idPosition && (
|
||||||
|
data.idPosition == "" || String(data.idPosition) == "null" ? "Jabatan Tidak Boleh Kosong" : null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
size="md"
|
size="md"
|
||||||
type="number"
|
type="number"
|
||||||
@@ -288,7 +339,7 @@ export default function EditProfile() {
|
|||||||
error={
|
error={
|
||||||
touched.phone &&
|
touched.phone &&
|
||||||
(data.phone == "" ? "Nomor Telepon Tidak Boleh Kosong"
|
(data.phone == "" ? "Nomor Telepon Tidak Boleh Kosong"
|
||||||
: !(data.phone.length >= 10 && data.phone.length <= 15) ? "Nomor Telepon Tidak Valid" : null)
|
: !(data.phone.length >= 9 && data.phone.length <= 15) ? "Nomor Telepon Tidak Valid" : null)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
Reference in New Issue
Block a user