tambahan
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
import apiFetch from "@/lib/apiFetch";
|
||||
import { Card, Pagination, Skeleton, Stack, Text, Title } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import useSWR from "swr";
|
||||
import { useLocalStorage, useShallowEffect } from "@mantine/hooks";
|
||||
import dayjs from "dayjs";
|
||||
import { useLocalStorage } from "@mantine/hooks";
|
||||
import { useState } from "react";
|
||||
import useSWR from "swr";
|
||||
|
||||
export default function WaHookHome() {
|
||||
const [page, setPage] = useLocalStorage({
|
||||
key: "wa-hook-page",
|
||||
defaultValue: 1,
|
||||
})
|
||||
const [totalPages, setTotalPages] = useState(1);
|
||||
const { data, error, isLoading, mutate } = useSWR("/wa-hook",() => apiFetch["wa-hook"].list.get({ query: { page, limit: 10 } }), {
|
||||
refreshInterval: 3000,
|
||||
revalidateOnFocus: true,
|
||||
@@ -25,7 +22,6 @@ export default function WaHookHome() {
|
||||
useShallowEffect(() => {
|
||||
mutate()
|
||||
setPage(data?.data?.list?.length || 1)
|
||||
setTotalPages(data?.data?.count || 1)
|
||||
}, [])
|
||||
|
||||
if (isLoading) return <Skeleton height={500} />
|
||||
@@ -48,7 +44,7 @@ export default function WaHookHome() {
|
||||
))}
|
||||
<Pagination
|
||||
value={page}
|
||||
total={totalPages}
|
||||
total={data?.data?.count || 1}
|
||||
onChange={setPage}
|
||||
withEdges
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user