48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
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<AdministrativeUserProfile>(`/users/${id}`);
|
|
}
|
|
|
|
export function createUserProfile(input: CreateUserProfileInput) {
|
|
return apiRequest<AdministrativeUserProfile>('/users', {
|
|
method: 'POST',
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function updateUserProfile(id: string, input: UserProfileInput) {
|
|
return apiRequest<AdministrativeUserProfile>(`/users/${id}`, {
|
|
method: 'PATCH',
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|