Skip to content

Commit

Permalink
Merge pull request #30 from omnia-digital/feature/upgrade_livewire_3
Browse files Browse the repository at this point in the history
Feature/upgrade livewire 3
  • Loading branch information
joshtorres authored Sep 30, 2023
2 parents 2ab120d + cd61f5f commit 6064826
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 35 deletions.
7 changes: 4 additions & 3 deletions src/Livewire/WithInlineInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public function setEditMode()
{
$this->editMode = true;

$this->dispatchBrowserEvent('edit-mode', [
'id' => $this->model()->getKey(),
]);
$this->dispatch(
'edit-mode',
id: $this->model()->getKey(),
);
}

public function submitInlineData()
Expand Down
18 changes: 10 additions & 8 deletions src/Livewire/WithMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ trait WithMap
{
public function addPlaces(string $mapId, array $places)
{
$this->dispatchBrowserEvent($mapId, [
'type' => 'loadPlaces',
'places' => $this->formatPlaces($places),
]);
$this->dispatch(
$mapId,
type:'loadPlaces',
places:$this->formatPlaces($places),
);
}

public function flyTo(string $mapId, string $lng, string $lat)
{
$this->dispatchBrowserEvent($mapId, [
'type' => 'fly',
'coordinate' => [$lng, $lat],
]);
$this->dispatch(
$mapId,
type:'fly',
coordinate:[$lng, $lat],
);
}

public function formatPlaces(array $places): array
Expand Down
4 changes: 2 additions & 2 deletions src/Livewire/WithModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ trait WithModal
{
public function closeModal(string $modalId)
{
$this->dispatchBrowserEvent($modalId, ['type' => 'close']);
$this->dispatch($modalId, type: 'close');
}

public function openModal(string $modalId)
{
$this->dispatchBrowserEvent($modalId, ['type' => 'open']);
$this->dispatch($modalId, type: 'open');
}
}
33 changes: 18 additions & 15 deletions src/Livewire/WithNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,32 @@ trait WithNotification
{
public function success(string $message, ?array $action = null)
{
$this->dispatchBrowserEvent('notify', [
'message' => $message,
'type' => 'success',
'action' => $action,
]);
$this->dispatch(
'notify',
message: $message,
type:'success',
action:$action,
);
}

public function error(string $message, ?array $action = null)
{
$this->dispatchBrowserEvent('notify', [
'message' => $message,
'type' => 'error',
'action' => $action,
]);
$this->dispatch(
'notify',
message: $message,
type:'error',
action:$action,
);
}

public function info(string $message, ?array $action = null)
{
$this->dispatchBrowserEvent('notify', [
'message' => $message,
'type' => 'info',
'action' => $action,
]);
$this->dispatch(
'notify',
message: $message,
type:'info',
action:$action,
);
}

public function alertInvalidInput(?string $message = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Livewire/WithStepWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function next(): void
{
$livewireComponentId = $this->submit();

$this->dispatchBrowserEvent('next-step-emitted', $livewireComponentId);
$this->dispatch('next-step-emitted', $livewireComponentId);
}

public function back(): void
{
$this->dispatchBrowserEvent('previous-step-emitted');
$this->dispatch('previous-step-emitted');
}

protected function fillSessionData()
Expand Down
11 changes: 6 additions & 5 deletions src/Livewire/WithStripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ public function updateStripePaymentMethod(string $event, string $message)
$this->emitSelf('stripePaymentMethodUpdated', $billable);

// Let Alpinejs now Stripe payment method updated.
$this->dispatchBrowserEvent('stripe-payment-method-updated');
$this->dispatch('stripe-payment-method-updated');

// Notify payment method was updated.
$this->dispatchBrowserEvent(empty($event) ? 'notify' : $event, [
'type' => 'success',
'message' => empty($message) ? 'Your payment method was updated!' : $message,
]);
$this->dispatch(
empty($event) ? 'notify' : $event,
type: 'success',
message: empty($message) ? 'Your payment method was updated!' : $message,
);

return [
'card_brand' => $billable->card_brand,
Expand Down

0 comments on commit 6064826

Please sign in to comment.