Skip to content

Commit

Permalink
Merge pull request #1 from jj15asmr/dev-livewire-v3-upgrade
Browse files Browse the repository at this point in the history
Upgrade Livewire v2 to v3
  • Loading branch information
jj15asmr authored Nov 26, 2023
2 parents 398c176 + c38394b commit 84bcb54
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 70 deletions.
8 changes: 4 additions & 4 deletions app/Actions/CalculateTotalDomainCostsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public function __invoke(string $domains): array
);

// Add the domain's individual registration & renewal price
$total_costs['domains'][$domain]['registration'] = $domain_price->registration_price ?? Money::USD(0);
$total_costs['domains'][$domain]['renewal'] = $domain_price->renewal_price ?? Money::USD(0);
$total_costs['domains'][$domain]['registration'] = ($domain_price->registration_price ?? Money::USD(0))->format();
$total_costs['domains'][$domain]['renewal'] = ($domain_price->renewal_price ?? Money::USD(0))->format();
}

$total_costs = Arr::prepend($total_costs, count($total_costs['domains']), 'total_domains');
$total_costs = Arr::prepend($total_costs, $total_renewal_cost, 'total_renewal');
$total_costs = Arr::prepend($total_costs, $total_registration_cost, 'total_registration');
$total_costs = Arr::prepend($total_costs, $total_renewal_cost->format(), 'total_renewal');
$total_costs = Arr::prepend($total_costs, $total_registration_cost->format(), 'total_registration');

return $total_costs;
}
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Livewire/DomainCostsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Livewire;

use App\Actions\CalculateTotalDomainCostsAction;
use App\Exceptions\{InvalidDomainException, DomainsArrayEmptyException};
use App\Exceptions\InvalidDomainException;
use Illuminate\Support\Facades\Storage;
use Livewire\Component;

Expand Down Expand Up @@ -32,7 +32,6 @@ public function calculate(CalculateTotalDomainCostsAction $calculate): void

try {
$this->total_costs = $calculate($this->domains);
$this->emit('totalCostsCalculated');

} catch (InvalidDomainException $ex) {
$this->addError('domains', "\"{$ex->domain}\" doesn't seem to be a valid domain, please check :)");
Expand All @@ -41,8 +40,7 @@ public function calculate(CalculateTotalDomainCostsAction $calculate): void

public function resetCalculation(bool $hard = false): void
{
(!$hard) ? $this->reset('total_costs') : $this->reset(['domains', 'total_costs']);
$this->emit('caculationReset');
!$hard ? $this->total_costs = null : $this->domains = $this->total_costs = null;
}

public function render(): mixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/tinker": "^2.8",
"livewire/livewire": "^2.12"
"livewire/livewire": "^3.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
Expand Down
108 changes: 83 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 84bcb54

Please sign in to comment.