30 lines
1010 B
TypeScript
30 lines
1010 B
TypeScript
import { Injectable, inject } from '@angular/core';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { environment } from '../../../environments/environment';
|
|
import type { AppSettings, User } from '../../shared/models';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class AdminService {
|
|
private readonly http = inject(HttpClient);
|
|
|
|
getSettings() {
|
|
return this.http.get<{ item: AppSettings }>(`${environment.apiBaseUrl}/admin/settings`);
|
|
}
|
|
|
|
updateSettings(payload: Partial<AppSettings>) {
|
|
return this.http.put<{ item: AppSettings }>(`${environment.apiBaseUrl}/admin/settings`, payload);
|
|
}
|
|
|
|
listUsers() {
|
|
return this.http.get<{ items: User[] }>(`${environment.apiBaseUrl}/admin/users`);
|
|
}
|
|
|
|
updateUser(id: string, payload: Partial<User>) {
|
|
return this.http.patch<{ item: User }>(`${environment.apiBaseUrl}/admin/users/${id}`, payload);
|
|
}
|
|
|
|
testSmtp(to: string) {
|
|
return this.http.post<{ message: string }>(`${environment.apiBaseUrl}/admin/test-smtp`, { to });
|
|
}
|
|
}
|