Skip to content

Commit

Permalink
Use Shout instead of custom alert component (#1449)
Browse files Browse the repository at this point in the history
Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>
  • Loading branch information
wychoong and glennjacobs authored Jan 5, 2024
1 parent 4cde47f commit babd93d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 179 deletions.
54 changes: 0 additions & 54 deletions packages/admin/resources/views/components/alert.blade.php

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Lunar\Admin\Filament\Resources\OrderResource\Pages;

use Awcodes\Shout\Components\Shout;
use Awcodes\Shout\Components\ShoutEntry;
use Barryvdh\DomPDF\Facade\Pdf;
use Closure;
use Filament\Actions;
Expand All @@ -17,6 +19,7 @@
use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\IconPosition;
use Filament\Support\Facades\FilamentIcon;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
use Illuminate\Support\HtmlString;
Expand All @@ -26,7 +29,6 @@
use Lunar\Admin\Filament\Resources\OrderResource\Pages\Components\OrderItemsTable;
use Lunar\Admin\Support\Actions\Orders\UpdateStatusAction;
use Lunar\Admin\Support\ActivityLog\Concerns\CanDispatchActivityUpdated;
use Lunar\Admin\Support\Infolists\Components\Alert;
use Lunar\Admin\Support\Infolists\Components\Livewire;
use Lunar\Admin\Support\Infolists\Components\Tags;
use Lunar\Admin\Support\Infolists\Components\Timeline;
Expand Down Expand Up @@ -79,18 +81,19 @@ public function infolist(Infolist $infolist): Infolist
->schema([
Infolists\Components\Group::make()
->schema([
Alert::make('requires_capture')
->danger()
ShoutEntry::make('requires_capture')
->type('danger')
->content(__('lunarpanel::order.infolist.alert.requires_capture'))
->visible(fn () => $this->requiresCapture),
Alert::make('requires_capture')
ShoutEntry::make('requires_capture')
->state(fn () => $this->paymentStatus)
->icons(fn ($state) => [
'heroicon-o-exclamation-circle' => 'refunded',
])
->configureColor(fn (Alert $component, $state) => match ($state) {
'partial-refund' => $component->info(),
'refunded' => $component->danger(),
->icon(fn ($state) => match ($state) {
'refunded' => FilamentIcon::resolve('lunar::exclamation-circle'),
default => null
})
->color(fn (ShoutEntry $component, $state) => match ($state) {
'partial-refund' => 'info',
'refunded' => 'danger',
default => null
})->content(fn ($state) => match ($state) {
'partial-refund' => __('lunarpanel::order.infolist.alert.partially_refunded'),
Expand Down Expand Up @@ -770,7 +773,7 @@ protected function getCaptureAction(): Actions\Action
->live()
->autocomplete(false)
->minValue(1)
->helperText(function ($get, $state) {
->helperText(function (Forms\Components\TextInput $component, $get, $state) {
$transaction = Transaction::findOrFail($get('transaction'));

$message = $transaction->amount->decimal > $state ? __('lunarpanel::order.form.amount.hint.less_than_total') : null;
Expand All @@ -779,10 +782,11 @@ protected function getCaptureAction(): Actions\Action
return null;
}

return view('lunarpanel::components.alert', [
'content' => $message,
'color' => 'danger',
]);
return Shout::make('alert')
->container($component->getContainer())
->type('danger')
->icon(FilamentIcon::resolve('lunar::exclamation-circle'))
->content($message);
})
->numeric(),
Forms\Components\Toggle::make('confirm')
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src/LunarPanelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public function register(): self
'lunar::image-placeholder' => 'lucide-image',
'lunar::trending-up' => 'lucide-trending-up',
'lunar::trending-down' => 'lucide-trending-down',
'lunar::exclamation-circle' => 'lucide-alert-circle',
]);

FilamentColor::register([
Expand Down
97 changes: 0 additions & 97 deletions packages/admin/src/Support/Infolists/Components/Alert.php

This file was deleted.

0 comments on commit babd93d

Please sign in to comment.