su-secret-santa/resources/views/livewire/pages/withdraw.blade.php

72 lines
1.4 KiB
PHP

<?php
use App\Models\Participant;
use App\Services\PostService;
use Illuminate\Support\Facades\Log;
use function Livewire\Volt\{state, mount, rules};
state(['token']);
state([
'participant' => null,
]);
mount(function ($token)
{
$this->token = $token;
if ($this->token) {
$this->participant = Participant::findByToken($this->token);
}
});
$confirmWithdrawal = function ()
{
$this->js(<<<'JS'
if (confirm('Are you sure you want to withdraw from the event? This action cannot be undone.')) {
$wire.call('withdraw');
}
JS);
};
$withdraw = function ()
{
if($this->participant->withdraw()) {
$this->js('alert("Withdrawal complete")');
return $this->redirect('/', navigate: true);
}
else {
$this->js('alert("Something went wrong")');
return null;
}
};
?>
<div>
<h1>Withdraw from the event?</h1>
<p>Withdrawing is permanent, once you withdraw you cannot rejoin.</p>
<button
wire:click="confirmWithdrawal"
class=""
>
Withdraw
</button>
<style>
body {
background-color: #021202;
margin: 10pt;
font-family: sans-serif;
background-image: url("../img/christmas-bg.png");
background-size: 140px;
color: white;
overflow: hidden;
}
a {
color: white;
font-weight: bold;
}</style>
</div>