fix: onscrool page notifikasi
This commit is contained in:
@@ -1,27 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { currentScroll, TEMA, WARNA } from "@/module/_global";
|
import { currentScroll, TEMA } from "@/module/_global";
|
||||||
import { useHookstate } from "@hookstate/core";
|
import { useHookstate } from "@hookstate/core";
|
||||||
import {
|
import { ActionIcon, Box, Grid, Skeleton, Spoiler, Text } from "@mantine/core";
|
||||||
ActionIcon,
|
|
||||||
Box,
|
|
||||||
Center,
|
|
||||||
Flex,
|
|
||||||
Grid,
|
|
||||||
Group,
|
|
||||||
Skeleton,
|
|
||||||
Spoiler,
|
|
||||||
Text,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
|
import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import React, { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { FaBell } from "react-icons/fa6";
|
|
||||||
import { IListNotification } from "../lib/type_notification";
|
|
||||||
import {
|
|
||||||
funGetAllNotification,
|
|
||||||
funReadNotification,
|
|
||||||
} from "../lib/api_notification";
|
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
import { FaBell } from "react-icons/fa6";
|
||||||
|
import { funGetAllNotification, funReadNotification, } from "../lib/api_notification";
|
||||||
|
import { IListNotification } from "../lib/type_notification";
|
||||||
|
|
||||||
export default function ListNotification() {
|
export default function ListNotification() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -69,7 +56,7 @@ export default function ListNotification() {
|
|||||||
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 + 1 >= scrollHeight) {
|
||||||
setPage(isPage + 1);
|
setPage(isPage + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,11 +69,7 @@ export default function ListNotification() {
|
|||||||
};
|
};
|
||||||
}, [containerRef, isPage]);
|
}, [containerRef, isPage]);
|
||||||
|
|
||||||
async function onReadNotif(
|
async function onReadNotif(category: string, idContent: string, idData: string) {
|
||||||
category: string,
|
|
||||||
idContent: string,
|
|
||||||
idData: string
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
const response = await funReadNotification({ id: idData });
|
const response = await funReadNotification({ id: idData });
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -235,7 +218,7 @@ export default function ListNotification() {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{}
|
{ }
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user