78ff8d4b43
User screenshots showed the tenant admin panel (Filament) had sidebar
labels stuck in Romanian even when switching to Russian: 'Cereri',
'Calendar vizual', 'Atelierul meu', 'KPI mecanici', 'Fișe lucru',
'Norme-ore', 'Tehnicieni', 'Șabloane servicii', 'Depozite', 'Scaner',
'Depozit', 'VIN-căutare', 'Furnizori', 'Achiziții', 'Procentaj',
'Coeficienți preț', plus all group headers.
Root cause: every Filament Resource and Page had static properties
'protected static ?string $navigationLabel = "Fișe lucru"' — string
literals baked into class definitions. Static properties don't run
through the translation layer.
Fix in two parts:
1. New translation files with 52 label keys + 12 group keys:
- lang/ro/nav.php — Romanian (identity)
- lang/ru/nav.php — full Russian translations (Заказ-наряды,
Автомобили, Клиенты, Календарь, Моя мастерская, Механики KPI,
Настройки, etc.)
- lang/en/nav.php — English translations (Work orders, Vehicles,
Clients, Calendar, My workshop, Mechanic KPI, Settings, etc.)
Keyed by the Romanian original so lookups map 1:1 —
'nav.label.Fișe lucru' returns 'Заказ-наряды' in RU, 'Work orders'
in EN, 'Fișe lucru' in RO.
2. Python transformer converted 54 files:
- 33 Filament Tenant Resources
- 15 Filament Tenant Pages
- 4 Filament Central Resources
- 1 Filament Central Page
- 1 Widget
Each 'protected static ?string $navigationLabel = "X";' became
'public static function getNavigationLabel(): string { return
__("nav.label.X"); }'. Same treatment for $navigationGroup.
Cleanup: 6 resources already had manually-added getNavigationLabel
methods from an earlier partial effort — those used flat JSON keys
(__("Cereri")) that never resolved. Deduped so only the nav.label.*
version remains.
Untouched (intentional):
- $modelLabel / $pluralModelLabel (used in breadcrumbs and headings —
still hardcoded, next tier of work)
- Section titles, column headers, form field labels (medium priority)
- $navigationSort (numeric, no translation needed)
- $navigationIcon (icon reference)
Suite: 306 passed (853 assertions). Unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
126 lines
4.6 KiB
PHP
126 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Pages;
|
|
|
|
use App\Tenancy\TenantManager;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Pages\Page;
|
|
|
|
class Integrations extends Page
|
|
{
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-puzzle-piece';
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return __('nav.label.Integrări');
|
|
}
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('nav.group.Marketing');
|
|
}
|
|
|
|
protected static ?int $navigationSort = 63;
|
|
|
|
protected static ?string $title = 'Integrări externe';
|
|
|
|
protected string $view = 'filament.tenant.pages.integrations';
|
|
|
|
public array $config = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$tenant = app(TenantManager::class)->current();
|
|
$this->config = (array) ($tenant?->settings['integrations'] ?? []);
|
|
}
|
|
|
|
public function setStatus(string $key, bool $enabled): void
|
|
{
|
|
$this->config[$key]['enabled'] = $enabled;
|
|
$this->save();
|
|
}
|
|
|
|
public function updateField(string $key, string $field, ?string $value): void
|
|
{
|
|
$this->config[$key][$field] = $value;
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$tenant = app(TenantManager::class)->current();
|
|
if (! $tenant) return;
|
|
$tenant->update([
|
|
'settings' => array_merge((array) $tenant->settings, [
|
|
'integrations' => $this->config,
|
|
]),
|
|
]);
|
|
Notification::make()->title('Integrări salvate')->success()->send();
|
|
}
|
|
|
|
public function integrations(): array
|
|
{
|
|
return [
|
|
'telegram_bot' => [
|
|
'name' => 'Telegram Bot',
|
|
'icon' => '✈️',
|
|
'color' => '#229ED9',
|
|
'description' => 'Primește cereri din canalul Telegram + trimite confirmări automate.',
|
|
'fields' => [
|
|
'bot_token' => ['label' => 'Bot Token', 'type' => 'password', 'placeholder' => 'din @BotFather'],
|
|
'chat_id' => ['label' => 'Channel/Chat ID', 'type' => 'text', 'placeholder' => '@psauto_md'],
|
|
],
|
|
],
|
|
'whatsapp_business' => [
|
|
'name' => 'WhatsApp Business',
|
|
'icon' => '💬',
|
|
'color' => '#25D366',
|
|
'description' => 'Trimite mesaje template către clienți (programări, confirmări).',
|
|
'fields' => [
|
|
'phone_id' => ['label' => 'Phone Number ID', 'type' => 'text'],
|
|
'token' => ['label' => 'Permanent Access Token', 'type' => 'password'],
|
|
],
|
|
],
|
|
'google_ads' => [
|
|
'name' => 'Google Ads',
|
|
'icon' => '🔍',
|
|
'color' => '#EA4335',
|
|
'description' => 'Tracking conversii — leadurile generate de campanii Google.',
|
|
'fields' => [
|
|
'customer_id' => ['label' => 'Customer ID', 'type' => 'text', 'placeholder' => '123-456-7890'],
|
|
'conversion_id' => ['label' => 'Conversion ID', 'type' => 'text'],
|
|
],
|
|
],
|
|
'facebook' => [
|
|
'name' => 'Facebook / Instagram Lead Ads',
|
|
'icon' => '📘',
|
|
'color' => '#1877F2',
|
|
'description' => 'Importă lead-uri direct din Lead Ads forms.',
|
|
'fields' => [
|
|
'page_id' => ['label' => 'Page ID', 'type' => 'text'],
|
|
'access_token' => ['label' => 'Access Token', 'type' => 'password'],
|
|
],
|
|
],
|
|
'sms_gateway' => [
|
|
'name' => 'SMS Gateway',
|
|
'icon' => '📱',
|
|
'color' => '#6366F1',
|
|
'description' => 'Trimite SMS-uri prin gateway local (Moldcell/Orange API).',
|
|
'fields' => [
|
|
'provider' => ['label' => 'Provider', 'type' => 'text', 'placeholder' => 'moldcell / orange / twilio'],
|
|
'api_key' => ['label' => 'API Key', 'type' => 'password'],
|
|
'sender_id' => ['label' => 'Sender ID', 'type' => 'text'],
|
|
],
|
|
],
|
|
'webhook_in' => [
|
|
'name' => 'Webhook intrări (formulare site)',
|
|
'icon' => '🪝',
|
|
'color' => '#8B5CF6',
|
|
'description' => 'URL secret pentru POST direct cu lead-uri din site-ul tău.',
|
|
'fields' => [
|
|
'secret' => ['label' => 'Secret token', 'type' => 'text', 'placeholder' => 'random string'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
}
|