feat : update scroll and style

Deskripsi:
- update api
- update globle
- update project
- update user
- update profile

No Issue
This commit is contained in:
lukman
2024-09-19 13:41:04 +08:00
parent fe5155ee37
commit 6626f92ff1
7 changed files with 70 additions and 11 deletions

View File

@@ -14,6 +14,8 @@ export async function GET(request: Request) {
const name = searchParams.get('search') const name = searchParams.get('search')
const idGroup = searchParams.get("group"); const idGroup = searchParams.get("group");
const active = searchParams.get("active"); const active = searchParams.get("active");
const page = searchParams.get('page');
const dataSkip = Number(page) * 5 - 5;
const user = await funGetUserByCookies() const user = await funGetUserByCookies()
if (user.id == undefined) { if (user.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 });
@@ -36,6 +38,8 @@ export async function GET(request: Request) {
const users = await prisma.user.findMany({ const users = await prisma.user.findMany({
skip: dataSkip,
take: 5,
where: { where: {
isActive: active == 'false' ? false : true, isActive: active == 'false' ? false : true,
idGroup: String(fixGroup), idGroup: String(fixGroup),

View File

@@ -36,7 +36,7 @@ export default function ReloadButtonTop({ onReload, title }: { onReload: () => v
style={{ style={{
...state, ...state,
zIndex: 999, zIndex: 999,
position: 'absolute', position: 'fixed',
top: 90, top: 90,
display: 'flex', display: 'flex',
justifyContent: 'center', justifyContent: 'center',

View File

@@ -171,9 +171,13 @@ export default function ListTugasDetailProject() {
<Box> <Box>
<Stack pt={10}> <Stack pt={10}>
<SimpleGrid <SimpleGrid
cols={{ base: 3, sm: 3, lg: 3 }} cols={{ base: 2, sm: 3, lg: 3 }}
style={{
alignContent: 'flex-start',
alignItems: 'flex-start',
}}
> >
<Flex onClick={() => { setOpenDrawerStatus(true) }} justify={'center'} align={'center'} direction={'column'} > <Flex onClick={() => { setOpenDrawerStatus(true) }} justify={'center'} align={'center'} direction={'column'} pb={20}>
<Box> <Box>
<AiOutlineFileDone size={30} color={tema.get().utama} /> <AiOutlineFileDone size={30} color={tema.get().utama} />
</Box> </Box>

View File

@@ -59,6 +59,10 @@ export default function NavbarDetailProject() {
<Stack pt={10}> <Stack pt={10}>
<SimpleGrid <SimpleGrid
cols={{ base: 3, sm: 3, lg: 3 }} cols={{ base: 3, sm: 3, lg: 3 }}
style={{
alignContent: 'flex-start',
alignItems: 'flex-start',
}}
> >
<Flex justify={'center'} align={'center'} direction={'column'} <Flex justify={'center'} align={'center'} direction={'column'}
style={{ style={{
@@ -67,6 +71,7 @@ export default function NavbarDetailProject() {
onClick={() => { onClick={() => {
router.push(param.id + '/add-task') router.push(param.id + '/add-task')
}} }}
pb={20}
> >
<Box> <Box>
<IoAddCircle size={30} color={tema.get().utama} /> <IoAddCircle size={30} color={tema.get().utama} />

View File

@@ -178,6 +178,9 @@ export default function EditMember({ id }: { id: string }) {
size="150" size="150"
radius={"100"} radius={"100"}
src={img} src={img}
style={{
border: `1px solid ${"#C1BFBFFF"}`
}}
/> />
</Indicator> </Indicator>
} }

View File

@@ -1,9 +1,9 @@
import { globalRole, SkeletonSingle, TEMA, WARNA } from "@/module/_global" import { currentScroll, globalRole, SkeletonSingle, TEMA, WARNA } from "@/module/_global"
import { Box, Text, TextInput, Divider, Avatar, Grid } from "@mantine/core" import { Box, Text, TextInput, Divider, Avatar, Grid } from "@mantine/core"
import { useShallowEffect } from "@mantine/hooks" import { useShallowEffect } from "@mantine/hooks"
import { useRouter, useSearchParams } from "next/navigation" import { useRouter, useSearchParams } from "next/navigation"
import { useState } from "react" import { useEffect, useState } from "react"
import { HiMagnifyingGlass } from "react-icons/hi2" import { HiMagnifyingGlass } from "react-icons/hi2"
import { IListMember } from "../lib/type_member" import { IListMember } from "../lib/type_member"
import { funGetAllmember } from "../lib/api_member" import { funGetAllmember } from "../lib/api_member"
@@ -25,14 +25,24 @@ export default function TabListMember() {
const [nameGroup, setNameGroup] = useState('') const [nameGroup, setNameGroup] = useState('')
const tema = useHookstate(TEMA) const tema = useHookstate(TEMA)
//scroll
const { value: containerRef } = useHookstate(currentScroll);
const [isPage, setPage] = useState(1)
async function getAllUser() {
async function getAllUser(loading: boolean) {
try { try {
setLoading(true) setLoading(true)
const res = await funGetAllmember('?active=' + status + '&group=' + group + '&search=' + searchQuery) const res = await funGetAllmember('?active=' + status + '&group=' + group + '&search=' + searchQuery + '&page=' + isPage)
if (res.success) { if (res.success) {
setDataMember(res.data) if (isPage == 1) {
setNameGroup(res.filter.name) setDataMember(res.data)
setNameGroup(res.filter.name)
} else {
setDataMember([...dataMember, ...res.data])
setNameGroup(res.filter.name)
}
} else { } else {
toast.error(res.message) toast.error(res.message)
} }
@@ -44,10 +54,40 @@ export default function TabListMember() {
} }
} }
function onSearch(val:string){
setSearchQuery(val)
setPage(1)
}
useShallowEffect(() => { useShallowEffect(() => {
getAllUser() getAllUser(true)
}, [status, searchQuery]) }, [status, searchQuery])
useShallowEffect(() => {
getAllUser(false)
}, [status, isPage])
useEffect(() => {
const handleScroll = async () => {
if (containerRef && containerRef.current) {
const scrollTop = containerRef.current.scrollTop;
const containerHeight = containerRef.current.clientHeight;
const scrollHeight = containerRef.current.scrollHeight;
if (scrollTop + containerHeight >= scrollHeight) {
setPage(isPage + 1)
}
}
};
const container = containerRef?.current;
container?.addEventListener("scroll", handleScroll);
return () => {
container?.removeEventListener("scroll", handleScroll);
};
}, [containerRef, isPage]);
return ( return (
<> <>
<Box> <Box>
@@ -63,7 +103,7 @@ export default function TabListMember() {
radius={30} radius={30}
leftSection={<HiMagnifyingGlass size={20} />} leftSection={<HiMagnifyingGlass size={20} />}
placeholder="Pencarian" placeholder="Pencarian"
onChange={(e) => setSearchQuery(e.target.value)} onChange={(e) => onSearch(e.target.value)}
my={10} my={10}
/> />
{loading {loading

View File

@@ -120,6 +120,9 @@ export default function EditProfile() {
size="150" size="150"
radius={"100"} radius={"100"}
src={img} src={img}
style={{
border: `1px solid ${"#C1BFBFFF"}`
}}
/> />
</Indicator> </Indicator>
} }