From 7cb6b94b08394e09c8cdeb327c92e628c2696f97 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Thu, 14 May 2026 17:32:39 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20per=5Fpage=20not=20perPage=20in=20Zod=20?= =?UTF-8?q?schemas=20=E2=80=94=20raw=20serde=5Fjson=20keys=20are=20snake?= =?UTF-8?q?=5Fcase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thoughts-frontend/app/users/all/page.tsx | 2 +- thoughts-frontend/lib/api.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/thoughts-frontend/app/users/all/page.tsx b/thoughts-frontend/app/users/all/page.tsx index 24d8fbe..28f39d0 100644 --- a/thoughts-frontend/app/users/all/page.tsx +++ b/thoughts-frontend/app/users/all/page.tsx @@ -28,7 +28,7 @@ export default async function AllUsersPage({ ); } - const { items, total, perPage } = usersData; + const { items, total, per_page } = usersData;\n const perPage = per_page; const totalPages = Math.ceil(total / perPage); return ( diff --git a/thoughts-frontend/lib/api.ts b/thoughts-frontend/lib/api.ts index 60a36fd..39cdc36 100644 --- a/thoughts-frontend/lib/api.ts +++ b/thoughts-frontend/lib/api.ts @@ -208,8 +208,8 @@ export const getAllUsers = (page: number = 1, pageSize: number = 20) => apiFetch( `/users?page=${page}&per_page=${pageSize}`, {}, - z.object({ items: z.array(UserSchema), total: z.number(), page: z.number(), perPage: z.number() }) - .transform((d) => ({ ...d, totalPages: Math.ceil(d.total / d.perPage) })) + z.object({ items: z.array(UserSchema), total: z.number(), page: z.number(), per_page: z.number() }) + .transform((d) => ({ ...d, totalPages: Math.ceil(d.total / d.per_page) })) ); export const getAllUsersCount = () => @@ -221,8 +221,8 @@ export const getFeed = (token: string, page: number = 1, pageSize: number = 20) apiFetch( `/feed?page=${page}&per_page=${pageSize}`, {}, - z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), perPage: z.number() }) - .transform((d) => ({ ...d, totalPages: Math.ceil(d.total / d.perPage) })), + z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), per_page: z.number() }) + .transform((d) => ({ ...d, totalPages: Math.ceil(d.total / d.per_page) })), token ); @@ -230,7 +230,7 @@ export const getUserThoughts = (username: string, token: string | null) => apiFetch( `/users/${username}/thoughts`, {}, - z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), perPage: z.number() }), + z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), per_page: z.number() }), token ); @@ -252,7 +252,7 @@ export const getThoughtsByTag = (tagName: string, token: string | null) => apiFetch( `/tags/${tagName}`, {}, - z.object({ tag: z.string(), items: z.array(ThoughtSchema), total: z.number(), page: z.number(), perPage: z.number() }), + z.object({ tag: z.string(), items: z.array(ThoughtSchema), total: z.number(), page: z.number(), per_page: z.number() }), token ); @@ -260,7 +260,7 @@ export const getPopularTags = () => apiFetch( "/tags/popular", {}, - z.object({ tags: z.array(z.object({ name: z.string(), thoughtCount: z.number() })) }) + z.object({ tags: z.array(z.object({ name: z.string(), thought_count: z.number() })) }) .transform((d) => d.tags.map((t) => t.name)) );