Feat: Shipping functionalities redesign, elta courier integration, commenting out acs since no integration can happen, flow updates
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Shipping\ActivityLog;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Lunar\Admin\Support\ActivityLog\AbstractRender;
|
||||
use Modules\Core\Shipping\Support\ShipmentTimelineLogger;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Draws a shipment checkpoint on the order page's Timeline (logged by
|
||||
* ShipmentTimelineLogger): carrier + voucher, the status badge, and the
|
||||
* carrier's own location / text.
|
||||
*/
|
||||
class ShipmentCheckpointRender extends AbstractRender
|
||||
{
|
||||
public function getEvent(): string
|
||||
{
|
||||
return ShipmentTimelineLogger::EVENT;
|
||||
}
|
||||
|
||||
public function render(Activity $log)
|
||||
{
|
||||
$status = (string) $log->getExtraProperty('status');
|
||||
$occurredAt = $log->getExtraProperty('occurred_at');
|
||||
|
||||
return view('core::shipping.activity.shipment-checkpoint', [
|
||||
'carrier' => $log->getExtraProperty('carrier'),
|
||||
'trackingReference' => $log->getExtraProperty('tracking_reference'),
|
||||
'isReturn' => (bool) $log->getExtraProperty('is_return'),
|
||||
'statusLabel' => (string) str($status)->replace('_', ' ')->title(),
|
||||
'statusColor' => match ($status) {
|
||||
'delivered' => 'success',
|
||||
'failed', 'returned', 'cancelled' => 'danger',
|
||||
'in_transit', 'out_for_delivery', 'collected_from_sender' => 'warning',
|
||||
default => 'gray',
|
||||
},
|
||||
'details' => collect([
|
||||
$log->getExtraProperty('location'),
|
||||
$log->getExtraProperty('message') ?: $log->getExtraProperty('carrier_status'),
|
||||
])->filter()->unique()->implode(' · '),
|
||||
'occurredAt' => $occurredAt ? Carbon::parse($occurredAt)->timezone(config('app.timezone')) : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user