add functionality to delete employee button (#11)

Reviewed-on: #11
Reviewed-by: Hernd Beidemann <huydw@proton.me>
This commit is contained in:
2024-12-18 13:02:46 +00:00
parent 4f31bc1358
commit 0eb4fe419b
7 changed files with 93 additions and 42 deletions

View File

@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AuthService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,22 @@
import {inject, Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {Employee} from "../Employee";
@Injectable({
providedIn: 'root'
})
export default class EmployeeApiService {
private http: HttpClient = inject(HttpClient);
private static readonly BASE_URL = 'http://localhost:8089';
public deleteById(id: number): Observable<Employee> {
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
}
public getAll(): Observable<Employee[]> {
return this.http.get<Employee[]>(`${EmployeeApiService.BASE_URL}/employees`)
}
}