CluPilotCloud/app/Livewire/ConfirmWithdraw.php

47 lines
1.6 KiB
PHP

<?php
namespace App\Livewire;
use App\Livewire\Concerns\ResolvesCustomer;
use App\Services\Billing\CustomDomainAccess;
use App\Services\Billing\WithdrawalRight;
use LivewireUI\Modal\ModalComponent;
/**
* Confirmation before a consumer withdraws from their contract (R23).
*
* The heaviest button in the portal: it ends the cloud the same afternoon, takes
* the address down and sends the money back, and none of that can be undone by
* clicking again. So it is confirmed in a dialog this product draws rather than
* one the browser does.
*
* The figures are read again here, not handed in from the page. A modal is
* opened with arguments from markup, and markup is not evidence — a dialog that
* says "37,00 € kommen zurück" has to have worked that out from the contract it
* is about, or it is a promise nobody made.
*
* No mutation here. Settings::withdraw() keeps the work and its own server-side
* refusal; the confirm button only says yes.
*/
class ConfirmWithdraw extends ModalComponent
{
use ResolvesCustomer;
public function proceed(): void
{
$this->dispatch('withdrawal-confirmed');
$this->closeModal();
}
public function render()
{
$right = WithdrawalRight::for(app(CustomDomainAccess::class)->contractOf($this->customer()));
// No figures to read out any more: the refund is the whole amount, so
// there is one sentence and nothing to work out from the contract. The
// right itself is still resolved here rather than handed in from the
// page, because markup is not evidence.
return view('livewire.confirm-withdraw', ['right' => $right]);
}
}