mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2025-12-14 06:36:46 +00:00
🎨 fix(election): handle potential null values for end_time and candidates in election views
This commit is contained in:
@@ -42,7 +42,7 @@ mount(function () {
|
|||||||
->toArray();
|
->toArray();
|
||||||
$this->loadEvents();
|
$this->loadEvents();
|
||||||
$this->loadBoardEvents();
|
$this->loadBoardEvents();
|
||||||
if ($this->election->end_time->isPast() || !config('services.voting')) {
|
if ($this->election->end_time?->isPast() || !config('services.voting')) {
|
||||||
$this->isNotClosed = false;
|
$this->isNotClosed = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -123,7 +123,7 @@ $loadNostrEvents = function ($kinds) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$vote = function ($pubkey, $type, $board = false) {
|
$vote = function ($pubkey, $type, $board = false) {
|
||||||
if ($this->election->end_time->isPast()) {
|
if ($this->election->end_time?->isPast()) {
|
||||||
$this->isNotClosed = false;
|
$this->isNotClosed = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ $vote = function ($pubkey, $type, $board = false) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$checkElection = function () {
|
$checkElection = function () {
|
||||||
if ($this->election->end_time->isPast()) {
|
if ($this->election->end_time?->isPast()) {
|
||||||
$this->isNotClosed = false;
|
$this->isNotClosed = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -429,7 +429,7 @@ $signEvent = function ($event) {
|
|||||||
<div>
|
<div>
|
||||||
@if($isNotClosed)
|
@if($isNotClosed)
|
||||||
<x-badge success
|
<x-badge success
|
||||||
label="Die Wahl ist geöffnet bis zum {{ $election->end_time->timezone('Europe/Berlin')->format('d.m.Y H:i') }}"/>
|
label="Die Wahl ist geöffnet bis zum {{ $election->end_time?->timezone('Europe/Berlin')->format('d.m.Y H:i') }}"/>
|
||||||
@else
|
@else
|
||||||
<x-badge negative label="Die Wahl ist geschlossen"/>
|
<x-badge negative label="Die Wahl ist geschlossen"/>
|
||||||
@endif
|
@endif
|
||||||
@@ -497,7 +497,7 @@ $signEvent = function ($event) {
|
|||||||
</div>
|
</div>
|
||||||
<footer class="mt-5">
|
<footer class="mt-5">
|
||||||
<div class="grid sm:grid-cols-2 gap-2">
|
<div class="grid sm:grid-cols-2 gap-2">
|
||||||
@foreach($electionConfig->firstWhere('type', 'presidency')['candidates'] as $c)
|
@foreach($electionConfig->firstWhere('type', 'presidency')['candidates'] ?? [] as $c)
|
||||||
<div
|
<div
|
||||||
@if($isNotClosed)wire:click="vote('{{ $c['pubkey'] }}', 'presidency')"
|
@if($isNotClosed)wire:click="vote('{{ $c['pubkey'] }}', 'presidency')"
|
||||||
@endif
|
@endif
|
||||||
@@ -533,7 +533,7 @@ $signEvent = function ($event) {
|
|||||||
</div>
|
</div>
|
||||||
<footer class="mt-5">
|
<footer class="mt-5">
|
||||||
<div class="grid sm:grid-cols-4 gap-2">
|
<div class="grid sm:grid-cols-4 gap-2">
|
||||||
@foreach($electionConfigBoard->firstWhere('type', 'board')['candidates'] as $c)
|
@foreach($electionConfigBoard->firstWhere('type', 'board')['candidates'] ?? [] as $c)
|
||||||
<div
|
<div
|
||||||
@if($isNotClosed && !$c['hasVoted'])wire:click="vote('{{ $c['pubkey'] }}', 'board', true)"
|
@if($isNotClosed && !$c['hasVoted'])wire:click="vote('{{ $c['pubkey'] }}', 'board', true)"
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
Reference in New Issue
Block a user