Pin removal added

master
Alexis Feron 4 days ago
parent 144af2e06f
commit 58d7526834

@ -2,6 +2,7 @@ import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core';
import * as L from 'leaflet';
import { Pin } from '../../model/Pin';
import { PinService } from '../../services/pin/pin.service';
import { EditPinPopupComponent } from '../edit-pin-popup/edit-pin-popup.component';
@Component({
@ -15,6 +16,8 @@ export class PinMarkerComponent {
currentIndex: number = 0;
constructor(private pinService: PinService) {}
onClosePopup() {
this.marker.closePopup();
}
@ -26,7 +29,9 @@ export class PinMarkerComponent {
}
onDelete() {
// TODO: Implémenter l'action de suppression
this.pinService.deletePin(this.pin.id).subscribe(() => {
this.marker.remove();
});
}
get formattedDescription(): string {

@ -91,4 +91,13 @@ export class PinService {
})
);
}
deletePin(id: string) {
const url = `${this.apiURL}/pin/${id}`;
const headers = new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + localStorage.getItem('auth_token'),
});
return this.http.delete<any>(url, { headers });
}
}

Loading…
Cancel
Save