Skip to content

Add currency to users, locale/currency to admin profile, fix hardcoded dark-mode in infra views#14

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-locale-currency-to-user
Draft

Add currency to users, locale/currency to admin profile, fix hardcoded dark-mode in infra views#14
Copilot wants to merge 2 commits intomainfrom
copilot/add-locale-currency-to-user

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

Three related gaps: currency missing from User.$fillable and the DB, admin panel Profile page lacking locale/currency fields, and infra views forcing dark theme via hardcoded inline styles that break the light theme.

User model & DB

  • Added currency to User::$fillable
  • getActiveCurrencyAttribute() now falls back to $this->currency instead of always returning 'BRL' for admin users
  • New migration adds currency VARCHAR(10) DEFAULT 'BRL' to users table

Admin Profile page

Added "Moeda e Idioma" section to bring the admin profile to parity with distributor/partner panels:

// mount() — initialize from user record
'locale'   => $user->locale   ?? 'pt_BR',
'currency' => $user->currency ?? 'BRL',

// saveProfile() — persist and apply immediately
$user->locale   = $data['locale']   ?? 'pt_BR';
$user->currency = $data['currency'] ?? 'BRL';
$user->save();
session(['locale' => $user->locale]);
app()->setLocale($user->locale);

Dark-mode fixes in infra views

Root cause: views used .infra-dark { background-color:#1f2937 !important } + style="color-scheme:dark;background-color:#1f2937" inline overrides, forcing dark backgrounds regardless of the Filament theme.

  • partner & distributor customer-infra.blade.php: removed both <style>.infra-dark</style> blocks and <div class="infra-dark"> wrapper; removed all $icStyle inline style attributes; updated proposta_currency/sim_currency selects and backup machine inputs
  • admin customer-infra.blade.php: updated $ic/$sc PHP variables
  • All input/select classes now use the bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-900 dark:text-white pattern
Original prompt

Contexto

O projeto é um ERP Laravel/Filament com três painéis (admin, distributor, partner). Os arquivos de tradução já foram criados (lang/pt_BR/app.php, lang/en/app.php, lang/es/app.php), o middleware SetLocale já existe e está registrado em bootstrap/app.php e nos três PanelProviders. Agora precisamos garantir que:

  1. A linguagem persista para o sistema inteiro — o middleware já está no lugar, mas falta garantir que o User model tenha locale e currency no $fillable, e que o LocaleController persista corretamente.
  2. O perfil do admin (Admin\Pages\Profile) tenha campos de Moeda e Idioma — atualmente só tem nome, e-mail, telefone e senha. Os painéis distributor e partner já têm esses campos no EditProfile, mas o admin não tem.
  3. Views com fundo branco hardcoded devem usar as classes Tailwind com dark-mode do Filament — várias views usam bg-white sem dark:bg-gray-*, classes fixas de tema escuro (bg-gray-800, bg-gray-900 hardcoded sem fallback para tema claro), e o arquivo customer-infra-pricing-modal.blade.php usa bg-white sem suporte dark. Isso causa o fundo branco visível na screenshot.

Screenshot do problema

image1

A página de Infraestrutura mostra fundo branco porque as views estão usando cores hardcoded em vez de usar as variáveis de tema do Filament.


Tarefas a implementar

1. Garantir persistência global do locale/currency

app/Models/User.php — adicionar locale e currency ao $fillable:

protected $fillable = [
    // ... campos existentes ...
    'locale',
    'currency',
];

Verificar se currency existe na tabela users. Se não existir, criar migration:

database/migrations/2026_03_05_000002_add_currency_to_users_table.php

app/Http/Controllers/LocaleController.php — já persiste locale no user. Confirmar que está correto (já parece ok).


2. Adicionar campos de Moeda e Idioma ao perfil do Admin

app/Filament/Admin/Pages/Profile.php — adicionar seção "Moeda e Idioma" ao profileForm:

use Filament\Forms\Components\Select;

// No profileForm, após a seção "Informações Pessoais":
Section::make('Moeda e Idioma')
    ->icon('heroicon-o-currency-dollar')
    ->description('Define o idioma da interface e a moeda padrão para exibição de valores')
    ->schema([
        Grid::make(2)->schema([
            Select::make('locale')
                ->label(__('app.profile.language'))
                ->options([
                    'pt_BR' => '🇧🇷 Português (BR)',
                    'en'    => '🇺🇸 English',
                    'es'    => '🇪🇸 Español',
                ])
                ->native(false)
                ->required(),

            Select::make('currency')
                ->label(__('app.profile.currency'))
                ->options([
                    'BRL' => '🇧🇷 Real (R$)',
                    'USD' => '🇺🇸 Dólar (US$)',
                    'EUR' => '🇪🇺 Euro (€)',
                    'PYG' => '🇵🇾 Guarani (₲)',
                    'ARS' => '🇦🇷 Peso Argentino ($)',
                ])
                ->native(false)
                ->required(),
        ]),
    ]),

No mount(), incluir locale e currency no profileData:

$this->profileData = [
    'name'     => $user->name,
    'email'    => $user->email,
    'phone'    => $user->phone,
    'locale'   => $user->locale   ?? 'pt_BR',
    'currency' => $user->currency ?? 'BRL',
];

No saveProfile(), persistir e aplicar o locale:

$user->locale   = $data['locale']   ?? 'pt_BR';
$user->currency = $data['currency'] ?? 'BRL';
$user->save();

// Aplicar locale na sessão e na app imediatamente
session(['locale' => $user->locale]);
app()->setLocale($user->locale);

3. Corrigir views com fundo branco / cores hardcoded para usar tema Filament

O problema principal é que várias views usam classes Tailwind de tema escuro fixo (bg-gray-800, bg-gray-900) ou branco fixo (bg-white) sem suporte ao tema claro/escuro do Filament (que usa dark: prefix).

Arquivos a corrigir:

resources/views/filament/partner/resources/customer-resource/pages/customer-infra.blade.php

  • Remover os <style> duplicados com .infra-dark hardcoded em dark
  • Substituir as variáveis PHP de classe ($ic, $sc, $lc, $bp, $bd, $bg) por classes que funcionem tanto no tema claro quanto escuro, ex:
    • $ic: 'w-full rounded-lg px-3 py-2 text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-white focus:outline-none focus:border-primary-500 focus:ring-1 focus:ring-primary-500'
    • $sc: mesmo padrão
    • Remover $icStyle inline com background-color:#1f2937
  • Remover <div class="infra-dark"> e o </div> correspondente
  • No seletor de moeda inline (dropdown proposta_currency), trocar style="color-scheme:dark;background-color:#1f2937;" por classes Tailwind: `class="w-full rounded-lg bg-white dark:bg-gray-800 border border-gray...

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…dark mode in infra views

Co-authored-by: gerichkoeke <125511907+gerichkoeke@users.noreply.github.com>
Copilot AI changed the title [WIP] Update User model to include locale and currency Add currency to users, locale/currency to admin profile, fix hardcoded dark-mode in infra views Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants