feat: add customizable text for manager contact button

- Add text_manager_button field to TextsDTO with getter method
- Update SettingsSerializerService to validate and deserialize new field
- Add text_manager_button field to admin settings store
- Add input field in admin TextsView for configuring button text
- Update SPA SettingsStore with default value including emoji
- Replace hardcoded button text in Product.vue with configurable text
- Remove SVG icon from manager button to allow emoji usage
- Add default value with emoji to app.php configuration
- Button text now customizable via admin panel Texts tab
This commit is contained in:
2025-12-25 20:43:12 +03:00
parent 551c4a3506
commit 0a7877ddbe
7 changed files with 24 additions and 8 deletions

View File

@@ -57,6 +57,7 @@ export const useSettingsStore = defineStore('settings', {
start_button: {
text: '',
},
text_manager_button: '',
},
sliders: {

View File

@@ -30,6 +30,10 @@
<ItemInput label="Текст кнопки приветственного сообщения" v-model="settings.items.texts.start_button.text">
Текст на кнопке приветственного сообщения, которая открывает магазин.
</ItemInput>
<ItemInput label="Текст кнопки связи с менеджером" v-model="settings.items.texts.text_manager_button" placeholder="Связаться с менеджером">
Текст на кнопке для связи с менеджером на странице товара. Используется только при выборе режима "Кнопка связи с менеджером" в настройках витрины.
</ItemInput>
</template>
<script setup>

View File

@@ -24,6 +24,7 @@ export const useSettingsStore = defineStore('settings', {
text_no_more_products: 'Нет товаров',
text_empty_cart: 'Корзина пуста',
text_order_created_success: 'Заказ успешно оформлен.',
text_manager_button: '💬 Связаться с менеджером',
},
mainpage_blocks: [],
is_privacy_consented: true,

View File

@@ -184,12 +184,7 @@
@click="openManagerChat"
>
<template v-if="settings.manager_username">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round"
d="M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 0 1-.825-.242m9.345-8.334a2.126 2.126 0 0 0-.476-.095 48.64 48.64 0 0 0-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0 0 11.25 3c-2.115 0-4.198.137-5.74.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155"/>
</svg>
Связаться с менеджером
{{ settings.texts?.text_manager_button || '💬 Связаться с менеджером' }}
</template>
<template v-else>Менеджер недоступен</template>
</button>

View File

@@ -63,6 +63,7 @@ HTML,
'text_no_more_products' => 'Это всё по текущему запросу. Попробуйте уточнить фильтры или поиск.',
'text_empty_cart' => 'Ваша корзина пуста.',
'text_order_created_success' => 'Ваш заказ успешно оформлен и будет обработан в ближайшее время.',
'text_manager_button' => '💬 Связаться с менеджером',
'start_message' => <<<HTML
👋 <b>Добро пожаловать!</b>

View File

@@ -7,15 +7,18 @@ final class TextsDTO
private string $textNoMoreProducts;
private string $textEmptyCart;
private string $textOrderCreatedSuccess;
private string $textManagerButton;
public function __construct(
string $textNoMoreProducts,
string $textEmptyCart,
string $textOrderCreatedSuccess
string $textOrderCreatedSuccess,
string $textManagerButton
) {
$this->textNoMoreProducts = $textNoMoreProducts;
$this->textEmptyCart = $textEmptyCart;
$this->textOrderCreatedSuccess = $textOrderCreatedSuccess;
$this->textManagerButton = $textManagerButton;
}
public function getTextNoMoreProducts(): string
@@ -33,12 +36,18 @@ final class TextsDTO
return $this->textOrderCreatedSuccess;
}
public function getTextManagerButton(): string
{
return $this->textManagerButton;
}
public function toArray(): array
{
return [
'text_no_more_products' => $this->textNoMoreProducts,
'text_empty_cart' => $this->textEmptyCart,
'text_order_created_success' => $this->textOrderCreatedSuccess,
'text_manager_button' => $this->textManagerButton,
];
}
}

View File

@@ -170,7 +170,8 @@ class SettingsSerializerService
return new TextsDTO(
$data['text_no_more_products'],
$data['text_empty_cart'],
$data['text_order_created_success']
$data['text_order_created_success'],
$data['text_manager_button'] ?? ''
);
}
@@ -377,6 +378,10 @@ class SettingsSerializerService
if (isset($data['text_order_created_success']) && ! is_string($data['text_order_created_success'])) {
throw new InvalidArgumentException('texts.text_order_created_success must be a string');
}
if (isset($data['text_manager_button']) && ! is_string($data['text_manager_button'])) {
throw new InvalidArgumentException('texts.text_manager_button must be a string');
}
}
private function deserializeLogs(array $logs): LogsDTO