upd: announcement

Deskripsi:
- pagination scrooll load

No Issues
This commit is contained in:
amel
2024-09-19 11:37:41 +08:00
parent 4026c58e8f
commit f8ca866cc6
6 changed files with 116 additions and 22 deletions

View File

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

View File

@@ -24,6 +24,8 @@ export async function GET(request: Request) {
const groupId = user.idGroup
const { searchParams } = new URL(request.url);
const name = searchParams.get('search');
const page = searchParams.get('page');
const dataSkip = Number(page) * 10 - 10;
let kondisi: any = {
idVillage: String(villageId),
@@ -76,6 +78,8 @@ export async function GET(request: Request) {
const announcements = await prisma.announcement.findMany({
skip: dataSkip,
take: 10,
where: kondisi,
select: {
id: true,
@@ -128,7 +132,8 @@ export async function POST(request: Request) {
let memberDivision = []
for (var i = 0, l = groups.length; i < l; i++) {2
for (var i = 0, l = groups.length; i < l; i++) {
2
var obj = groups[i].Division;
for (let index = 0; index < obj.length; index++) {
const element = obj[index];