import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';

import {User} from '@/_models';

@Injectable({ providedIn: 'root' })
export class UserService {

    constructor(private http: HttpClient) { }

    getAll() {
        return this.http.get<User[]>(`${config.apiUrl}/users`);
    }

    getAllReinstated() {
        return this.http.get<User[]>(`${config.apiUrl}/toBeReinstated`);
    }

    getAllNewForms() {
        return this.http.get<User[]>(`${config.apiUrl}/newForms`);
    }

    register(user: User) {
        return this.http.put(`${config.apiUrl}/users/register`, user);
    }

    delete(id: number) {
        return this.http.delete(`${config.apiUrl}/users/${id}`);
    }

    public save(user: User) {
        return this.http.post<User>(`${config.apiUrl}/users/users` , user);
    }
}