Fix: Updates to OrderFullfilmentServices and box now clients, order views and checkout services
This commit is contained in:
1 parent
dcdc998eee
commit
12aaa43f10
15 files changed
+450
-18
No files matched your search
@@ -5,6 +5,8 @@ namespace Modules\Core\Shipping\Extensions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Illuminate\Support\Collection;
|
||||
use Modules\Core\Shipping\Models\ShipmentInfo;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
@@ -112,10 +114,34 @@ class OrderShipmentsExtension extends ViewPageExtension
|
||||
->action(fn (Shipment $record) => $this->cancel($record))
|
||||
->visible(fn (Shipment $record) => ! $record->cancelled_at),
|
||||
]),
|
||||
RepeatableEntry::make('shipmentInfo')
|
||||
->label('Tracking history')
|
||||
->state(fn (Shipment $record) => $this->orderedCheckpoints($record))
|
||||
->hidden(fn (Shipment $record) => $record->shipmentInfo->isEmpty())
|
||||
->schema([
|
||||
TextEntry::make('status')
|
||||
->label(fn (ShipmentInfo $record) => $record->occurred_at->format('Y-m-d H:i'))
|
||||
->inlineLabel()
|
||||
->state(fn (ShipmentInfo $record) => (string) str($record->status->value)->replace('_', ' ')->title())
|
||||
->helperText(fn (ShipmentInfo $record) => $record->location),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Oldest first — a delivery journey (Collected → In Transit →
|
||||
* Delivered) reads naturally top-to-bottom in that order, unlike
|
||||
* statusLabel()/statusColor() above which only ever need the single
|
||||
* latest checkpoint and so use latestShipmentInfo() directly instead.
|
||||
*
|
||||
* @return Collection<int, ShipmentInfo>
|
||||
*/
|
||||
private function orderedCheckpoints(Shipment $record): Collection
|
||||
{
|
||||
return $record->shipmentInfo->sortBy('occurred_at')->values();
|
||||
}
|
||||
|
||||
private function carrierLabel(Shipment $record): string
|
||||
{
|
||||
return match ($record->carrier) {
|
||||
|
||||
Reference in new issue
Block a user