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)) );