diff --git a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.css b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.css new file mode 100644 index 0000000..e69de29 diff --git a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html new file mode 100644 index 0000000..61b6ea4 --- /dev/null +++ b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.html @@ -0,0 +1,110 @@ +
+

+ + + +

+

+ + + +

+

+ + + +

+

+ + + +

+

+ + + +

+

+ + + +

+

+ + + +

+

+ + + +

+
+ @if (editMode) { + + } +
diff --git a/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts new file mode 100644 index 0000000..4ab72e0 --- /dev/null +++ b/Front/skydivelogs-app/src/app/gear-infos/gear-infos.component.ts @@ -0,0 +1,63 @@ +import { Component, Inject, OnInit } from "@angular/core"; + +import { MAT_DIALOG_DATA } from "@angular/material/dialog"; +import { TranslateModule } from "@ngx-translate/core"; +import { MatCheckboxModule } from "@angular/material/checkbox"; +import { MatFormFieldModule } from "@angular/material/form-field"; +import { FormsModule, ReactiveFormsModule } from "@angular/forms"; +import { MatInputModule } from "@angular/material/input"; +import { MatButtonModule } from "@angular/material/button"; + +import { AddAction } from "../../models/add-action.enum"; +import { GearResp } from "../../models/gear"; + +import { GearService } from "../../services/gear.service"; +import { ServiceComm } from "../../services/service-comm.service"; + +@Component({ + selector: "app-gear-infos", + templateUrl: "./gear-infos.component.html", + styleUrls: ["./gear-infos.component.css"], + imports: [ + TranslateModule, + FormsModule, + MatCheckboxModule, + MatFormFieldModule, + ReactiveFormsModule, + MatInputModule, + MatButtonModule, + ], +}) +export class GearInfosComponent implements OnInit { + public editMode: boolean; + public gear: GearResp; + + constructor( + @Inject(MAT_DIALOG_DATA) public data: any, + private serviceGear: GearService, + private serviceComm: ServiceComm, + ) { + this.gear = new GearResp(data.gear); + this.editMode = data.editMode; + } + + ngOnInit(): void {} + + public updateGear() { + this.serviceGear + .updateGear( + this.gear.id, + this.gear.name, + this.gear.manufacturer, + this.gear.minSize, + this.gear.maxSize, + this.gear.aad, + this.gear.mainCanopy, + this.gear.reserveCanopy, + this.gear.equipment, + ) + .subscribe(() => { + this.serviceComm.refreshData(AddAction.Gear); + }); + } +} diff --git a/Front/skydivelogs-app/src/services/gear.service.ts b/Front/skydivelogs-app/src/services/gear.service.ts index fc0f3aa..f9b5513 100644 --- a/Front/skydivelogs-app/src/services/gear.service.ts +++ b/Front/skydivelogs-app/src/services/gear.service.ts @@ -65,4 +65,33 @@ export class GearService extends BaseService { public getFromCache(): Observable> { return this.serviceCacheApi.getByKey>(CacheApiKey.Gear); } + + public updateGear( + id: number, + name: string, + manufacturer: string, + minSize: number, + maxSize: number, + aad: string, + mainCanopy: string, + reserveCanopy: string, + equipment: string, + ) { + const gearData = { + id: id, + name: name, + manufacturer: manufacturer, + minSize: minSize, + maxSize: maxSize, + aad: aad, + mainCanopy: mainCanopy, + reserveCanopy: reserveCanopy, + equipment: equipment, + }; + const bodyUpdatedGear = new GearReq(gearData); + + return this.http.put(`${this.apiUrl}/Gear/${id}`, bodyUpdatedGear, { + headers: this.headers, + }); + } }