feat: articles list screen

This commit is contained in:
fsylvain committed 2026-09-27 17:12:23 +02:00
1 parent ca3fe20519
commit f6d0d01092
14 files changed
+2353 -25

No files matched your search

+10 -19
View File
@@ -61,15 +61,8 @@ if (typeof window !== 'undefined') {
}
export function useApi() {
async function request<T>(
path: string,
options: RequestOptions = {},
): Promise<T> {
const {
onUnauthorized = 'redirect',
onForbidden = 'redirect',
...init
} = options
async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {
const { onUnauthorized = 'redirect', onForbidden = 'redirect', ...init } = options
let response: Response
try {
@@ -99,10 +92,7 @@ export function useApi() {
if (response.status === 403) {
const session = useSessionStore()
if (
onForbidden !== 'passthrough' &&
session.session?.verified === false
) {
if (onForbidden !== 'passthrough' && session.session?.verified === false) {
router.push('/register/pending')
}
throw new ApiError(403)
@@ -115,16 +105,17 @@ export function useApi() {
throw new ApiError(response.status)
}
if (response.status === 204) {
return undefined as T
}
return response.json()
}
async function getMe(): Promise<MeResult> {
const body = await request<{ is_verified: boolean; username?: string }>(
'/v1/auth/me',
{
onUnauthorized: 'passthrough',
},
)
const body = await request<{ is_verified: boolean; username?: string }>('/v1/auth/me', {
onUnauthorized: 'passthrough',
})
return { verified: Boolean(body.is_verified), username: body.username }
}