24 lines
810 B
TypeScript
24 lines
810 B
TypeScript
import { Injectable, inject } from '@angular/core';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { Observable } from 'rxjs';
|
|
import { API_URL } from '../../core/tokens/api-url.token';
|
|
import { Review } from '../../core/models/review.model';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class ReviewService {
|
|
private http = inject(HttpClient);
|
|
private apiUrl = inject(API_URL);
|
|
private readonly endpoint = '/admin/AdminReviews';
|
|
|
|
getAll(): Observable<Review[]> {
|
|
return this.http.get<Review[]>(`${this.apiUrl}${this.endpoint}`);
|
|
}
|
|
|
|
approve(id: string): Observable<void> {
|
|
return this.http.post<void>(`${this.apiUrl}${this.endpoint}/${id}/approve`, {});
|
|
}
|
|
|
|
delete(id: string): Observable<void> {
|
|
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
|
|
}
|
|
} |