File tree Expand file tree Collapse file tree 3 files changed +5
-10
lines changed
client/my-app/src/components/features Expand file tree Collapse file tree 3 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ import { Separator } from "@/components/ui/separator";
44import RefreshButton from "@/components/features/cameras/RefreshCamerasButton" ;
55import SearchCamerasInput from "@/components/features/cameras/SearchCamerasInput" ;
66import CameraFilters from "@/components/features/cameras/CameraFilters" ;
7+ import { fetchWithAuth } from "@/lib/fetchWithAuth" ;
78
89type ViewMode = "grid" | "list" ;
9- const base = process . env . NEXT_PUBLIC_APP_URL ! ;
1010
1111/* ------------------------- Search matcher -------------------------- */
1212function 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) ค้นหา
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments