Files
autocrm/app/Filament/Tenant/Pages/Integrations.php
T
Vasyka f7fc69077b feat(i18n): wrap 1103 hardcoded UI strings across Filament with __()
- Convert static $modelLabel/$pluralModelLabel/$title to getter methods
- Wrap ->label()/->placeholder()/->helperText()/->description()/->title()/->body() args
- Wrap Section::make()/Fieldset::make()/Notification::make()->title() args
- Fix RelationManagers::getTitle() signature to match parent (Model, string)
- Fix Pages::getTitle() to instance method (BasePage::getTitle is non-static)
- Extend lang/ru.json + lang/en.json with 700+ common terms; identity fallback for the rest
- Remove duplicate getters in 5 resources that had manual getModelLabel already

All 306 tests pass. Missing translations fall back to the RO key so the UI never breaks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-15 05:04:24 +00:00

131 lines
4.7 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 = null;
public function getTitle(): string
{
return __('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'],
],
],
];
}
}