From 2fcac9edfc22f2cf82f2543b3bc458c5bfa81922 Mon Sep 17 00:00:00 2001 From: Baspa Date: Fri, 30 Aug 2024 09:44:35 +0000 Subject: [PATCH] Fix styling --- src/Models/Mail.php | 2 +- src/Resources/MailResource.php | 36 ++++++++----------- .../MailResource/Pages/ListMails.php | 16 ++++----- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/Models/Mail.php b/src/Models/Mail.php index 46756d3..eff6e04 100644 --- a/src/Models/Mail.php +++ b/src/Models/Mail.php @@ -51,4 +51,4 @@ public function getStatusAttribute(): string return 'Pending'; } } -} \ No newline at end of file +} diff --git a/src/Resources/MailResource.php b/src/Resources/MailResource.php index f635cc9..aa2d2c1 100644 --- a/src/Resources/MailResource.php +++ b/src/Resources/MailResource.php @@ -2,22 +2,15 @@ namespace Vormkracht10\FilamentMails\Resources; -use Filament\Forms\Form; -use Filament\Tables\Table; -use Filament\Infolists\Infolist; -use Filament\Resources\Resource; use Filament\Infolists\Components\Grid; -use Filament\Infolists\Components\Tabs; -use Filament\Tables\Actions\EditAction; -use Filament\Tables\Actions\ViewAction; -use Filament\Tables\Actions\ActionGroup; -use Filament\Forms\Components\FileUpload; -use Filament\Tables\Actions\DeleteAction; -use Illuminate\Database\Eloquent\Builder; use Filament\Infolists\Components\Section; +use Filament\Infolists\Components\Tabs; use Filament\Infolists\Components\Tabs\Tab; -use Vormkracht10\FilamentMails\Models\Mail; use Filament\Infolists\Components\TextEntry; +use Filament\Infolists\Infolist; +use Filament\Resources\Resource; +use Filament\Tables\Table; +use Vormkracht10\FilamentMails\Models\Mail; use Vormkracht10\FilamentMails\Resources\MailResource\Pages\ListMails; use Vormkracht10\Mails\Models\Mail; @@ -75,22 +68,22 @@ public static function infolist(Infolist $infolist): Infolist ->label(__('Subject')), TextEntry::make('from') ->label(__('From')) - ->formatStateUsing(fn($state) => self::formatEmailAddress($state)), + ->formatStateUsing(fn ($state) => self::formatEmailAddress($state)), TextEntry::make('to') ->label(__('Recipient')) - ->formatStateUsing(fn($state) => self::formatEmailAddress($state)), + ->formatStateUsing(fn ($state) => self::formatEmailAddress($state)), TextEntry::make('cc') ->label(__('CC')) ->default('-') - ->formatStateUsing(fn($state) => self::formatEmailAddress($state)), + ->formatStateUsing(fn ($state) => self::formatEmailAddress($state)), TextEntry::make('bcc') ->label(__('BCC')) ->default('-') - ->formatStateUsing(fn($state) => self::formatEmailAddress($state)), + ->formatStateUsing(fn ($state) => self::formatEmailAddress($state)), TextEntry::make('reply_to') ->default('-') ->label(__('Reply To')) - ->formatStateUsing(fn($state) => self::formatEmailAddress($state)), + ->formatStateUsing(fn ($state) => self::formatEmailAddress($state)), ]), ]), Section::make('Content') @@ -182,7 +175,7 @@ public static function table(Table $table): Table ->label(__('Status')) ->sortable() ->badge() - ->color(fn(string $state): string => match ($state) { + ->color(fn (string $state): string => match ($state) { 'Hard Bounced' => 'danger', 'Soft Bounced' => 'warning', 'Complained' => 'danger', @@ -201,7 +194,7 @@ public static function table(Table $table): Table ->searchable(), Tables\Columns\TextColumn::make('to') ->label(__('Recipient')) - ->formatStateUsing(fn($state) => self::formatEmailAddress($state)) + ->formatStateUsing(fn ($state) => self::formatEmailAddress($state)) ->sortable() ->searchable(), Tables\Columns\TextColumn::make('sent_at') @@ -234,7 +227,6 @@ public static function getPages(): array ]; } - private static function formatEmailAddress($state): string { if (empty($state)) { @@ -243,7 +235,7 @@ private static function formatEmailAddress($state): string $data = json_decode($state, true); - if (!is_array($data)) { + if (! is_array($data)) { return (string) $state; // Return the original state if it's not valid JSON } @@ -251,4 +243,4 @@ private static function formatEmailAddress($state): string return $name === null ? $email : "$name <$email>"; }, array_keys($data), $data)); } -} \ No newline at end of file +} diff --git a/src/Resources/MailResource/Pages/ListMails.php b/src/Resources/MailResource/Pages/ListMails.php index f6f60ef..31bd055 100644 --- a/src/Resources/MailResource/Pages/ListMails.php +++ b/src/Resources/MailResource/Pages/ListMails.php @@ -2,11 +2,11 @@ namespace Vormkracht10\FilamentMails\Resources\MailResource\Pages; -use Filament\Resources\Pages\ListRecords; -use Vormkracht10\FilamentMails\Resources\MailResource; use Filament\Resources\Components\Tab; +use Filament\Resources\Pages\ListRecords; use Illuminate\Database\Eloquent\Builder; use Vormkracht10\FilamentMails\Models\Mail; +use Vormkracht10\FilamentMails\Resources\MailResource; class ListMails extends ListRecords { @@ -33,17 +33,17 @@ public function getTabs(): array ->label(__('Sent')) ->icon('heroicon-o-paper-airplane') ->badge(Mail::sent()->count()) - ->modifyQueryUsing(fn(Builder $query) => $query->sent()), + ->modifyQueryUsing(fn (Builder $query) => $query->sent()), 'delivered' => Tab::make() ->label(__('Delivered')) ->icon('heroicon-o-check-circle') ->badge(Mail::delivered()->count()) - ->modifyQueryUsing(fn(Builder $query) => $query->delivered()), + ->modifyQueryUsing(fn (Builder $query) => $query->delivered()), 'bounced' => Tab::make() ->label(__('Bounced')) ->icon('heroicon-o-x-circle') - ->badge(fn() => Mail::softBounced()->count() + Mail::hardBounced()->count()) - ->modifyQueryUsing(fn(Builder $query) => $query->where(function ($query) { + ->badge(fn () => Mail::softBounced()->count() + Mail::hardBounced()->count()) + ->modifyQueryUsing(fn (Builder $query) => $query->where(function ($query) { $query->softBounced()->orWhere(function ($query) { $query->hardBounced(); }); @@ -52,7 +52,7 @@ public function getTabs(): array ->label(__('Unsent')) ->icon('heroicon-o-x-circle') ->badge(Mail::unsent()->count()) - ->modifyQueryUsing(fn(Builder $query) => $query->unsent()), + ->modifyQueryUsing(fn (Builder $query) => $query->unsent()), ]; } -} \ No newline at end of file +}