fixup pagenation error

This commit is contained in:
oiov
2025-05-09 10:13:15 +08:00
parent 46730b9c3f
commit 4f12de115d
4 changed files with 19 additions and 10 deletions
+5 -1
View File
@@ -47,6 +47,8 @@ const getLogsUrl = (
const LogsTable = ({ userId, target }) => {
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(20);
const [filters, setFilters] = useState({
type: "",
ip: "",
@@ -195,11 +197,13 @@ const LogsTable = ({ userId, target }) => {
<p className="ml-auto text-nowrap text-sm">
{nFormatter(data?.total || 0)} logs
</p>
{data && Math.ceil(data.total / 20) > 1 && (
{data && Math.ceil(data.total / pageSize) > 1 && (
<PaginationWrapper
total={data.total}
currentPage={page}
setCurrentPage={setPage}
pageSize={pageSize}
setPageSize={setPageSize}
layout="right"
/>
)}
+8 -6
View File
@@ -18,7 +18,7 @@ import { siteConfig } from "@/config/site";
import { TeamPlanQuota } from "@/config/team";
import { UserEmailList } from "@/lib/dto/email";
import { reservedAddressSuffix } from "@/lib/enums";
import { cn, fetcher, timeAgo } from "@/lib/utils";
import { cn, fetcher, nFormatter, timeAgo } from "@/lib/utils";
import { useMediaQuery } from "@/hooks/use-media-query";
import ApiReference from "@/app/emails/api-reference";
@@ -88,7 +88,7 @@ export default function EmailSidebar({
const [showSendsModal, setShowSendsModal] = useState(false);
const pageSize = 10;
const [pageSize, setPageSize] = useState(10);
const { data, isLoading, error, mutate } = useSWR<{
list: UserEmailList[];
@@ -309,7 +309,7 @@ export default function EmailSidebar({
</p>
</div>
<p className="text-sm font-semibold text-gray-900 dark:text-gray-100">
<CountUp count={data ? data.total : 0} />
{nFormatter(data ? data.total : 0)}
</p>
</div>
@@ -322,7 +322,7 @@ export default function EmailSidebar({
</p>
</div>
<p className="text-sm font-semibold text-gray-900 dark:text-gray-100">
<CountUp count={data ? data.totalInboxCount : 0} />
{nFormatter(data ? data.totalInboxCount : 0)}
</p>
</div>
@@ -345,7 +345,7 @@ export default function EmailSidebar({
</p>
</div>
<p className="text-sm font-semibold text-gray-900 dark:text-gray-100">
<CountUp count={data ? data.totalUnreadCount : 0} />
{nFormatter(data ? data.totalUnreadCount : 0)}
</p>
<TooltipProvider>
<Tooltip>
@@ -375,7 +375,7 @@ export default function EmailSidebar({
</p>
</div>
<p className="text-sm font-semibold text-gray-900 dark:text-gray-100">
<CountUp count={sendEmails || 0} />
{nFormatter(sendEmails || 0)}
</p>
</div>
</div>
@@ -547,6 +547,8 @@ export default function EmailSidebar({
total={data.total}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
pageSize={pageSize}
setPageSize={setPageSize}
layout="center"
/>
)}
+5 -2
View File
@@ -21,8 +21,9 @@ export default function SendsEmailList({
}: {
isAdminModel: boolean;
}) {
const pageSize = 10;
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const [searchQuery, setSearchQuery] = useState("");
const { data, isLoading, error } = useSWR<{
@@ -116,9 +117,11 @@ export default function SendsEmailList({
{data && totalPages > 1 && (
<PaginationWrapper
className="m-0 mt-6 scale-75 justify-center"
total={totalPages}
total={data.total}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
pageSize={pageSize}
setPageSize={setPageSize}
/>
)}
</div>
+1 -1
View File
File diff suppressed because one or more lines are too long