Merge pull request #60 from AlineRinquin/isa2

Toutes les fonctionnalités to do list ok
This commit is contained in:
AlineRinquin 2022-02-27 16:28:24 +01:00 committed by GitHub
commit 46a6e3b506
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 134 additions and 81 deletions

View file

@ -4,6 +4,8 @@ import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Tache } from '../models/tache';
import { ToDoList } from '../models/to-do-list';
import { TodoList } from '../todo-list';
import { TokenService } from './token.service';
@Injectable({
providedIn: 'root',
@ -12,12 +14,13 @@ export class TodoService {
private toDoList: any;
private apiUrl: string;
constructor(private http: HttpClient) {
constructor(private http: HttpClient, private tokenService: TokenService) {
this.apiUrl = environment.apiUrl;
}
getToDoListByTeamId(): Observable<any> {
return this.http.get(`${this.apiUrl}/todolist/team/1`);
getToDoListByTeamId(): Observable<any> | void {
const teamId = this.tokenService.getCurrentTeamId();
return this.http.get(`${this.apiUrl}/todolist/team/${teamId}`);
}
deleteTacheById(idTache: any): Observable<any> {
@ -27,12 +30,27 @@ export class TodoService {
}
addTache(newtache: Tache, idTodoList: number): Observable<any> {
// console.log(newtache);
// console.log(newtache);
return this.http.post(`${this.apiUrl}/taches/add/${idTodoList}`, newtache);
}
updateTache(tache: Tache): Observable<any> {
console.log(tache);
console.log(tache);
return this.http.put(`${this.apiUrl}/taches/update/1`, tache);
}
addTodoByTeamId(newtodoList: TodoList): Observable<any> {
const teamId = this.tokenService.getCurrentTeamId();
console.log(newtodoList + 'newtodoList');
return this.http.post(`${this.apiUrl}/todolist/add/${teamId}`, newtodoList);
}
deleteTodoById(idTodo: any): Observable<any> {
return this.http.delete(`${this.apiUrl}/todolist/delete/${idTodo}`, {
responseType: 'text',
});
}
updateTodo(todoList: TodoList): Observable<any> {
console.log(todoList);
return this.http.put(`${this.apiUrl}/todolist/update/666`, todoList);
}
}