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

@Component({
    selector: 'app-shipping-company-form',
    templateUrl: './shipping-company-form.component.html'
})
export class ShippingCompanyFormComponent extends AbstractDataFormComponent<ShippingCompanyJsonld> {
    constructor(
        private shippingCompanyService: ShippingCompanyService,
        translateService: TranslateService,
        router: Router
    ) {
        super(
            shippingCompanyForm,
            (data: ShippingCompanyJsonld) => this.shippingCompanyService.shippingCompaniesPost(data),
            (id: string | number, data: ShippingCompanyJsonld) => this.shippingCompanyService.shippingCompaniesIdPatch(id.toString(), data),
            (id: string | number) => this.shippingCompanyService.shippingCompaniesIdDelete(id.toString()),
            translateService,
            router
        );

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