diff --git a/apps/client/src/api/users.ts b/apps/client/src/api/users.ts index 8333248e..9f70ca67 100644 --- a/apps/client/src/api/users.ts +++ b/apps/client/src/api/users.ts @@ -1,8 +1,22 @@ import { request } from './client.js' import type { z } from 'zod' -import { UpdateUserSchema } from '@blog/zod-shared' +import { DeleteUserSchema, UpdateUserSchema } from '@blog/zod-shared' -export type UserProfile = { id: string; username: string; bio?: string; avatar?: string } +/** + * `email`/`hasPassword`/`oauthProvider` are only ever present when the + * requester is viewing their own account — see userService.getPublicProfile's + * viewerId gate. Anyone else's profile arrives without them. + */ +export type UserProfile = { + id: string + username: string + bio?: string + image?: string + createdAt: string + email?: string + hasPassword?: boolean + oauthProvider?: 'google' | 'facebook' | null +} export const usersApi = { get: (id: string) => request(`/api/v1/users/${id}`), @@ -10,5 +24,6 @@ export const usersApi = { update: (id: string, input: z.infer) => request(`/api/v1/users/${id}`, { method: 'PATCH', body: JSON.stringify(input) }), - remove: (id: string) => request(`/api/v1/users/${id}`, { method: 'DELETE' }), + remove: (id: string, confirmation: z.infer) => + request(`/api/v1/users/${id}`, { method: 'DELETE', body: JSON.stringify(confirmation) }), } diff --git a/apps/client/src/components/layouts/PageShell.tsx b/apps/client/src/components/layouts/PageShell.tsx index fba99bd2..21087014 100644 --- a/apps/client/src/components/layouts/PageShell.tsx +++ b/apps/client/src/components/layouts/PageShell.tsx @@ -39,7 +39,9 @@ export function PageShell({ children }: { children: React.ReactNode }) { New post