import { Component } from '@angular/core';
import { AbstractDataFormComponent } from "@app/_components/_abstract/abstract-data-form-component";
import { ZoneJsonld, ZoneService } from "@app/core/api/v1";
import { zoneForm } from "@app/_forms/apiForms";
import { TranslateService } from "@ngx-translate/core";
import { Router } from "@angular/router";
import {ROUTE_BASE_DATA} from "@app/app-routing.module";

@Component({
    selector: 'app-zone-form',
    templateUrl: './zone-form.component.html'
})
export class ZoneFormComponent extends AbstractDataFormComponent<ZoneJsonld> {
    constructor(
        private zoneService: ZoneService,
        translateService: TranslateService,
        router: Router
    ) {
        super(
            zoneForm,
            (data: ZoneJsonld) => this.zoneService.zonesPost(data),
            (id: string | number, data: ZoneJsonld) => this.zoneService.zonesIdPatch(id.toString(), data),
            (id: string | number) => zoneService.zonesIdDelete(id.toString()),
            translateService,
            router
        );

        this.redirectAfterDelete = '/' + ROUTE_BASE_DATA;
    }
}