CluPilotCloud/app/Livewire/ConfirmBookStorage.php

47 lines
1.5 KiB
PHP

<?php
namespace App\Livewire;
use LivewireUI\Modal\ModalComponent;
/**
* Confirmation before several storage packs go into the cart at once (R23).
*
* The offer comes from a card that has just told the customer their downgrade is
* blocked, and it answers with a recurring charge — three packs is thirty euros
* a month, every month, until they cancel them. That is not something a stray
* click on a card about SAVING money should do, and the dialog that says so is
* drawn by this product rather than by the browser.
*
* No mutation here. Billing::bookStoragePacks() keeps the work and the customer
* resolution it already had; this only says yes, with the number it was opened
* for.
*/
class ConfirmBookStorage extends ModalComponent
{
public int $packs = 1;
public int $packGb = 0;
public function mount(int $packs = 1): void
{
// Clamped here as well as in the action behind it. A modal is opened
// with arguments from the page, and a page is markup — the figure that
// arrives is not evidence of anything, and the sentence this dialog
// shows must not be able to say something the action would not do.
$this->packs = max(1, min(50, $packs));
$this->packGb = (int) config('provisioning.storage_addon.gb', 0);
}
public function proceed(): void
{
$this->dispatch('storage-packs-confirmed', packs: $this->packs);
$this->closeModal();
}
public function render()
{
return view('livewire.confirm-book-storage');
}
}