fix: localize validation and api messages
This commit is contained in:
@@ -130,7 +130,7 @@ export async function apiRequest<T>(path: string, options: RequestInit = {}): Pr
|
||||
|
||||
const body = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new ApiError(body.error || 'The request could not be completed', response.status);
|
||||
throw new ApiError(body.error || 'Não foi possível concluir a solicitação.', response.status);
|
||||
}
|
||||
return body as T;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ async function uploadRequest<T>(path: string, file: File): Promise<T> {
|
||||
if (session) headers.set('Authorization', `Bearer ${session.token}`);
|
||||
const response = await fetch(`${API_URL}${path}`, { method: 'PUT', headers, body: file });
|
||||
const body = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new ApiError(body.error || 'The video upload could not be completed', response.status);
|
||||
if (!response.ok) throw new ApiError(body.error || 'Não foi possível concluir o envio do vídeo.', response.status);
|
||||
return body as T;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ async function uploadImageRequest<T>(path: string, file: File): Promise<T> {
|
||||
if (session) headers.set('Authorization', `Bearer ${session.token}`);
|
||||
const response = await fetch(`${API_URL}${path}`, { method: 'POST', headers, body: file });
|
||||
const body = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new ApiError(body.error || 'The cover image could not be uploaded', response.status);
|
||||
if (!response.ok) throw new ApiError(body.error || 'Não foi possível enviar a imagem de capa.', response.status);
|
||||
return body as T;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user