ajout contact
This commit is contained in:
parent
e6f59fb84c
commit
0244cb29ea
3 changed files with 12 additions and 7 deletions
|
|
@ -3,6 +3,8 @@ import { HttpClient } from '@angular/common/http';
|
|||
import { map, Observable } from 'rxjs';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Contact } from '../models/contact';
|
||||
import { Router } from '@angular/router';
|
||||
import { TokenService } from './token.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -11,14 +13,15 @@ export class RepertoireService {
|
|||
apiUrl: string;
|
||||
tokenKey: string;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
constructor(private http: HttpClient, private router: Router, private tokenService: TokenService) {
|
||||
// On se sert des variables d'environnement de notre application
|
||||
this.apiUrl = environment.apiUrl;
|
||||
this.tokenKey = environment.tokenKey;
|
||||
}
|
||||
|
||||
getContact(): Observable<any> {
|
||||
return this.http.get(`${this.apiUrl}/contacts/team/1`);
|
||||
const teamId = this.tokenService.getCurrentTeamId()
|
||||
return this.http.get(`${this.apiUrl}/contacts/team/${teamId}`);
|
||||
}
|
||||
|
||||
getContactById(id: any): Observable<any> {
|
||||
|
|
@ -26,7 +29,7 @@ export class RepertoireService {
|
|||
}
|
||||
|
||||
addContact(contact: Contact): Observable<any> {
|
||||
console.log(contact);
|
||||
const teamId = this.tokenService.getCurrentTeamId()
|
||||
return this.http.post(`${this.apiUrl}/contacts/add`, contact);
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +38,6 @@ export class RepertoireService {
|
|||
}
|
||||
|
||||
updateContact(contact: Contact): Observable<any> {
|
||||
return this.http.put(`${this.apiUrl}/contacts/update/1`, contact);
|
||||
return this.http.put(`${this.apiUrl}/contacts/update/`, contact);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue