diff --git a/web-v2/src/lib/userProfileApi.ts b/web-v2/src/lib/userProfileApi.ts new file mode 100644 index 0000000..6b6b365 --- /dev/null +++ b/web-v2/src/lib/userProfileApi.ts @@ -0,0 +1,47 @@ +import { apiRequest } from './api'; +import type { AdministrativeUser } from './api'; + +export interface AdministrativeUserProfile extends AdministrativeUser { + dni: string | null; + phone: string | null; + jobTitle: string | null; + employeeNumber: string | null; +} + +export interface UserProfileInput { + username?: string; + email?: string | null; + dni?: string | null; + phone?: string | null; + jobTitle?: string | null; + employeeNumber?: string | null; + firstName?: string; + lastName?: string; +} + +export interface CreateUserProfileInput extends UserProfileInput { + username: string; + firstName: string; + lastName: string; + password: string; + mustChangePassword: boolean; + roleIds: string[]; +} + +export function getUserProfile(id: string) { + return apiRequest(`/users/${id}`); +} + +export function createUserProfile(input: CreateUserProfileInput) { + return apiRequest('/users', { + method: 'POST', + body: JSON.stringify(input), + }); +} + +export function updateUserProfile(id: string, input: UserProfileInput) { + return apiRequest(`/users/${id}`, { + method: 'PATCH', + body: JSON.stringify(input), + }); +}