diff --git a/resources/views/components/project-card.blade.php b/resources/views/components/project-card.blade.php index b5475e9..6d47ff8 100644 --- a/resources/views/components/project-card.blade.php +++ b/resources/views/components/project-card.blade.php @@ -81,33 +81,31 @@ @endif -
- @if( - ($currentPleb && $currentPleb->id === $project->einundzwanzig_pleb_id) - || ($currentPleb && in_array($currentPleb->npub, config('einundzwanzig.config.current_board'), true)) - ) - - - Löschen - - - - Editieren - - @endif +
+ @if( + ($currentPleb && $currentPleb->id === $project->einundzwanzig_pleb_id) + || ($currentPleb && in_array($currentPleb->npub, config('einundzwanzig.config.current_board'), true)) + ) + + Löschen + + + + Editieren + + @endif @if(($currentPleb && $currentPleb->association_status->value > 2) || $project->accepted) Öffnen diff --git a/resources/views/livewire/association/project-support/form/edit.blade.php b/resources/views/livewire/association/project-support/form/edit.blade.php index 25d26d1..24a7119 100644 --- a/resources/views/livewire/association/project-support/form/edit.blade.php +++ b/resources/views/livewire/association/project-support/form/edit.blade.php @@ -19,9 +19,9 @@ class extends Component { public bool $isAllowed = false; - public function mount(ProjectProposal $project): void + public function mount($projectProposal): void { - $this->project = $project; + $this->project = ProjectProposal::query()->where('slug', $projectProposal)->firstOrFail(); if (NostrAuth::check()) { $currentPubkey = NostrAuth::pubkey(); @@ -30,14 +30,14 @@ class extends Component { if ( ( $currentPleb - && $currentPleb->id === $project->einundzwanzig_pleb_id + && $currentPleb->id === $this->project->einundzwanzig_pleb_id ) || in_array($currentPleb->npub, config('einundzwanzig.config.current_board')) ) { $this->isAllowed = true; $this->form = [ - 'name' => $project->name, - 'description' => $project->description, + 'name' => $this->project->name, + 'description' => $this->project->description, ]; } } diff --git a/resources/views/livewire/association/project-support/index.blade.php b/resources/views/livewire/association/project-support/index.blade.php index 8f2cd59..8297e94 100644 --- a/resources/views/livewire/association/project-support/index.blade.php +++ b/resources/views/livewire/association/project-support/index.blade.php @@ -22,9 +22,12 @@ new class extends Component { public ?EinundzwanzigPleb $currentPleb = null; + public ?ProjectProposal $projectToDelete = null; + protected $listeners = [ 'nostrLoggedIn' => 'handleNostrLoggedIn', 'nostrLoggedOut' => 'handleNostrLoggedOut', + 'confirmDeleteProject' => 'confirmDeleteProject', ]; public function mount(): void @@ -76,9 +79,9 @@ new class extends Component { $this->currentPleb = null; } - public function confirmDelete($id): void + public function confirmDeleteProject($id): void { - $this->confirmDeleteId = $id; + $this->projectToDelete = ProjectProposal::query()->findOrFail($id); Flux::modal('delete-project')->show(); } @@ -89,10 +92,13 @@ new class extends Component { public function delete(): void { - ProjectProposal::query()->findOrFail($this->confirmDeleteId)->delete(); - Flux::toast('Projektunterstützung gelöscht.'); - $this->loadProjects(); - Flux::modals()->close(); + if ($this->projectToDelete) { + $this->projectToDelete->delete(); + Flux::toast('Projektunterstützung gelöscht.'); + $this->loadProjects(); + Flux::modals()->close(); + $this->projectToDelete = null; + } } }; @@ -158,33 +164,33 @@ new class extends Component {
-
{{ $projects->count() }} Projekte
+
{{ $projects->count() }} Projekte
- -
- @foreach($this->projects as $project) - - @endforeach -
+ +
+ @foreach($this->projects as $project) + + @endforeach +
- - -
-
- Projektunterstützung löschen - -

Bist du sicher, dass du diese Projektunterstützung löschen möchtest?

-

Diese Aktion kann nicht rückgängig gemacht werden.

-
-
-
- - - Abbrechen - - Ja, löschen -
-
-
-
+ + +
+
+ Projektunterstützung löschen? + +

Du bist dabei, diese Projektunterstützung zu löschen.

+

Diese Aktion kann nicht rückgängig gemacht werden.

+
+
+
+ + + Abbrechen + + Löschen +
+
+
+ diff --git a/resources/views/livewire/association/project-support/show.blade.php b/resources/views/livewire/association/project-support/show.blade.php index 86d5f82..4425804 100644 --- a/resources/views/livewire/association/project-support/show.blade.php +++ b/resources/views/livewire/association/project-support/show.blade.php @@ -1,90 +1,186 @@ project = $project; + $this->projectProposal = \App\Models\ProjectProposal::query()->where('slug', $projectProposal)->firstOrFail(); if (NostrAuth::check()) { + $this->currentPubkey = NostrAuth::pubkey(); + $this->handleNostrLoggedIn($this->currentPubkey); $this->isAllowed = true; } } -}; + + public function getBoardVotesProperty() + { + return Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->whereHas('einundzwanzigPleb', fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board'))) + ->get(); + } + + public function getOtherVotesProperty() + { + return Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->whereDoesntHave( + 'einundzwanzigPleb', + fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board')) + ) + ->get(); + } + + public function handleNostrLoggedIn($pubkey): void + { + $this->currentPubkey = $pubkey; + $this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first(); + $this->isAllowed = true; + $this->ownVoteExists = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('einundzwanzig_pleb_id', $this->currentPleb->id) + ->exists(); + } + + public function handleApprove(): void + { + Vote::query()->updateOrCreate([ + 'project_proposal_id' => $this->projectProposal->id, + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + ], [ + 'value' => true, + ]); + } + + public function handleNotApprove(): void + { + Vote::query()->updateOrCreate([ + 'project_proposal_id' => $this->projectProposal->id, + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + ], [ + 'value' => false, + ]); + } +} ?>
- @if($isAllowed) -
-
-
-

