Skip to content

Commit

Permalink
Merge pull request #29 from sequra/fix/order-link-to-back-office
Browse files Browse the repository at this point in the history
Fix/order link to back office
  • Loading branch information
m1k3lm authored Sep 26, 2024
2 parents 6ed5af0 + 53d5d63 commit 745648e
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions Ui/Component/Listing/Column/SequraOrderLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\UrlInterface;
use SeQura\Core\BusinessLogic\Domain\Connection\Models\ConnectionData;
use SeQura\Core\BusinessLogic\Domain\Connection\Services\ConnectionService;
use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\OrderRequestStates;
use SeQura\Core\BusinessLogic\Domain\Order\Models\SeQuraOrder;
use SeQura\Core\BusinessLogic\Domain\Order\Service\OrderService;
use SeQura\Core\BusinessLogic\SeQuraAPI\BaseProxy;
use SeQura\Core\Infrastructure\ServiceRegister;
use Sequra\Core\Services\BusinessLogic\Utility\SeQuraTranslationProvider;

Expand All @@ -23,7 +26,8 @@ class SequraOrderLink extends Column
protected $assetRepository;
protected $urlBuilder;
protected $translationProvider;
public const SEQURA_PORTAL_URL = 'https://simbox.sequrapi.com/orders/';
public const SEQURA_PORTAL_SANDBOX_URL = 'https://simbox.sequrapi.com/orders/';
public const SEQURA_PORTAL_URL = 'https://simba.sequra.com/orders/';

/**
* @param ContextInterface $context
Expand Down Expand Up @@ -117,14 +121,22 @@ private function getButtonLink(string $orderReference): string
$imagePath = $this->assetRepository->getUrl('Sequra_Core::images/sequra-logo.png');

return html_entity_decode(
'<a class="sequra-link" href="' . $this->urlBuilder->getUrl(self::SEQURA_PORTAL_URL . $orderReference) . '" target="_blank" onclick="event.stopPropagation()">
'<a class="sequra-link" href="' . $this->getButtonLinkUrl($orderReference) . '" target="_blank" onclick="event.stopPropagation()">
<button class="sequra-preview">
<img class="sequra-logo" src=' . $imagePath . ' alt="sequra-logo">
' . $this->translationProvider->translate("sequra.viewOnSequra") . '
</button>
</a>');
}

private function getButtonLinkUrl(string $orderReference): string
{
$connectionSettings = $this->getConnectionSettings();
$baseUrl = $connectionSettings && $connectionSettings->getEnvironment() === BaseProxy::LIVE_MODE ?
self::SEQURA_PORTAL_URL : self::SEQURA_PORTAL_SANDBOX_URL;
return $this->urlBuilder->getUrl( $baseUrl . $orderReference );
}

/**
* Returns an instance of Order service.
*
Expand All @@ -138,4 +150,20 @@ private function getOrderService(): OrderService

return $this->orderService;
}

/**
* @return ConnectionData|null
*/
private function getConnectionSettings(): ?ConnectionData
{
return $this->getConnectionService()->getConnectionData();
}

/**
* @return ConnectionService
*/
private function getConnectionService(): ConnectionService
{
return ServiceRegister::getService(ConnectionService::class);
}
}

0 comments on commit 745648e

Please sign in to comment.