upd: scroll

This commit is contained in:
amel
2024-09-19 16:07:45 +08:00
parent 0459bb3656
commit da3f604855
3 changed files with 12 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import { ScrollProvider, WrapLayout } from "@/module/_global"
import { WrapLayout } from "@/module/_global"
import { funDetectCookies, funGetUserByCookies } from "@/module/auth"
import _ from "lodash"
import { redirect } from "next/navigation"
@@ -11,9 +11,7 @@ export default async function Layout({ children }: { children: React.ReactNode }
return (
<>
<WrapLayout role={user.idUserRole} theme={user.theme} user={user.id}>
<ScrollProvider>
{children}
</ScrollProvider>
{children}
</WrapLayout>
</>
);

View File

@@ -6,7 +6,7 @@ import {
MantineProvider,
rem,
} from "@mantine/core";
import { WARNA } from "@/module/_global";
import { ScrollProvider, WARNA } from "@/module/_global";
import { Lato } from "next/font/google";
import '@mantine/carousel/styles.css';
import { Toaster } from 'react-hot-toast';
@@ -33,20 +33,23 @@ export default function RootLayout({
return (
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<ColorSchemeScript />
</head>
<body className={`${LatoFont.className}`} suppressHydrationWarning>
<MantineProvider>
<Notifications />
<Notifications />
<Box bg={'#252A2F'} pos={"fixed"} w={"100%"} h={"100%"} style={{
overflowY: "auto",
}}>
<Toaster/>
<LayoutBackground>
{children}
</LayoutBackground>
<Toaster />
<ScrollProvider>
<LayoutBackground>
{children}
</LayoutBackground>
</ScrollProvider>
</Box>
</MantineProvider>
</body>
</html>

View File

@@ -31,13 +31,11 @@ export default function ListAnnouncement() {
setLoading(true)
const response = await funGetAllAnnouncement('?search=' + searchQuery + '&page=' + isPage)
if (response.success) {
// if (response.data.length > 0) {
if (isPage == 1) {
setIsData(response?.data)
} else {
setIsData([...isData, ...response?.data])
}
// }
} else {
toast.error(response.message);
}
@@ -79,7 +77,6 @@ export default function ListAnnouncement() {
const scrollTop = containerRef.current.scrollTop;
const containerHeight = containerRef.current.clientHeight;
const scrollHeight = containerRef.current.scrollHeight;
if (scrollTop + containerHeight >= scrollHeight) {
setPage(isPage + 1)
}