<?php
namespace PortalPeople\DisabledPostcodes\Block\Adminhtml\Postcode;

use Magento\Backend\Block\Template;
use PortalPeople\DisabledPostcodes\Api\DisabledPostcodeManagementInterface;

class Index extends Template
{
    protected $_template = 'PortalPeople_DisabledPostcodes::postcode/index.phtml';

    private DisabledPostcodeManagementInterface $management;

    public function __construct(
        Template\Context $context,
        DisabledPostcodeManagementInterface $management,
        array $data = []
    ) {
        parent::__construct($context, $data);
        $this->management = $management;
    }

    public function getRows(): array
    {
        return $this->management->getList(null);
    }

    public function getEditUrl(int $id): string
    {
        return $this->getUrl('disabledpostcodes/postcode/edit', ['id' => $id]);
    }

    public function getDeleteUrl(int $id): string
    {
        return $this->getUrl('disabledpostcodes/postcode/delete', ['id' => $id]);
    }

    public function getNewUrl(): string
    {
        return $this->getUrl('disabledpostcodes/postcode/new');
    }

    public function getImportUrl(): string
    {
        return $this->getUrl('disabledpostcodes/postcode/import');
    }
}
