From 882778a45fb8d3d81e78a2c80804d3fbedf96c38 Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Tue, 16 Apr 2024 19:01:45 +0100 Subject: [PATCH] add entry seen service --- .../app/core/services/entry-seen.service.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 frontend/src/app/core/services/entry-seen.service.ts 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}` + ); + } +}