add entry seen service

This commit is contained in:
X4Lo committed 2024-04-16 19:01:45 +01:00
1 parent 15e7ec7479
commit 882778a45f
1 file changed
+38
@@ -0,0 +1,38 @@
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}`
);
}
}