- {{ $project->name }} -

-
- @if($project->status === 'pending') - - @elseif($project->status === 'active') - - @else - - @endif + @if($projectProposal->accepted || $isAllowed) +
+ +
+ {{ $projectProposal->created_at->translatedFormat('d.m.Y') }} +
+
+

+ {{ $projectProposal->name }} +

+ {!! $projectProposal->description !!} +
-
- -
- -

- Details -

-
-
-
Status
-
- @if($project->status === 'pending') - Ausstehend - @elseif($project->status === 'active') - Aktiv - @else - Archiviert - @endif -
+
+
+ + User + +
Eingereicht von +
+ {{ $projectProposal->einundzwanzigPleb?->profile->name ?? str($projectProposal->einundzwanzigPleb->npub)->limit(32) }} +
-
-
Erstellt am
-
- {{ $project->created_at->format('d.m.Y') }} -
+
+
+ -
-
-
+
+ {{ number_format($projectProposal->support_in_sats, 0, ',', '.') }} Sats +
+
+
- -
- -

- Beschreibung -

-

- {{ $project->description ?? 'Keine Beschreibung' }} -

-
+
+ Picture +
+ +
+ + @if($isAllowed && !$projectProposal->accepted) +
+
+ @if(!$ownVoteExists) +
+ + + Zustimmen + + + + Ablehnen + +
+ @else +

Du hast bereits abgestimmt.

+ @endif +
+ +
+
+ Zustimmungen des Vorstands ({{ count($this->boardVotes->where('value', 1)) }}) +
+
+ +
+
+ Ablehnungen des Vorstands ({{ count($this->boardVotes->where('value', 0)) }}) +
+
+ +
+
+ Zustimmungen der übrigen Mitglieder + ({{ count($this->otherVotes->where('value', 1)) }}) +
+
+ +
+
+ Ablehnungen der übrigen Mitglieder + ({{ count($this->otherVotes->where('value', 0)) }}) +
+
+
+ @endif