Skip to content

Commit 74c6655

Browse files
committed
fix: page size, แก้ fetch dashboard
1 parent 1b3b626 commit 74c6655

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

client/my-app/src/components/features/dashboard/CameraAlertView.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Separator } from "@/components/ui/separator";
44
import RefreshButton from "@/components/features/cameras/RefreshCamerasButton";
55
import SearchCamerasInput from "@/components/features/cameras/SearchCamerasInput";
66
import CameraFilters from "@/components/features/cameras/CameraFilters";
7+
import { fetchWithAuth } from "@/lib/fetchWithAuth";
78

89
type ViewMode = "grid" | "list";
9-
const base = process.env.NEXT_PUBLIC_APP_URL!;
1010

1111
/* ------------------------- Search matcher -------------------------- */
1212
function buildMatcher(search?: string) {
@@ -54,16 +54,11 @@ export default async function CameraView({
5454
location?: string;
5555
type?: string;
5656
}) {
57-
const res = await fetch(`${base}/api/cameras`, {
57+
const json = await fetchWithAuth(`/api/cameras`, {
5858
method: "GET",
59-
headers: {
60-
Authorization: `Bearer ${process.env.NEXT_PUBLIC_TOKEN}`,
61-
"Content-Type": "application/json",
62-
},
59+
credentials: "include",
6360
cache: "no-store",
6461
});
65-
if (!res.ok) throw new Error("Failed to load cameras");
66-
const json = await res.json();
6762
const cameras: Camera[] = Array.isArray(json.data) ? json.data : [];
6863

6964
// 1) ค้นหา

client/my-app/src/components/features/history/CameraLogs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type SortState = {
8080
order: SortOrder;
8181
};
8282

83-
const PAGE_SIZE = 25;
83+
const PAGE_SIZE = 10;
8484

8585
/* ============================ HELPERS ===================================== */
8686

client/my-app/src/components/features/history/UserLogs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type SortState = {
7474
order: SortOrder;
7575
};
7676

77-
const PAGE_SIZE = 25;
77+
const PAGE_SIZE = 10;
7878

7979
/* ============================ HELPERS ===================================== */
8080

0 commit comments

Comments
 (0)