upd: scroll
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ScrollProvider, WrapLayout } from "@/module/_global"
|
import { WrapLayout } from "@/module/_global"
|
||||||
import { funDetectCookies, funGetUserByCookies } from "@/module/auth"
|
import { funDetectCookies, funGetUserByCookies } from "@/module/auth"
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
import { redirect } from "next/navigation"
|
import { redirect } from "next/navigation"
|
||||||
@@ -11,9 +11,7 @@ export default async function Layout({ children }: { children: React.ReactNode }
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WrapLayout role={user.idUserRole} theme={user.theme} user={user.id}>
|
<WrapLayout role={user.idUserRole} theme={user.theme} user={user.id}>
|
||||||
<ScrollProvider>
|
{children}
|
||||||
{children}
|
|
||||||
</ScrollProvider>
|
|
||||||
</WrapLayout>
|
</WrapLayout>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
MantineProvider,
|
MantineProvider,
|
||||||
rem,
|
rem,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { WARNA } from "@/module/_global";
|
import { ScrollProvider, WARNA } from "@/module/_global";
|
||||||
import { Lato } from "next/font/google";
|
import { Lato } from "next/font/google";
|
||||||
import '@mantine/carousel/styles.css';
|
import '@mantine/carousel/styles.css';
|
||||||
import { Toaster } from 'react-hot-toast';
|
import { Toaster } from 'react-hot-toast';
|
||||||
@@ -33,20 +33,23 @@ export default function RootLayout({
|
|||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<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 />
|
<ColorSchemeScript />
|
||||||
</head>
|
</head>
|
||||||
<body className={`${LatoFont.className}`} suppressHydrationWarning>
|
<body className={`${LatoFont.className}`} suppressHydrationWarning>
|
||||||
<MantineProvider>
|
<MantineProvider>
|
||||||
<Notifications />
|
<Notifications />
|
||||||
<Box bg={'#252A2F'} pos={"fixed"} w={"100%"} h={"100%"} style={{
|
<Box bg={'#252A2F'} pos={"fixed"} w={"100%"} h={"100%"} style={{
|
||||||
overflowY: "auto",
|
overflowY: "auto",
|
||||||
}}>
|
}}>
|
||||||
<Toaster/>
|
<Toaster />
|
||||||
<LayoutBackground>
|
<ScrollProvider>
|
||||||
{children}
|
<LayoutBackground>
|
||||||
</LayoutBackground>
|
{children}
|
||||||
|
</LayoutBackground>
|
||||||
|
</ScrollProvider>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
</MantineProvider>
|
</MantineProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -31,13 +31,11 @@ export default function ListAnnouncement() {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
const response = await funGetAllAnnouncement('?search=' + searchQuery + '&page=' + isPage)
|
const response = await funGetAllAnnouncement('?search=' + searchQuery + '&page=' + isPage)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
// if (response.data.length > 0) {
|
|
||||||
if (isPage == 1) {
|
if (isPage == 1) {
|
||||||
setIsData(response?.data)
|
setIsData(response?.data)
|
||||||
} else {
|
} else {
|
||||||
setIsData([...isData, ...response?.data])
|
setIsData([...isData, ...response?.data])
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message);
|
toast.error(response.message);
|
||||||
}
|
}
|
||||||
@@ -79,7 +77,6 @@ export default function ListAnnouncement() {
|
|||||||
const scrollTop = containerRef.current.scrollTop;
|
const scrollTop = containerRef.current.scrollTop;
|
||||||
const containerHeight = containerRef.current.clientHeight;
|
const containerHeight = containerRef.current.clientHeight;
|
||||||
const scrollHeight = containerRef.current.scrollHeight;
|
const scrollHeight = containerRef.current.scrollHeight;
|
||||||
|
|
||||||
if (scrollTop + containerHeight >= scrollHeight) {
|
if (scrollTop + containerHeight >= scrollHeight) {
|
||||||
setPage(isPage + 1)
|
setPage(isPage + 1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user