Skip to content

Commit

Permalink
Added message when courier booking has date from future. Added flash …
Browse files Browse the repository at this point in the history
…message confirmation for booking.
  • Loading branch information
xGrz committed Jun 15, 2024
1 parent a982174 commit 584c0ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
@php use Illuminate\Support\Carbon; @endphp
<div class="grid grid-cols-1 gap-2">
<x-p-paper>
<x-p-select label="Pickup date" wire:model.live="pickupDate">
@foreach($dateOptions as $pickupDateOption)
<option>{{$pickupDateOption}}</option>
<option value="{{$pickupDateOption}}">
{{$pickupDateOption}} ({{Carbon::parse($pickupDateOption)->dayName}})
</option>
@endforeach
</x-p-select>
@if (!Carbon::parse($pickupDate)->isToday())
<div class="text-yellow-500">You book a courier with a future date</div>
@endif
</x-p-paper>

<x-p-paper>
Expand Down
1 change: 1 addition & 0 deletions src/Livewire/CreateSingleShipmentBooking.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function book()
$to = Carbon::parse($this->pickupDate . ' ' . $this->pickupTo);
try {
DHL24::booking()->book($from, $to, $this->shipment, $this->comment);
session()->flash('success', 'Courier successfully booked for ' . $from->format('d-m-Y') . ' between ' . $from->format('H:i') . '-' . $to->format('H:i'));
$this->redirectRoute('dhl24.shipments.index');
} catch (DHL24Exception $e) {
$this->dispatch('openModal', component: 'shipment-create-error', arguments: ['title' => 'Courier booking failed', 'message' => $e->getMessage()]);
Expand Down

0 comments on commit 584c0ab

Please sign in to comment.