Skip to content

Commit

Permalink
FRW-9176 Introduced View page for merchants in the BackOffice. (#11133)
Browse files Browse the repository at this point in the history
FRW-9176 Introduced View page for merchants in the BackOffice.
  • Loading branch information
olhalivitchuk authored Oct 11, 2024
1 parent f78798f commit 33d07ac
Show file tree
Hide file tree
Showing 18 changed files with 600 additions and 0 deletions.
35 changes: 35 additions & 0 deletions data/translation/Zed/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,38 @@ Stores,Stores
"Create Merchant","Händler Erstellen"
Approval,Genehmigung
Status,Status
registration-number,Zulassungsnummer
merchant-user-id,"Benutzerkennung des Händlers"
deny-access,"Zugang verweigern"
terms-and-conditions,"Bedingungen und Konditionen"
data-privacy,Datenschutz
cancellation-policy,Annullierungspolitik
view-merchant,"Ansicht Händler"
Role,Rolle
Title,Titel
"First Name",Vorname
"Last Name",Nachname
Phone,Telefon
"Store relation",Store-Beziehung
Warehouses,Lagerhäuser
Imprint,Impressum
"Public Email","Öffentliche E-Mail"
"Public Phone","Öffentliches Telefon"
"Fax Number",Faxnummer
"Logo Url",Logo-URL
Country,Land
Street,Straße
Number,Nummer
"Zip Code",Postleitzahl
City,Stadt
latitude,Breitengrad
longitude,Längengrad
Description,Beschreibung
"Average Delivery Time","Durchschnittliche Lieferzeit"
"Banner URL",Banner-URL
"Approval Status",Genehmigungsstatus
"Contact Person",Kontaktperson
"Legal Information","Rechtliche Informationen"
"Merchant Profile",Händlerprofil
"Merchant Status",Händlerstatus
Users,Benutzer
35 changes: 35 additions & 0 deletions data/translation/Zed/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,38 @@ Stores,Stores
"Create Merchant","Create Merchant"
Approval,Approval
Status,Status
registration-number,"Registration Number"
merchant-user-id,"Merchant user ID"
deny-access,"Deny Access"
terms-and-conditions,"Terms and conditions"
data-privacy,"Data Privacy"
cancellation-policy,"Cancellation policy"
view-merchant,"View Merchant"
Role,Role
Title,Title
"First Name","First Name"
"Last Name","Last Name"
Phone,Phone
"Store relation","Store relation"
Warehouses,Warehouses
Imprint,Imprint
"Public Email","Public Email"
"Public Phone","Public Phone"
"Fax Number","Fax Number"
"Logo Url","Logo Url"
Country,Country
Street,Street
Number,Number
"Zip Code","Zip Code"
City,City
latitude,Latitude
longitude,Longitude
Description,Description
"Average Delivery Time","Average Delivery Time"
"Banner URL","Banner URL"
"Approval Status","Approval Status"
"Contact Person","Contact Person"
"Legal Information","Legal Information"
"Merchant Profile","Merchant Profile"
"Merchant Status","Merchant Status"
Users,Users
16 changes: 16 additions & 0 deletions src/Spryker/Shared/MerchantGui/Transfer/merchant_gui.transfer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<property name="addressCollection" type="MerchantAddressCollection" deprecated="Use MerchantProfile.addressCollection instead"/>
<property name="urlCollection" type="Url[]" singular="url"/>
<property name="storeRelation" type="StoreRelation"/>
<property name="merchantProfile" type="MerchantProfile"/>
<property name="stocks" type="Stock[]" singular="stock"/>
</transfer>

<transfer name="MerchantResponse">
Expand Down Expand Up @@ -91,4 +93,18 @@
<property name="name" type="string"/>
</transfer>

<transfer name="Stock">
</transfer>

<transfer name="MerchantProfile">
<property name="merchantProfileLocalizedGlossaryAttributes" type="MerchantProfileLocalizedGlossaryAttributes[]" singular="merchantProfileLocalizedGlossaryAttribute"/>
<property name="addressCollection" type="MerchantProfileAddress[]" singular="address"/>
</transfer>

<transfer name="MerchantProfileLocalizedGlossaryAttributes">
</transfer>

<transfer name="MerchantProfileAddress">
</transfer>

</transfers>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\MerchantGui\Communication\Controller;

use Generated\Shared\Transfer\MerchantCriteriaTransfer;
use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
use Spryker\Zed\MerchantGui\MerchantGuiConfig;
use Symfony\Component\HttpFoundation\Request;

/**
* @method \Spryker\Zed\MerchantGui\Communication\MerchantGuiCommunicationFactory getFactory()
*/
class ViewMerchantController extends AbstractController
{
/**
* @var string
*/
protected const REQUEST_ID_MERCHANT = 'id-merchant';

/**
* @var string
*/
protected const MESSAGE_MERCHANT_NOT_FOUND = 'Merchant with id `%d` doesn\'t exist.';

/**
* @var string
*/
protected const ID_MERCHANT_PLACEHOLDER = '%d';

/**
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return mixed
*/
public function indexAction(Request $request)
{
$idMerchant = $this->castId($request->get(
static::REQUEST_ID_MERCHANT,
));

$merchantCriteriaTransfer = new MerchantCriteriaTransfer();
$merchantCriteriaTransfer->setIdMerchant($idMerchant);
$merchantTransfer = $this->getFactory()->getMerchantFacade()->findOne($merchantCriteriaTransfer);

if ($merchantTransfer === null) {
$this->addErrorMessage(static::MESSAGE_MERCHANT_NOT_FOUND, [static::ID_MERCHANT_PLACEHOLDER => $idMerchant]);

return $this->redirectResponse(MerchantGuiConfig::URL_MERCHANT_LIST);
}

return $this->viewResponse([
'idMerchant' => $idMerchant,
'merchant' => $merchantTransfer,
'merchantProfile' => $merchantTransfer->getMerchantProfile(),
'storeRelations' => $merchantTransfer->getStoreRelation() ? $merchantTransfer->getStoreRelation()->getStores() : [],
'merchantUrlCollection' => $merchantTransfer->getUrlCollection(),
'merchantStockCollection' => $merchantTransfer->getStocks(),
'merchantAddressCollection' => $merchantTransfer->getMerchantProfile() ? $merchantTransfer->getMerchantProfile()->getAddressCollection() : [],
'merchantLocalizedAttributes' => $merchantTransfer->getMerchantProfile() ? $merchantTransfer->getMerchantProfile()->getMerchantProfileLocalizedGlossaryAttributes() : [],
'toggleActiveForm' => $this->getFactory()->createToggleActiveMerchantForm()->createView(),
'toggleStatusForm' => $this->getFactory()->createMerchantStatusForm()->createView(),
'merchantUserTable' => $this->getFactory()->createMerchantViewForm($merchantTransfer)->createView()->vars['tables']['merchantUsersTable'],
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\MerchantGui\Communication\Form;

use Spryker\Zed\Kernel\Communication\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;

/**
* @method \Spryker\Zed\MerchantGui\Communication\MerchantGuiCommunicationFactory getFactory()
* @method \Spryker\Zed\MerchantGui\MerchantGuiConfig getConfig()
*/
class MerchantViewForm extends AbstractType
{
/**
* @param \Symfony\Component\Form\FormView $view
* @param \Symfony\Component\Form\FormInterface $form
* @param array<string, mixed> $options
*
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options): void
{
foreach ($this->getFactory()->getMerchantViewFormViewExpanderPlugins() as $formViewExpanderPlugin) {
$view = $formViewExpanderPlugin->expand($view, $form, $options);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Spryker\Zed\MerchantGui\Communication\Form\MerchantCreateForm;
use Spryker\Zed\MerchantGui\Communication\Form\MerchantStatusForm;
use Spryker\Zed\MerchantGui\Communication\Form\MerchantUpdateForm;
use Spryker\Zed\MerchantGui\Communication\Form\MerchantViewForm;
use Spryker\Zed\MerchantGui\Communication\Form\ToggleActiveMerchantForm;
use Spryker\Zed\MerchantGui\Communication\Table\MerchantTable;
use Spryker\Zed\MerchantGui\Communication\Tabs\MerchantFormTabs;
Expand Down Expand Up @@ -125,6 +126,17 @@ public function createMerchantStatusForm(): FormInterface
return $this->getFormFactory()->create(MerchantStatusForm::class);
}

/**
* @param \Generated\Shared\Transfer\MerchantTransfer|null $data
* @param array<string, mixed> $options
*
* @return \Symfony\Component\Form\FormInterface
*/
public function createMerchantViewForm(?MerchantTransfer $data = null, array $options = []): FormInterface
{
return $this->getFormFactory()->create(MerchantViewForm::class, $data, $options);
}

/**
* @return \Spryker\Zed\MerchantGui\Dependency\Facade\MerchantGuiToMerchantFacadeInterface
*/
Expand Down Expand Up @@ -157,6 +169,14 @@ public function getMerchantUpdateFormViewExpanderPlugins(): array
return $this->getProvidedDependency(MerchantGuiDependencyProvider::PLUGINS_MERCHANT_UPDATE_FORM_VIEW_EXPANDER);
}

/**
* @return array<\Spryker\Zed\MerchantGuiExtension\Dependency\Plugin\MerchantUpdateFormViewExpanderPluginInterface>
*/
public function getMerchantViewFormViewExpanderPlugins(): array
{
return $this->getProvidedDependency(MerchantGuiDependencyProvider::PLUGINS_MERCHANT_VIEW_FORM_VIEW_EXPANDER);
}

/**
* @return array<\Spryker\Zed\MerchantGuiExtension\Dependency\Plugin\MerchantTableDataExpanderPluginInterface>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ protected function prepareData(TableConfiguration $config): array
protected function buildLinks(array $item): string
{
$buttons = [];
$buttons[] = $this->generateViewButton(
Url::generate(MerchantGuiConfig::URL_MERCHANT_VIEW, [static::REQUEST_ID_MERCHANT => $item[SpyMerchantTableMap::COL_ID_MERCHANT]]),
'View',
);
$buttons[] = $this->generateEditButton(
Url::generate(MerchantGuiConfig::URL_MERCHANT_EDIT, [EditMerchantController::REQUEST_ID_MERCHANT => $item[SpyMerchantTableMap::COL_ID_MERCHANT]]),
'Edit',
Expand Down
12 changes: 12 additions & 0 deletions src/Spryker/Zed/MerchantGui/MerchantGuiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ class MerchantGuiConfig extends AbstractBundleConfig
*/
public const URL_MERCHANT_EDIT = '/merchant-gui/edit-merchant';

/**
* Specification:
* - Base url for viewing a merchant’s page.
*
* @uses \Spryker\Zed\MerchantGui\Communication\Controller\ViewMerchantController::indexAction()
*
* @api
*
* @var string
*/
public const URL_MERCHANT_VIEW = '/merchant-gui/view-merchant';

/**
* @uses \Spryker\Zed\MerchantGui\Communication\Controller\EditMerchantController::activateAction()
*
Expand Down
28 changes: 28 additions & 0 deletions src/Spryker/Zed/MerchantGui/MerchantGuiDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class MerchantGuiDependencyProvider extends AbstractBundleDependencyProvider
*/
public const PLUGINS_MERCHANT_UPDATE_FORM_VIEW_EXPANDER = 'PLUGINS_MERCHANT_UPDATE_FORM_VIEW_EXPANDER';

/**
* @var string
*/
public const PLUGINS_MERCHANT_VIEW_FORM_VIEW_EXPANDER = 'PLUGINS_MERCHANT_VIEW_FORM_VIEW_EXPANDER';

/**
* @var string
*/
Expand All @@ -101,6 +106,7 @@ public function provideCommunicationLayerDependencies(Container $container): Con
$container = $this->addUrlFacade($container);
$container = $this->addLocaleFacade($container);
$container = $this->addMerchantUpdateFormViewExpanderPlugins($container);
$container = $this->addMerchantViewFormViewExpanderPlugins($container);
$container = $this->addStoreRelationFormTypePlugin($container);

return $container;
Expand Down Expand Up @@ -232,6 +238,20 @@ protected function addMerchantUpdateFormViewExpanderPlugins(Container $container
return $container;
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addMerchantViewFormViewExpanderPlugins(Container $container): Container
{
$container->set(static::PLUGINS_MERCHANT_VIEW_FORM_VIEW_EXPANDER, function () {
return $this->getMerchantViewFormViewExpanderPlugins();
});

return $container;
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
Expand Down Expand Up @@ -346,4 +366,12 @@ protected function getMerchantUpdateFormViewExpanderPlugins(): array
{
return [];
}

/**
* @return array<\Spryker\Zed\MerchantGuiExtension\Dependency\Plugin\MerchantUpdateFormViewExpanderPluginInterface>
*/
protected function getMerchantViewFormViewExpanderPlugins(): array
{
return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% if merchant.isActive %}
{% set actionUrl = url('/merchant-gui/edit-merchant/deactivate', { 'id-merchant': merchant.idMerchant }) %}
{% set label = 'Deactivate' | trans %}
{% set buttonClass = 'btn-remove' %}
{% set icon = 'fa-trash' %}
{% else %}
{% set actionUrl = url('/merchant-gui/edit-merchant/activate', { 'id-merchant': merchant.idMerchant }) %}
{% set label = 'Activate' | trans %}
{% set buttonClass = 'btn-view' %}
{% set icon = 'fa-caret-right' %}
{% endif %}

{{ form_start(toggleActiveForm, {
action: actionUrl,
attr: { class: 'form-inline' }
}) }}

<button class="btn btn-sm btn-outline safe-submit {{ buttonClass }}">
<i class="fa {{ icon }}"></i> {{ label }}
</button>

{{ form_end(toggleActiveForm) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% embed '@Gui/Partials/widget.twig' with { widget_title: 'Contact Person' | trans } %}
{% block widget_content %}
<div class="row">
<div class="col-xs-2"><b>{{ 'Role' | trans }}</b></div>
<div class="col-xs-10">{{ merchantProfile.contactPersonRole }}</div>
</div>
<div class="hr-line-dashed"></div>

<div class="row">
<div class="col-xs-2"><b>{{ 'Title' | trans }}</b></div>
<div class="col-xs-10">{{ merchantProfile.contactPersonTitle }}</div>
</div>
<div class="hr-line-dashed"></div>

<div class="row">
<div class="col-xs-2"><b>{{ 'First Name' | trans }}</b></div>
<div class="col-xs-10">{{ merchantProfile.contactPersonFirstName }}</div>
</div>
<div class="hr-line-dashed"></div>

<div class="row">
<div class="col-xs-2"><b>{{ 'Last Name' | trans }}</b></div>
<div class="col-xs-10">{{ merchantProfile.contactPersonLastName }}</div>
</div>
<div class="hr-line-dashed"></div>

<div class="row">
<div class="col-xs-2"><b>{{ 'Phone' | trans }}</b></div>
<div class="col-xs-10">{{ merchantProfile.contactPersonPhone }}</div>
</div>
<div class="hr-line-dashed"></div>
{% endblock %}
{% endembed %}
Loading

0 comments on commit 33d07ac

Please sign in to comment.