fix(portal): cancel the active instance explicitly, not just the newest record
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>feat/portal-design
parent
c011a11b48
commit
cbbb523f9c
|
|
@ -19,11 +19,11 @@ class ConfirmCancelPackage extends ModalComponent
|
|||
public function cancelPackage()
|
||||
{
|
||||
$customer = $this->customer();
|
||||
$instance = $customer?->instances()->latest('id')->first();
|
||||
// Target the ACTIVE package explicitly — a newer failed/deprovisioned
|
||||
// record must not shadow an older active instance (v1: one active/customer).
|
||||
$instance = $customer?->instances()->where('status', 'active')->latest('id')->first();
|
||||
|
||||
// Only an active package can be cancelled — never resurrect an already
|
||||
// cancelled/deprovisioned/scheduled instance.
|
||||
if ($instance === null || $instance->status !== 'active') {
|
||||
if ($instance === null) {
|
||||
return $this->redirectRoute('settings', navigate: true);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ class ConfirmCancelPackage extends ModalComponent
|
|||
|
||||
public function render()
|
||||
{
|
||||
$instance = $this->customer()?->instances()->latest('id')->first();
|
||||
$instance = $this->customer()?->instances()->where('status', 'active')->latest('id')->first();
|
||||
|
||||
return view('livewire.confirm-cancel-package', [
|
||||
'subdomain' => $instance?->subdomain ?? '',
|
||||
|
|
|
|||
|
|
@ -150,15 +150,19 @@ class Settings extends Component
|
|||
public function render()
|
||||
{
|
||||
$c = $this->customer();
|
||||
$instance = $c?->instances()->latest('id')->first();
|
||||
// Prefer the active/cancelling instance for the package section so the
|
||||
// controls line up with what cancellation actually targets.
|
||||
$active = $c?->instances()->where('status', 'active')->latest('id')->first();
|
||||
$scheduled = $c?->instances()->where('status', 'cancellation_scheduled')->latest('id')->first();
|
||||
$instance = $active ?? $scheduled ?? $c?->instances()->latest('id')->first();
|
||||
|
||||
return view('livewire.settings', [
|
||||
'customer' => $c,
|
||||
'instance' => $instance,
|
||||
'branding' => $c?->brandingResolved(),
|
||||
'logoUrl' => $this->brandLogoPath ? Storage::disk('public')->url($this->brandLogoPath) : null,
|
||||
'hasActivePackage' => $instance !== null && ! in_array($instance->status, ['cancelled', 'deprovisioned'], true),
|
||||
'cancellationScheduled' => $instance !== null && $instance->status === 'cancellation_scheduled',
|
||||
'hasActivePackage' => $active !== null,
|
||||
'cancellationScheduled' => $active === null && $scheduled !== null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue