fix(frontend): align Zod schemas with camelCase API responses
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled

per_page → perPage in paginated response schemas, drop tag field from tag endpoint
This commit is contained in:
2026-05-29 12:15:07 +02:00
parent 9798a1d829
commit 6abd2e7aad
4 changed files with 11 additions and 11 deletions

View File

@@ -68,7 +68,7 @@ export default async function RemoteActorPage({
const postsData = postsResult.status === "fulfilled" ? postsResult.value : null;
const posts = postsData?.items ?? [];
const totalPages = postsData
? Math.ceil(postsData.total / postsData.per_page)
? Math.ceil(postsData.total / postsData.perPage)
: 1;
const me =
meResult.status === "fulfilled" ? (meResult.value as Me | null) : null;

View File

@@ -100,7 +100,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) {
const thoughtsData = thoughtsResult.status === "fulfilled" ? thoughtsResult.value : null;
const thoughts = thoughtsData?.items ?? [];
const totalPages = thoughtsData
? Math.ceil(thoughtsData.total / thoughtsData.per_page)
? Math.ceil(thoughtsData.total / thoughtsData.perPage)
: 1;
const localFollowersCount =

View File

@@ -22,8 +22,8 @@ export default async function AllUsersPage({
);
}
const { items, total, per_page } = usersData;
const totalPages = Math.ceil(total / per_page);
const { items, total, perPage } = usersData;
const totalPages = Math.ceil(total / perPage);
return (
<div className="container mx-auto max-w-2xl p-4 sm:p-6">

View File

@@ -299,7 +299,7 @@ export const getRemoteActorPosts = (
z.object({
total: z.number(),
page: z.number(),
per_page: z.number(),
perPage: z.number(),
items: z.array(ThoughtSchema),
}),
token
@@ -347,8 +347,8 @@ export const getAllUsers = (page: number = 1, pageSize: number = 20) =>
apiFetch(
`/users?page=${page}&per_page=${pageSize}`,
{ next: { tags: ['users'] } },
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) }))
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) }))
);
export const getAllUsersCount = () =>
@@ -381,8 +381,8 @@ export const getFeed = (token: string, page = 1, pageSize = 20, opts: FeedOption
return apiFetch(
`/feed?${params.toString()}`,
{ next: { tags: ["feed"] } },
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) })),
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) })),
token
);
};
@@ -391,7 +391,7 @@ export const getUserThoughts = (username: string, token: string | null, page = 1
apiFetch(
`/users/${username}/thoughts?page=${page}`,
{ next: { tags: [`profile:${username}`] } },
z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), per_page: z.number() }),
z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), perPage: z.number() }),
token
);
@@ -427,7 +427,7 @@ export const getThoughtsByTag = (tagName: string, token: string | null) =>
apiFetch(
`/tags/${tagName}`,
{ next: { tags: [`tag:${tagName}`, 'feed'] } },
z.object({ tag: z.string(), items: z.array(ThoughtSchema), total: z.number(), page: z.number(), per_page: z.number() }),
z.object({ items: z.array(ThoughtSchema), total: z.number(), page: z.number(), perPage: z.number() }),
token
);