diff --git a/frontend/src/app/core/services/entry-seen.service.ts b/frontend/src/app/core/services/entry-seen.service.ts new file mode 100644 index 0000000..2046e8e --- /dev/null +++ b/frontend/src/app/core/services/entry-seen.service.ts @@ -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( + `${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( + `${this.backend_apiUrl}/${this.apiAction}/${id}` + ); + } + + removeEntrySeen(id: number) { + return this.http.delete( + `${this.backend_apiUrl}/${this.apiAction}/${id}` + ); + } +}