Files
Showy/frontend/src/app/core/services/entry-seen.service.ts
T
2024-05-10 09:45:54 +01:00

44 lines
1.1 KiB
TypeScript

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { EntrySeen } from '../../shared/models/entrySeen.model';
@Injectable({
providedIn: 'root',
})
export class EntrySeenService {
private backend_apiUrl = 'http://localhost:4000/api/v1';
private apiAction = 'entry-seen';
constructor(private http: HttpClient) {}
createEntrySeen(entryId: string, dateSeen: Date, seenWith: string) {
return this.http.post<EntrySeen>(
`${this.backend_apiUrl}/${this.apiAction}`,
{
entry_id: entryId,
date_seen: dateSeen,
seen_with: seenWith,
}
);
}
// get entry seen by entry id
getEntrySeenById(id: string) {
return this.http.get<EntrySeen[]>(
`${this.backend_apiUrl}/${this.apiAction}/${id}`
);
}
removeEntrySeen(id: number) {
return this.http.delete<any>(
`${this.backend_apiUrl}/${this.apiAction}/${id}`
);
}
getYearlyStats(year: number) {
return this.http.get<any>(
`${this.backend_apiUrl}/${this.apiAction}/stats-year/${year}`
);
}
}