Skip to content

Commit

Permalink
Merge branch '1.x' of github.com:lunarphp/lunar into feature/shipping…
Browse files Browse the repository at this point in the history
…-addon
  • Loading branch information
alecritson committed Jan 5, 2024
2 parents 46374d8 + babd93d commit a79f5f6
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 219 deletions.
28 changes: 28 additions & 0 deletions packages/admin/resources/lang/en/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,32 @@
'label' => 'Delete',
],
],
'orders' => [
'update_status' => [
'label' => 'Update Status',
'wizard' => [
'step_one' => [
'label' => 'Status',
],
'step_two' => [
'label' => 'Mailers & Notifications',
'no_mailers' => 'There are no mailers available for this status.',
],
'step_three' => [
'label' => 'Preview & Save',
'no_mailers' => 'No mailers have been chosen for preview.',
],
],
'notification' => [
'label' => 'Order status updated',
],
'billing_email' => [
'label' => 'Billing Email',
],
'shipping_email' => [
'label' => 'Shipping Email',
],
],

],
];
13 changes: 10 additions & 3 deletions packages/admin/resources/lang/en/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,16 @@
'notification' => 'Orders status updated',
],
'update_status' => [
'label' => 'Update Status',
'notification' => 'Order status updated',
'new_status' => [
'label' => 'New status',
],
'additional_content' => [
'label' => 'Additional content',
],
'additional_email_recipient' => [
'label' => 'Additional email recipient',
'placeholder' => 'optional',
],
],
'download_order_pdf' => [
'label' => 'Download PDF',
Expand Down Expand Up @@ -254,7 +262,6 @@
'success' => 'Capture successful',
],
],

'refund_payment' => [
'label' => 'Refund',

Expand Down
54 changes: 0 additions & 54 deletions packages/admin/resources/views/components/alert.blade.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class="px-3 text-gray-500 appearance-none"
</div>
</button>

<div class="items-center flex-shrink-0 hidden px-2 space-x-2 rtl:space-x-reverse group-hover:flex">
<div class="flex items-center flex-shrink-0 px-2 space-x-2 rtl:space-x-reverse">
<x-filament-actions::group
:actions="$actions"
label="Actions"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div>
@if(count($getMailers()))
<x-filament::input.wrapper>
<x-filament::input.select wire:model="selectedMailer">
@foreach($getMailers() as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</x-filament::input.select>
</x-filament::input.wrapper>

<div class="mt-4">
<iframe
srcdoc="{{ $getPreview() }}"
class="grow w-full h-full"
style="height:500px"
></iframe>
</div>
@endif
</div>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preview mailer!
19 changes: 2 additions & 17 deletions packages/admin/src/Filament/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

namespace Lunar\Admin\Filament\Resources;

use Filament\Forms;
use Filament\Notifications\Notification;
use Filament\Support\Facades\FilamentIcon;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Collection;
use Lunar\Admin\Filament\Resources\OrderResource\Pages;
use Lunar\Admin\Filament\Resources\OrderResource\Pages\ManageOrder;
use Lunar\Admin\Support\Actions\Orders\UpdateStatusBulkAction;
use Lunar\Admin\Support\OrderStatus;
use Lunar\Admin\Support\Resources\BaseResource;
use Lunar\Models\Order;
Expand Down Expand Up @@ -60,20 +58,7 @@ public static function getDefaultTable(Table $table): Table
->recordUrl(fn ($record) => ManageOrder::getUrl(['record' => $record]))
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\BulkAction::make('update_status')
->label(__('lunarpanel::order.action.bulk_update_status.label'))
->form([
Forms\Components\Select::make('status')
->label(__('lunarpanel::order.table.status.label'))
->options(fn () => collect(config('lunar.orders.statuses', []))
->mapWithKeys(fn ($data, $status) => [$status => $data['label']]))
->required(),
])
->modalWidth('md')
->action(fn (Collection $records, $data) => $records->toQuery()->update([
'status' => $data['status'],
]))
->after(fn () => Notification::make()->title(__('lunarpanel::order.action.bulk_update_status.notification'))->success()->send())
UpdateStatusBulkAction::make('update_status')
->deselectRecordsAfterCompletion(),
]),
])
Expand Down
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,15 +19,16 @@
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;
use Livewire\Attributes\Computed;
use Lunar\Admin\Filament\Resources\CustomerResource;
use Lunar\Admin\Filament\Resources\OrderResource;
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 @@ -78,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 @@ -631,23 +635,12 @@ protected function getHeaderActions(): array
return [
$this->getCaptureAction(),
$this->getRefundAction(),
Actions\Action::make('update_status')
->label(__('lunarpanel::order.action.update_status.label'))
->form(fn () => [
Forms\Components\Select::make('status')
->label(__('lunarpanel::order.form.status.label'))
->default(fn ($record) => $record->status)
->options(fn () => collect(config('lunar.orders.statuses', []))
->mapWithKeys(fn ($data, $status) => [$status => $data['label']]))
->required(),
])
->modalWidth('md')
->slideOver()
->action(fn ($record, $data) => $record
->update([
'status' => $data['status'],
]))
->after(fn () => $this->dispatchActivityUpdated() && Notification::make()->title(__('lunarpanel::order.action.update_status.notification'))->success()->send()),
UpdateStatusAction::make('update_status')
->after(
function () {
$this->dispatchActivityUpdated();
}
),
Actions\Action::make('download_pdf')
->label(__('lunarpanel::order.action.download_order_pdf.label'))
->action(function ($record) {
Expand Down Expand Up @@ -780,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 @@ -789,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
2 changes: 1 addition & 1 deletion packages/admin/src/LunarPanelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class LunarPanelManager

protected static $pages = [
Pages\Dashboard::class,
// Pages\Reports\SalesReport::class,
];

protected static $widgets = [
Expand Down Expand Up @@ -132,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
32 changes: 32 additions & 0 deletions packages/admin/src/Support/Actions/Orders/UpdateStatusAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Lunar\Admin\Support\Actions\Orders;

use Filament\Actions\Action;
use Filament\Support\Enums\MaxWidth;
use Lunar\Admin\Support\Actions\Traits\UpdatesOrderStatus;
use Lunar\Models\Order;

class UpdateStatusAction extends Action
{
use UpdatesOrderStatus;

protected function setUp(): void
{
parent::setUp();

$this->label(
__('lunarpanel::actions.orders.update_status.label')
);

$this->modalWidth(MaxWidth::TwoExtraLarge);

$this->steps(
$this->getFormSteps()
);

$this->action(
fn (Order $record, array $data) => $this->updateStatus($record, $data)
);
}
}
Loading

0 comments on commit a79f5f6

Please sign in to comment.