Skip to content

Commit 665278a

Browse files
committed
Added ConfirmVehicleRemoval dialog to vehicle compomonent
1 parent 74e78ff commit 665278a

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

apps/car-rental/src/components/vehicles/vehicle-details/vehicle.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<button mat-icon-button matTooltip="Edytuj pojazd">
1212
<mat-icon>edit</mat-icon>
1313
</button>
14-
<button mat-icon-button matTooltip="Usuń pojazd">
14+
<button mat-icon-button matTooltip="Usuń pojazd" (click)="openConfirmVehicleRemovalDialog()">
1515
<mat-icon>delete</mat-icon>
1616
</button>
1717
</div>

apps/car-rental/src/components/vehicles/vehicle-details/vehicle.component.scss

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#vehicle-card {
22
height: 100vh;
3+
padding: 1rem;
34
}
45

56
#vehicle-card-title {

apps/car-rental/src/components/vehicles/vehicle-details/vehicle.component.ts

+17
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { MatListModule } from '@angular/material/list';
1313
import { MatDividerModule } from '@angular/material/divider';
1414
import { MatIconModule } from '@angular/material/icon';
1515
import { MatTooltipModule } from '@angular/material/tooltip';
16+
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
17+
import { ConfirmVehicleRemovalComponent } from '../confirm-vehicle-removal/confirm-vehicle-removal.component';
1618

1719
@Component({
1820
selector: 'app-vehicle',
@@ -26,6 +28,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
2628
MatDividerModule,
2729
MatIconButton,
2830
MatIconModule,
31+
MatDialogModule,
2932
],
3033
templateUrl: './vehicle.component.html',
3134
styleUrl: './vehicle.component.scss',
@@ -39,6 +42,7 @@ export class VehicleComponent implements OnInit {
3942
private readonly route: ActivatedRoute,
4043
private readonly vehiclesService: VehiclesService,
4144
private readonly vehiclesBrandService: VehicleBrandsService,
45+
private readonly dialog: MatDialog,
4246
private readonly notificationService: NotificationService,
4347
private readonly router: Router
4448
) {
@@ -69,4 +73,17 @@ export class VehicleComponent implements OnInit {
6973
goBackToTheVehiclesList(): void {
7074
this.router.navigate(['/vehicles']);
7175
}
76+
77+
openConfirmVehicleRemovalDialog(): void {
78+
const dialogRef = this.dialog.open(ConfirmVehicleRemovalComponent, {
79+
width: '400px',
80+
height: '200px',
81+
data: this.vehicle,
82+
});
83+
dialogRef.afterClosed().subscribe((result) => {
84+
if (result === 'vehicleRemoved') {
85+
this.goBackToTheVehiclesList();
86+
}
87+
});
88+
}
7289
}

0 commit comments

Comments
 (0)