mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-26 05:23:19 +00:00
🗑️ Remove election-related blade files no longer in use
This commit is contained in:
@@ -1,728 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\{
|
||||
Filter\Filter,
|
||||
Key\Key,
|
||||
Message\EventMessage,
|
||||
Message\RequestMessage,
|
||||
Relay\Relay,
|
||||
Relay\RelaySet,
|
||||
Request\Request,
|
||||
Subscription\Subscription,
|
||||
Event\Event as NostrEvent,
|
||||
Sign\Sign
|
||||
};
|
||||
|
||||
use function Livewire\Volt\{computed, mount, state, with, updated, on};
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
|
||||
name('association.election');
|
||||
|
||||
state([
|
||||
'isAllowed' => false,
|
||||
'showLog' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
'events' => [],
|
||||
'boardEvents' => [],
|
||||
'election' => fn() => $election,
|
||||
'plebs' => [],
|
||||
'search' => '',
|
||||
'signThisEvent' => '',
|
||||
'isNotClosed' => true,
|
||||
]);
|
||||
|
||||
mount(function () {
|
||||
$this->plebs = \App\Models\EinundzwanzigPleb::query()
|
||||
->with(['profile'])
|
||||
->whereIn('association_status', [3, 4])
|
||||
->orderBy('association_status', 'desc')
|
||||
->get()
|
||||
->toArray();
|
||||
$this->loadEvents();
|
||||
$this->loadBoardEvents();
|
||||
if ($this->election->end_time?->isPast() || !config('services.voting')) {
|
||||
$this->isNotClosed = false;
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
$logPubkeys = [
|
||||
'0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033',
|
||||
'430169631f2f0682c60cebb4f902d68f0c71c498fd1711fd982f052cf1fd4279',
|
||||
];
|
||||
if (in_array($this->currentPubkey, $logPubkeys, true)) {
|
||||
$this->showLog = true;
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
},
|
||||
'echo:votes,.newVote' => function () {
|
||||
$this->loadEvents();
|
||||
$this->loadBoardEvents();
|
||||
},
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
updated([
|
||||
'search' => function ($value) {
|
||||
$this->plebs = \App\Models\EinundzwanzigPleb::query()
|
||||
->with(['profile'])
|
||||
->whereIn('association_status', [3, 4])
|
||||
->where(fn($query)
|
||||
=> $query
|
||||
->where('pubkey', 'like', "%$value%")
|
||||
->orWhereHas('profile', fn($query) => $query->where('name', 'ilike', "%$value%")))
|
||||
->orderBy('association_status', 'desc')
|
||||
->get()
|
||||
->toArray();
|
||||
},
|
||||
]);
|
||||
|
||||
$loadEvents = function () {
|
||||
$this->events = $this->loadNostrEvents([32122]);
|
||||
};
|
||||
|
||||
$loadBoardEvents = function () {
|
||||
$this->boardEvents = $this->loadNostrEvents([2121]);
|
||||
};
|
||||
|
||||
$loadNostrEvents = function ($kinds) {
|
||||
$subscription = new Subscription();
|
||||
$subscriptionId = $subscription->setId();
|
||||
$filter = new Filter();
|
||||
$filter->setKinds($kinds);
|
||||
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
|
||||
$relaySet = new RelaySet();
|
||||
$relaySet->setRelays([new Relay(config('services.relay'))]);
|
||||
$request = new Request($relaySet, $requestMessage);
|
||||
$response = $request->send();
|
||||
return collect($response[config('services.relay')])
|
||||
->map(function($event) {
|
||||
if(!isset($event->event)) {
|
||||
return false;
|
||||
}
|
||||
return [
|
||||
'id' => $event->event->id,
|
||||
'kind' => $event->event->kind,
|
||||
'content' => $event->event->content,
|
||||
'pubkey' => $event->event->pubkey,
|
||||
'tags' => $event->event->tags,
|
||||
'created_at' => $event->event->created_at,
|
||||
];
|
||||
})
|
||||
->filter()
|
||||
->toArray();
|
||||
};
|
||||
|
||||
$vote = function ($pubkey, $type, $board = false) {
|
||||
if ($this->election->end_time?->isPast()) {
|
||||
$this->isNotClosed = false;
|
||||
return;
|
||||
}
|
||||
$note = new NostrEvent();
|
||||
$note->setKind($board ? 2121 : 32122);
|
||||
if (!$board) {
|
||||
$dTag = sprintf('%s,%s,%s', $this->currentPleb->pubkey, date('Y'), $type);
|
||||
$note->setTags([['d', $dTag]]);
|
||||
}
|
||||
$note->setContent("$pubkey,$type");
|
||||
$this->signThisEvent = $note->toJson();
|
||||
};
|
||||
|
||||
$checkElection = function () {
|
||||
if ($this->election->end_time?->isPast()) {
|
||||
$this->isNotClosed = false;
|
||||
}
|
||||
};
|
||||
|
||||
$signEvent = function ($event) {
|
||||
$note = new NostrEvent();
|
||||
$note->setId($event['id']);
|
||||
$note->setSignature($event['sig']);
|
||||
$note->setKind($event['kind']);
|
||||
$note->setContent($event['content']);
|
||||
$note->setPublicKey($event['pubkey']);
|
||||
$note->setTags($event['tags']);
|
||||
$note->setCreatedAt($event['created_at']);
|
||||
$eventMessage = new EventMessage($note);
|
||||
$relay = new Relay(config('services.relay'));
|
||||
$relay->setMessage($eventMessage);
|
||||
$relay->send();
|
||||
Broadcast::on('votes')->as('newVote')->sendNow();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app
|
||||
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Wahlen ' . $election->year, description: 'Wahlen des Vereins im Jahr ' . $election->year)"
|
||||
>
|
||||
@volt
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div x-cloak class="relative flex h-full" x-data="nostrApp(@this)"
|
||||
wire:poll.600000ms="checkElection">
|
||||
|
||||
@php
|
||||
$positions = [
|
||||
'presidency' => ['icon' => 'fa-crown', 'title' => 'Präsidium'],
|
||||
'board' => ['icon' => 'fa-users', 'title' => 'Vizepräsidium'],
|
||||
];
|
||||
$loadedEvents = collect($events)
|
||||
->map(function($event) {
|
||||
$profile = \App\Models\Profile::query()
|
||||
->where('pubkey', $event['pubkey'])
|
||||
->first()
|
||||
?->toArray();
|
||||
$votedFor = \App\Models\Profile::query()
|
||||
->where('pubkey', str($event['content'])->before(',')->toString())
|
||||
->first()
|
||||
?->toArray();
|
||||
|
||||
return [
|
||||
'id' => $event['id'],
|
||||
'kind' => $event['kind'],
|
||||
'content' => $event['content'],
|
||||
'pubkey' => $event['pubkey'],
|
||||
'tags' => $event['tags'],
|
||||
'created_at' => $event['created_at'],
|
||||
'profile' => $profile,
|
||||
'votedFor' => $votedFor,
|
||||
'type' => str($event['content'])->after(',')->toString(),
|
||||
];
|
||||
})
|
||||
->sortByDesc('created_at')
|
||||
->unique(fn ($event) => $event['pubkey'] . $event['type'])
|
||||
->values();
|
||||
$loadedBoardEvents = collect($boardEvents)
|
||||
->map(function($event) {
|
||||
$profile = \App\Models\Profile::query()
|
||||
->where('pubkey', $event['pubkey'])
|
||||
->first()
|
||||
?->toArray();
|
||||
$votedFor = \App\Models\Profile::query()
|
||||
->where('pubkey', str($event['content'])->before(',')->toString())
|
||||
->first()
|
||||
?->toArray();
|
||||
|
||||
return [
|
||||
'id' => $event['id'],
|
||||
'kind' => $event['kind'],
|
||||
'content' => $event['content'],
|
||||
'pubkey' => $event['pubkey'],
|
||||
'tags' => $event['tags'],
|
||||
'created_at' => $event['created_at'],
|
||||
'profile' => $profile,
|
||||
'votedFor' => $votedFor,
|
||||
'type' => str($event['content'])->after(',')->toString(),
|
||||
];
|
||||
})
|
||||
->sortByDesc('created_at')
|
||||
->values();
|
||||
@endphp
|
||||
|
||||
<!-- Inbox sidebar -->
|
||||
<div id="inbox-sidebar"
|
||||
class="absolute z-20 top-0 bottom-0 w-full md:w-auto md:static md:top-auto md:bottom-auto -mr-px md:translate-x-0 transition-transform duration-200 ease-in-out"
|
||||
:class="inboxSidebarOpen ? 'translate-x-0' : '-translate-x-full'">
|
||||
<div
|
||||
class="sticky top-16 bg-white dark:bg-[#1B1B1B] overflow-x-hidden overflow-y-auto no-scrollbar shrink-0 border-r border-gray-200 dark:border-gray-700/60 md:w-[18rem] xl:w-[20rem] h-[calc(100dvh-64px)]">
|
||||
|
||||
<!-- #Marketing group -->
|
||||
<div>
|
||||
<!-- Group header -->
|
||||
<div class="sticky top-0 z-10">
|
||||
<div
|
||||
class="flex items-center bg-white dark:bg-[#1B1B1B] border-b border-gray-200 dark:border-gray-700/60 px-5 h-16">
|
||||
<div class="w-full flex items-center justify-between">
|
||||
<!-- Channel menu -->
|
||||
<div class="relative" x-data="{ open: false }">
|
||||
<button class="grow flex items-center truncate" aria-haspopup="true"
|
||||
@click.prevent="open = !open" :aria-expanded="open">
|
||||
<div class="truncate">
|
||||
<span
|
||||
class="font-semibold text-gray-800 dark:text-gray-100">2024</span>
|
||||
</div>
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 ml-1 fill-current text-gray-400 dark:text-gray-500"
|
||||
viewBox="0 0 12 12">
|
||||
<path d="M5.9 11.4L.5 6l1.4-1.4 4 4 4-4L11.3 6z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="origin-top-right z-10 absolute top-full left-0 min-w-60 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700/60 py-1.5 rounded-lg shadow-lg overflow-hidden mt-1"
|
||||
@click.outside="open = false" @keydown.escape.window="open = false"
|
||||
x-show="open"
|
||||
x-transition:enter="transition ease-out duration-200 transform"
|
||||
x-transition:enter-start="opacity-0 -translate-y-2"
|
||||
x-transition:enter-end="opacity-100 translate-y-0"
|
||||
x-transition:leave="transition ease-out duration-200"
|
||||
x-transition:leave-start="opacity-100"
|
||||
x-transition:leave-end="opacity-0"
|
||||
x-cloak>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="font-medium text-sm text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-gray-200 block py-1.5 px-3"
|
||||
href="#0" @click="open = false" @focus="open = true"
|
||||
@focusout="open = false">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="grow flex items-center truncate">
|
||||
<div class="truncate">2024</div>
|
||||
</div>
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 fill-current text-orange-500 ml-1"
|
||||
viewBox="0 0 12 12">
|
||||
<path
|
||||
d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z"/>
|
||||
</svg>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Group body -->
|
||||
<div class="px-5 py-4">
|
||||
<!-- Search form -->
|
||||
<form class="relative">
|
||||
<label for="inbox-search" class="sr-only">Search</label>
|
||||
<input
|
||||
wire:model.live.debounce="search"
|
||||
id="inbox-search" class="form-input w-full pl-9 bg-white dark:bg-gray-800"
|
||||
type="search" placeholder="Suche…"/>
|
||||
<button class="absolute inset-0 right-auto group" type="submit" aria-label="Search">
|
||||
<svg
|
||||
class="shrink-0 fill-current text-gray-400 dark:text-gray-500 group-hover:text-gray-500 dark:group-hover:text-gray-400 ml-3 mr-2"
|
||||
width="16" height="16" viewBox="0 0 16 16"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M7 14c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7zM7 2C4.243 2 2 4.243 2 7s2.243 5 5 5 5-2.243 5-5-2.243-5-5-5z"/>
|
||||
<path
|
||||
d="M15.707 14.293L13.314 11.9a8.019 8.019 0 01-1.414 1.414l2.393 2.393a.997.997 0 001.414 0 .999.999 0 000-1.414z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
<!-- Inbox -->
|
||||
<div class="mt-4">
|
||||
<div class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3">
|
||||
Plebs
|
||||
</div>
|
||||
<ul class="mb-6">
|
||||
@foreach($plebs as $pleb)
|
||||
<li class="-mx-2">
|
||||
<div class="flex w-full p-2 rounded text-left">
|
||||
<img class="w-8 h-8 rounded-full mr-2 bg-black"
|
||||
src="{{ $pleb['profile']['picture'] ?? 'https://robohash.org/test' }}"
|
||||
onerror="this.onerror=null; this.src='https://robohash.org/test';"
|
||||
width="32"
|
||||
height="32"
|
||||
alt="A"/>
|
||||
<div class="grow truncate">
|
||||
<div class="flex items-center justify-between mb-1.5">
|
||||
<div class="truncate">
|
||||
<span
|
||||
class="text-sm font-semibold text-gray-800 dark:text-gray-100 truncate">{{ $pleb['profile']['name'] ?? $pleb['pubkey'] }}</span>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 font-medium">
|
||||
<x-badge
|
||||
color="{{ \App\Enums\AssociationStatus::from($pleb['association_status'])->color() }}"
|
||||
label="{{ \App\Enums\AssociationStatus::from($pleb['association_status'])->label() }}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="text-xs font-medium text-gray-800 dark:text-gray-100 truncate mb-0.5">
|
||||
<div class="flex items-center space-x-2 h-5">
|
||||
@foreach($positions as $name => $p)
|
||||
@php
|
||||
$votedResult = $loadedEvents->filter(fn ($e) => $e['pubkey'] === $pleb['pubkey'])->firstWhere('type', $name);
|
||||
@endphp
|
||||
<div class="flex space-x-2"
|
||||
wire:key="p_{{ $name }}">
|
||||
@if($votedResult)
|
||||
<i class="fa-sharp-duotone fa-solid {{ $p['icon'] }} w-4 h-4 fill-current text-green-500"></i>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Inbox body -->
|
||||
@if($currentPubkey)
|
||||
|
||||
@php
|
||||
$electionConfig = collect(json_decode($election->candidates, true, 512, JSON_THROW_ON_ERROR))
|
||||
->map(function ($c) use ($loadedEvents, $currentPubkey) {
|
||||
$candidates = \App\Models\Profile::query()
|
||||
->whereIn('pubkey', $c['c'])
|
||||
->get()
|
||||
->map(function ($p) use ($loadedEvents, $c, $currentPubkey) {
|
||||
$votedClass = ' bg-green-500/20 text-green-700';
|
||||
$notVotedClass = ' bg-gray-500/20 text-gray-100';
|
||||
$hasVoted = $loadedEvents
|
||||
->filter(fn($e) => $e['type'] === $c['type'] && $e['pubkey'] === $currentPubkey)
|
||||
->firstWhere('votedFor.pubkey', $p->pubkey);
|
||||
|
||||
return [
|
||||
'pubkey' => $p->pubkey,
|
||||
'name' => $p->name,
|
||||
'picture' => $p->picture,
|
||||
'votedClass' => $hasVoted ? $votedClass : $notVotedClass,
|
||||
];
|
||||
});
|
||||
|
||||
return [
|
||||
'type' => $c['type'],
|
||||
'c' => $c['c'],
|
||||
'candidates' => $candidates,
|
||||
];
|
||||
});
|
||||
$electionConfigBoard = collect(json_decode($election->candidates, true, 512, JSON_THROW_ON_ERROR))
|
||||
->map(function ($c) use ($loadedBoardEvents, $currentPubkey) {
|
||||
$candidates = \App\Models\Profile::query()
|
||||
->whereIn('pubkey', $c['c'])
|
||||
->get()
|
||||
->map(function ($p) use ($loadedBoardEvents, $c, $currentPubkey) {
|
||||
$votedClass = ' bg-green-500/20 text-green-700';
|
||||
$notVotedClass = ' bg-gray-500/20 text-gray-100';
|
||||
$hasVoted = $loadedBoardEvents
|
||||
->filter(fn($e) => $e['type'] === $c['type'] && $e['pubkey'] === $currentPubkey)
|
||||
->firstWhere('votedFor.pubkey', $p->pubkey);
|
||||
|
||||
return [
|
||||
'pubkey' => $p->pubkey,
|
||||
'name' => $p->name,
|
||||
'picture' => $p->picture,
|
||||
'votedClass' => $hasVoted ? $votedClass : $notVotedClass,
|
||||
'hasVoted' => $hasVoted,
|
||||
];
|
||||
});
|
||||
|
||||
return [
|
||||
'type' => $c['type'],
|
||||
'c' => $c['c'],
|
||||
'candidates' => $candidates,
|
||||
];
|
||||
});
|
||||
@endphp
|
||||
|
||||
<div class="grow flex flex-col md:translate-x-0 transition-transform duration-300 ease-in-out"
|
||||
:class="inboxSidebarOpen ? 'translate-x-1/3' : 'translate-x-0'">
|
||||
|
||||
<!-- Header -->
|
||||
<div class="sticky top-16">
|
||||
<div
|
||||
class="flex items-center justify-between before:absolute before:inset-0 before:backdrop-blur-md before:bg-gray-50/90 dark:before:bg-[#1B1B1B]/90 before:-z-10 border-b border-gray-200 dark:border-gray-700/60 px-4 sm:px-6 md:px-5 h-16">
|
||||
<div
|
||||
class="flex flex-col space-y-2 sm:space-y-0 sm:flex-row justify-between items-center w-full">
|
||||
<div>
|
||||
@if($isNotClosed)
|
||||
<x-badge success
|
||||
label="Die Wahl ist geöffnet bis zum {{ $election->end_time?->timezone('Europe/Berlin')->format('d.m.Y H:i') }}"/>
|
||||
@else
|
||||
<x-badge negative label="Die Wahl ist geschlossen"/>
|
||||
@endif
|
||||
</div>
|
||||
<div>
|
||||
<x-button secondary
|
||||
:href="route('association.election.admin', ['election' => $election])"
|
||||
label="Wahl-Admin"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Body -->
|
||||
<div class="grow px-4 sm:px-6 md:px-5 py-4">
|
||||
|
||||
<!-- Mail subject -->
|
||||
<header class="sm:flex sm:items-start space-x-4 mb-4">
|
||||
<h1 class="text-xl leading-snug text-gray-800 dark:text-gray-100 font-bold mb-1 sm:mb-0 ml-2">
|
||||
Wahlen
|
||||
</h1>
|
||||
<button
|
||||
class="text-xs inline-flex font-bold bg-amber-500/20 text-sky-700 rounded-full text-center px-2.5 py-1 whitespace-nowrap">
|
||||
2024
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- Messages box -->
|
||||
<div
|
||||
class="shadow-sm rounded-xl px-6 divide-y divide-gray-200 dark:divide-gray-700/60">
|
||||
|
||||
<!-- Mail -->
|
||||
<div class="py-6">
|
||||
<h1 class="text-xl leading-snug text-gray-800 dark:text-gray-100 font-bold mb-1 sm:mb-0 ml-2">
|
||||
Wahl des Präsidiums
|
||||
</h1>
|
||||
@php
|
||||
$president = $positions['presidency'];
|
||||
$board = $positions['board'];
|
||||
@endphp
|
||||
<div class="grid sm:grid-cols-2 gap-6">
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl">
|
||||
<div class="flex flex-col h-full p-5">
|
||||
<header>
|
||||
<div class="flex items-center justify-between">
|
||||
<i class="fa-sharp-duotone fa-solid {{ $president['icon'] }} w-9 h-9 fill-current text-white"></i>
|
||||
</div>
|
||||
</header>
|
||||
<div class="grow mt-2">
|
||||
<div
|
||||
class="inline-flex text-gray-800 dark:text-gray-100 hover:text-gray-900 dark:hover:text-white mb-1">
|
||||
<h2 class="text-xl leading-snug font-semibold">{{ $president['title'] }}</h2>
|
||||
</div>
|
||||
<div class="text-sm">
|
||||
@php
|
||||
$votedResult = $loadedEvents->filter(fn ($event) => $event['pubkey'] === $currentPubkey)->firstWhere('type', 'presidency');
|
||||
@endphp
|
||||
@if($votedResult)
|
||||
<span>Du hast "{{ $votedResult['votedFor']['name'] ?? 'error' }}" gewählt</span>
|
||||
@else
|
||||
<span>Wähle deinen Kandidaten für das Präsidium.</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<footer class="mt-5">
|
||||
<div class="grid sm:grid-cols-2 gap-2">
|
||||
@foreach($electionConfig->firstWhere('type', 'presidency')['candidates'] ?? [] as $c)
|
||||
<div
|
||||
@if($isNotClosed)wire:click="vote('{{ $c['pubkey'] }}', 'presidency')"
|
||||
@endif
|
||||
class="{{ $c['votedClass'] }} cursor-pointer text-xs inline-flex font-medium rounded-full text-center px-2.5 py-1">
|
||||
<div class="flex items-center">
|
||||
<img class="w-6 h-6 rounded-full mr-2 bg-black"
|
||||
src="{{ $c['picture'] ?? 'https://robohash.org/' . $c['pubkey'] }}"
|
||||
onerror="this.onerror=null; this.src='https://robohash.org/{{ $c['pubkey'] }}';"
|
||||
width="24" height="24"
|
||||
alt="{{ $c['name'] }}"/>
|
||||
{{ $c['name'] }}
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1 class="mt-6 text-xl leading-snug text-gray-800 dark:text-gray-100 font-bold mb-1 sm:mb-0 ml-2">
|
||||
Wahl der übrigen Vorstandsmitglieder
|
||||
</h1>
|
||||
<div class="grid gap-6">
|
||||
|
||||
<div
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl">
|
||||
<div class="flex flex-col h-full p-5">
|
||||
<div class="grow mt-2">
|
||||
<div class="text-sm">
|
||||
<span>Klicke auf den Kandidaten, um seine Position als Vorstandsmitglied zu bestätigen.</span>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="mt-5">
|
||||
<div class="grid sm:grid-cols-4 gap-2">
|
||||
@foreach($electionConfigBoard->firstWhere('type', 'board')['candidates'] ?? [] as $c)
|
||||
<div
|
||||
@if($isNotClosed && !$c['hasVoted'])wire:click="vote('{{ $c['pubkey'] }}', 'board', true)"
|
||||
@endif
|
||||
class="{{ $c['votedClass'] }} cursor-pointer text-xs inline-flex font-medium rounded-full text-center px-2.5 py-1">
|
||||
<div class="flex items-center">
|
||||
<img class="w-6 h-6 rounded-full mr-2 bg-black"
|
||||
src="{{ $c['picture'] ?? 'https://robohash.org/' . $c['pubkey'] }}"
|
||||
onerror="this.onerror=null; this.src='https://robohash.org/{{ $c['pubkey'] }}';"
|
||||
width="24" height="24"
|
||||
alt="{{ $c['name'] }}"/>
|
||||
{{ $c['name'] }}
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Log events -->
|
||||
<div x-cloak x-show="showLog" class="mt-6 hidden sm:block">
|
||||
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-xl mb-8">
|
||||
<header class="px-5 py-4">
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100">Präsidium Log <span
|
||||
class="text-gray-400 dark:text-gray-500 font-medium">{{ $loadedEvents->count() }}</span>
|
||||
</h2>
|
||||
</header>
|
||||
<div>
|
||||
<!-- Table -->
|
||||
<div class="overflow-x-auto">
|
||||
<table
|
||||
class="table-auto w-full dark:text-gray-300 divide-y divide-gray-100 dark:divide-gray-700/60">
|
||||
<!-- Table header -->
|
||||
<thead
|
||||
class="text-xs uppercase text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900/20 border-t border-gray-100 dark:border-gray-700/60">
|
||||
<tr>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">ID</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Kind</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Pubkey</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Created At</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Voted For</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Type</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- Table body -->
|
||||
<tbody class="text-sm">
|
||||
@foreach($loadedEvents as $event)
|
||||
<tr>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div
|
||||
class="font-medium">{{ \Illuminate\Support\Str::limit($event['id'], 10) }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['kind'] }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['profile']['name'] ?? '' }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['created_at'] }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['votedFor']['name'] ?? '' }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['type'] }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div x-cloak x-show="showLog" class="mt-6 hidden sm:block">
|
||||
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-xl mb-8">
|
||||
<header class="px-5 py-4">
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100">Board Log <span
|
||||
class="text-gray-400 dark:text-gray-500 font-medium">{{ $loadedBoardEvents->count() }}</span>
|
||||
</h2>
|
||||
</header>
|
||||
<div>
|
||||
<!-- Table -->
|
||||
<div class="overflow-x-auto">
|
||||
<table
|
||||
class="table-auto w-full dark:text-gray-300 divide-y divide-gray-100 dark:divide-gray-700/60">
|
||||
<!-- Table header -->
|
||||
<thead
|
||||
class="text-xs uppercase text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-900/20 border-t border-gray-100 dark:border-gray-700/60">
|
||||
<tr>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">ID</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Kind</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Pubkey</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Created At</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Voted For</div>
|
||||
</th>
|
||||
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div class="font-semibold text-left">Type</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- Table body -->
|
||||
<tbody class="text-sm">
|
||||
@foreach($loadedBoardEvents as $event)
|
||||
<tr>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div
|
||||
class="font-medium">{{ \Illuminate\Support\Str::limit($event['id'], 10) }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['kind'] }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['profile']['name'] ?? '' }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['created_at'] }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['votedFor']['name'] ?? '' }}</div>
|
||||
</td>
|
||||
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
|
||||
<div>{{ $event['type'] }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">Wahlen</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Wahlen einzusehen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,257 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\{Filter\Filter,
|
||||
Key\Key,
|
||||
Message\EventMessage,
|
||||
Message\RequestMessage,
|
||||
Relay\Relay,
|
||||
Relay\RelaySet,
|
||||
Request\Request,
|
||||
Subscription\Subscription,
|
||||
Event\Event as NostrEvent,
|
||||
Sign\Sign};
|
||||
|
||||
use function Livewire\Volt\{computed, mount, state, with, updated, on};
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
|
||||
name('association.election.admin');
|
||||
|
||||
state([
|
||||
'isAllowed' => false,
|
||||
'currentPubkey' => null,
|
||||
'votes' => null,
|
||||
'boardVotes' => null,
|
||||
'events' => null,
|
||||
'boardEvents' => null,
|
||||
'election' => fn() => $election,
|
||||
'signThisEvent' => '',
|
||||
'plebs' => fn()
|
||||
=> \App\Models\EinundzwanzigPleb::query()
|
||||
->with(['profile'])
|
||||
->whereIn('association_status', [3, 4])
|
||||
->orderBy('association_status', 'desc')
|
||||
->get()
|
||||
->toArray(),
|
||||
'electionConfig' => fn()
|
||||
=> collect(json_decode($this->election->candidates, true, 512, JSON_THROW_ON_ERROR))
|
||||
->map(fn($c)
|
||||
=> [
|
||||
'type' => $c['type'],
|
||||
'c' => $c['c'],
|
||||
'candidates' => \App\Models\Profile::query()
|
||||
->whereIn('pubkey', $c['c'])
|
||||
->get()
|
||||
->map(fn($p)
|
||||
=> [
|
||||
'pubkey' => $p->pubkey,
|
||||
'name' => $p->name,
|
||||
'picture' => $p->picture,
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
|
||||
mount(fn()
|
||||
=> [
|
||||
$this->loadEvents(),
|
||||
$this->loadBoardEvents(),
|
||||
$this->loadVotes(),
|
||||
$this->loadBoardVotes(),
|
||||
]);
|
||||
|
||||
on([
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function($pubkey) {
|
||||
$this->currentPubkey = $pubkey;
|
||||
$allowedPubkeys = [
|
||||
'0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033',
|
||||
'430169631f2f0682c60cebb4f902d68f0c71c498fd1711fd982f052cf1fd4279',
|
||||
];
|
||||
if(in_array($this->currentPubkey, $allowedPubkeys, true)) {
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
dd($this->isAllowed);
|
||||
},
|
||||
'echo:votes,.newVote' => fn()
|
||||
=> [
|
||||
$this->loadEvents(),
|
||||
$this->loadBoardEvents(),
|
||||
$this->loadVotes(),
|
||||
$this->loadBoardVotes(),
|
||||
],
|
||||
]);
|
||||
|
||||
$loadVotes = function () {
|
||||
$this->votes = collect($this->events)
|
||||
->map(fn($event)
|
||||
=> [
|
||||
'created_at' => $event['created_at'],
|
||||
'pubkey' => $event['pubkey'],
|
||||
'forpubkey' => $this->fetchProfile($event['content']),
|
||||
'type' => str($event['content'])->after(',')->toString(),
|
||||
])
|
||||
->sortByDesc('created_at')
|
||||
->unique(fn($event) => $event['pubkey'] . $event['type'])
|
||||
->values()
|
||||
->groupBy('type')
|
||||
->map(fn($votes)
|
||||
=> [
|
||||
'type' => $votes[0]['type'],
|
||||
'votes' => $votes->groupBy('forpubkey')->map(fn($group) => ['count' => $group->count()])->toArray(),
|
||||
])
|
||||
->values()
|
||||
->toArray();
|
||||
};
|
||||
|
||||
$loadBoardVotes = function () {
|
||||
$this->boardVotes = collect($this->boardEvents)
|
||||
->map(fn($event)
|
||||
=> [
|
||||
'created_at' => $event['created_at'],
|
||||
'pubkey' => $event['pubkey'],
|
||||
'forpubkey' => $this->fetchProfile($event['content']),
|
||||
'type' => str($event['content'])->after(',')->toString(),
|
||||
])
|
||||
->sortByDesc('created_at')
|
||||
->values()
|
||||
->groupBy('type')
|
||||
->map(fn($votes)
|
||||
=> [
|
||||
'type' => $votes[0]['type'],
|
||||
'votes' => $votes->groupBy('forpubkey')->map(fn($group) => ['count' => $group->count()])->toArray(),
|
||||
])
|
||||
->values()
|
||||
->toArray();
|
||||
};
|
||||
|
||||
$loadEvents = function () {
|
||||
$this->events = $this->loadNostrEvents([32122]);
|
||||
};
|
||||
|
||||
$loadBoardEvents = function () {
|
||||
$this->boardEvents = $this->loadNostrEvents([2121]);
|
||||
};
|
||||
|
||||
$fetchProfile = function ($content) {
|
||||
$pubkey = str($content)->before(',')->toString();
|
||||
$profile = \App\Models\Profile::query()->where('pubkey', $pubkey)->first();
|
||||
if (!$profile) {
|
||||
Artisan::call(\App\Console\Commands\Nostr\FetchProfile::class, ['--pubkey' => $pubkey]);
|
||||
$profile = \App\Models\Profile::query()->where('pubkey', $pubkey)->first();
|
||||
}
|
||||
return $profile->pubkey;
|
||||
};
|
||||
|
||||
$loadNostrEvents = function ($kinds) {
|
||||
$subscription = new Subscription();
|
||||
$subscriptionId = $subscription->setId();
|
||||
$filter = new Filter();
|
||||
$filter->setKinds($kinds);
|
||||
$requestMessage = new RequestMessage($subscriptionId, [$filter]);
|
||||
$relaySet = new RelaySet();
|
||||
$relaySet->setRelays([new Relay(config('services.relay'))]);
|
||||
$request = new Request($relaySet, $requestMessage);
|
||||
$response = $request->send();
|
||||
return collect($response[config('services.relay')])
|
||||
->map(function($event) {
|
||||
if(!isset($event->event)) {
|
||||
return false;
|
||||
}
|
||||
return [
|
||||
'id' => $event->event->id,
|
||||
'kind' => $event->event->kind,
|
||||
'content' => $event->event->content,
|
||||
'pubkey' => $event->event->pubkey,
|
||||
'tags' => $event->event->tags,
|
||||
'created_at' => $event->event->created_at,
|
||||
];
|
||||
})
|
||||
->filter()
|
||||
->toArray();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="{{ __('Wahl Manager') }}">
|
||||
@volt
|
||||
@php
|
||||
$positions = [
|
||||
'presidency' => ['icon' => 'fa-crown', 'title' => 'Präsidium'],
|
||||
'board' => ['icon' => 'fa-users', 'title' => 'Vorstandsmitglieder'],
|
||||
];
|
||||
@endphp
|
||||
|
||||
@if($isAllowed)
|
||||
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto" x-data="electionAdminCharts(@this)">
|
||||
|
||||
<!-- Dashboard actions -->
|
||||
<div class="sm:flex sm:justify-between sm:items-center mb-8">
|
||||
|
||||
<!-- Left: Title -->
|
||||
<div class="mb-4 sm:mb-0">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
Wahl des Vorstands {{ $election->year }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@php
|
||||
$president = $positions['presidency'];
|
||||
$board = $positions['board'];
|
||||
@endphp
|
||||
|
||||
<!-- Cards -->
|
||||
<div class="grid gap-y-4">
|
||||
<div wire:key="presidency" wire:ignore
|
||||
class="flex flex-col bg-white dark:bg-gray-800 shadow-sm rounded-xl">
|
||||
<header class="px-5 py-4 border-b border-gray-100 dark:border-gray-700/60">
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100"><i
|
||||
class="fa-sharp-duotone fa-solid {{ $president['icon'] }} w-5 h-5 fill-current text-white mr-4"></i>{{ $president['title'] }}
|
||||
</h2>
|
||||
</header>
|
||||
<div class="grow">
|
||||
<!-- Change the height attribute to adjust the chart height -->
|
||||
<canvas x-ref="chart_presidency" width="724" height="288"
|
||||
style="display: block; box-sizing: border-box; height: 288px; width: 724px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div wire:key="board" wire:ignore
|
||||
class="flex flex-col bg-white dark:bg-gray-800 shadow-sm rounded-xl">
|
||||
<header class="px-5 py-4 border-b border-gray-100 dark:border-gray-700/60">
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100"><i
|
||||
class="fa-sharp-duotone fa-solid {{ $board['icon'] }} w-5 h-5 fill-current text-white mr-4"></i>{{ $board['title'] }}
|
||||
</h2>
|
||||
</header>
|
||||
<div class="grow">
|
||||
<!-- Change the height attribute to adjust the chart height -->
|
||||
<canvas x-ref="chart_board" width="724" height="288"
|
||||
style="display: block; box-sizing: border-box; height: 288px; width: 724px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">Mitglieder</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, Mitglieder zu bearbeiten.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
use function Livewire\Volt\computed;
|
||||
use function Livewire\Volt\mount;
|
||||
use function Livewire\Volt\state;
|
||||
use function Livewire\Volt\with;
|
||||
use function Livewire\Volt\updated;
|
||||
use function Laravel\Folio\{middleware};
|
||||
use function Laravel\Folio\name;
|
||||
use function Livewire\Volt\{on};
|
||||
|
||||
name('association.elections');
|
||||
|
||||
state(['isAllowed' => false]);
|
||||
state(['currentPubkey' => null]);
|
||||
state(['elections' => []]);
|
||||
|
||||
mount(function () {
|
||||
$this->elections = \App\Models\Election::query()
|
||||
->get()
|
||||
->toArray();
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$logPubkeys = [
|
||||
'0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033',
|
||||
'430169631f2f0682c60cebb4f902d68f0c71c498fd1711fd982f052cf1fd4279',
|
||||
];
|
||||
if (in_array($this->currentPubkey, $logPubkeys, true)) {
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
|
||||
->where('pubkey', $pubkey)->first();
|
||||
$logPubkeys = [
|
||||
'0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033',
|
||||
'430169631f2f0682c60cebb4f902d68f0c71c498fd1711fd982f052cf1fd4279',
|
||||
];
|
||||
if (in_array($this->currentPubkey, $logPubkeys, true)) {
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$saveElection = function ($index) {
|
||||
$election = $this->elections[$index];
|
||||
$electionModel = \App\Models\Election::find($election['id']);
|
||||
$electionModel->candidates = $election['candidates'];
|
||||
$electionModel->save();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="{{ __('Wahlen') }}">
|
||||
@volt
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="relative flex h-full">
|
||||
@foreach($elections as $election)
|
||||
<div class="w-full sm:w-1/3 p-4">
|
||||
<div class="shadow-lg rounded-lg overflow-hidden">
|
||||
{{ $election['year'] }}
|
||||
</div>
|
||||
<div class="shadow-lg rounded-lg overflow-hidden">
|
||||
<x-textarea wire:model="elections.{{ $loop->index }}.candidates" rows="25"
|
||||
label="candidates" placeholder=""/>
|
||||
</div>
|
||||
<div class="py-2">
|
||||
<x-button label="Speichern" wire:click="saveElection({{ $loop->index }})"/>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">Einstellungen</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Einstellungen zu bearbeiten.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
with,
|
||||
updated,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('association.members.admin');
|
||||
|
||||
state(['isAllowed' => false]);
|
||||
state(['currentPubkey' => null]);
|
||||
state(['members' => []]);
|
||||
|
||||
mount(function () {
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
|
||||
->where('pubkey', $this->currentPubkey )->first();
|
||||
$allowedPubkeys = [
|
||||
'0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033',
|
||||
'430169631f2f0682c60cebb4f902d68f0c71c498fd1711fd982f052cf1fd4279',
|
||||
'7acf30cf60b85c62b8f654556cc21e4016df8f5604b3b6892794f88bb80d7a1d',
|
||||
'f240be2b684f85cc81566f2081386af81d7427ea86250c8bde6b7a8500c761ba',
|
||||
'19e358b8011f5f4fc653c565c6d4c2f33f32661f4f90982c9eedc292a8774ec3',
|
||||
'acbcec475a1a4f9481939ecfbd1c3d111f5b5a474a39ae039bbc720fdd305bec',
|
||||
];
|
||||
if (in_array($this->currentPubkey, $allowedPubkeys, true)) {
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
},
|
||||
]);
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
|
||||
->where('pubkey', $pubkey)->first();
|
||||
$allowedPubkeys = [
|
||||
'0adf67475ccc5ca456fd3022e46f5d526eb0af6284bf85494c0dd7847f3e5033',
|
||||
'430169631f2f0682c60cebb4f902d68f0c71c498fd1711fd982f052cf1fd4279',
|
||||
'7acf30cf60b85c62b8f654556cc21e4016df8f5604b3b6892794f88bb80d7a1d',
|
||||
'f240be2b684f85cc81566f2081386af81d7427ea86250c8bde6b7a8500c761ba',
|
||||
'19e358b8011f5f4fc653c565c6d4c2f33f32661f4f90982c9eedc292a8774ec3',
|
||||
'acbcec475a1a4f9481939ecfbd1c3d111f5b5a474a39ae039bbc720fdd305bec',
|
||||
];
|
||||
if (in_array($this->currentPubkey, $allowedPubkeys, true)) {
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="{{ __('Mitglieder') }}">
|
||||
@volt
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<livewire:einundzwanzig-pleb-table/>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">Mitglieder</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, Mitglieder zu bearbeiten.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,321 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Forms\NotificationForm;
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
use WireUi\Actions\Notification as WireNotification;
|
||||
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
use function Livewire\Volt\{state, mount, on, computed, form, usesFileUploads};
|
||||
|
||||
name('news');
|
||||
|
||||
form(NotificationForm::class);
|
||||
|
||||
usesFileUploads();
|
||||
|
||||
state([
|
||||
'file',
|
||||
'news' => fn()
|
||||
=> \App\Models\Notification::query()
|
||||
->orderBy('created_at', 'desc')
|
||||
->get(),
|
||||
'isAllowed' => false,
|
||||
'canEdit' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
]);
|
||||
|
||||
mount(function () {
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
|
||||
if (in_array($this->currentPleb->npub, config('einundzwanzig.config.current_board'), true)) {
|
||||
$this->canEdit = true;
|
||||
}
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
if (in_array($this->currentPleb->npub, config('einundzwanzig.config.current_board'), true)) {
|
||||
$this->canEdit = true;
|
||||
}
|
||||
$this->isAllowed = true;
|
||||
},
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
$save = function () {
|
||||
$this->form->validate();
|
||||
|
||||
$this->validate([
|
||||
'file' => 'required|file|mimes:pdf|max:1024',
|
||||
]);
|
||||
|
||||
$notification = \App\Models\Notification::query()
|
||||
->orderBy('created_at', 'desc')
|
||||
->create([
|
||||
'einundzwanzig_pleb_id' => $this->currentPleb->id,
|
||||
'category' => $this->form->category,
|
||||
'name' => $this->form->name,
|
||||
'description' => $this->form->description,
|
||||
]);
|
||||
|
||||
$notification
|
||||
->addMedia($this->file->getRealPath())
|
||||
->usingName($this->file->getClientOriginalName())
|
||||
->toMediaCollection('pdf');
|
||||
|
||||
$this->form->reset();
|
||||
$this->file = null;
|
||||
|
||||
$this->news = \App\Models\Notification::query()
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
};
|
||||
|
||||
$delete = function ($id) {
|
||||
$notification = new WireNotification($this);
|
||||
$notification->confirm([
|
||||
'title' => 'Post löschen',
|
||||
'message' => 'Bist du sicher, dass du diesen Post löschen möchtest?',
|
||||
'accept' => [
|
||||
'label' => 'Ja, löschen',
|
||||
'method' => 'deleteNow',
|
||||
'params' => $id,
|
||||
],
|
||||
]);
|
||||
};
|
||||
|
||||
$deleteNow = function ($id) {
|
||||
$notification = \App\Models\Notification::query()->find($id);
|
||||
$notification->delete();
|
||||
$this->news = \App\Models\Notification::query()
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app
|
||||
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'News', description: 'Die News des Vereins.')"
|
||||
>
|
||||
@volt
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 md:py-0 w-full max-w-9xl mx-auto">
|
||||
|
||||
<div class="xl:flex">
|
||||
|
||||
<!-- Left + Middle content -->
|
||||
<div class="md:flex flex-1">
|
||||
|
||||
<!-- Left content -->
|
||||
<div class="w-full md:w-60 mb-8 md:mb-0">
|
||||
<div
|
||||
class="md:sticky md:top-16 md:h-[calc(100dvh-64px)] md:overflow-x-hidden md:overflow-y-auto no-scrollbar">
|
||||
<div class="md:py-8">
|
||||
|
||||
<div class="flex justify-between items-center md:block">
|
||||
|
||||
<!-- Title -->
|
||||
<header class="mb-6">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
News</h1>
|
||||
</header>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Links -->
|
||||
<div
|
||||
class="flex flex-nowrap overflow-x-scroll no-scrollbar md:block md:overflow-auto px-4 md:space-y-3 -mx-4">
|
||||
<!-- Group 1 -->
|
||||
<div>
|
||||
<div
|
||||
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3 md:sr-only">
|
||||
Menu
|
||||
</div>
|
||||
<ul class="flex flex-nowrap md:block mr-3 md:mr-0">
|
||||
@foreach(\App\Enums\NewsCategory::selectOptions() as $category)
|
||||
<li class="mr-0.5 md:mr-0 md:mb-0.5"
|
||||
wire:key="category_{{ $category['value'] }}">
|
||||
<div
|
||||
class="flex items-center px-2.5 py-2 rounded-lg whitespace-nowrap bg-white dark:bg-gray-800">
|
||||
<i class="fa-sharp-duotone fa-solid fa-{{ $category['icon'] }} shrink-0 fill-current text-amber-500 mr-2"></i>
|
||||
<span
|
||||
class="text-sm font-medium text-amber-500">{{ $category['label'] }}</span>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Middle content -->
|
||||
<div class="flex-1 md:ml-8 xl:mx-4 2xl:mx-8">
|
||||
<div class="md:py-8">
|
||||
|
||||
<div class="space-y-2">
|
||||
@forelse($news as $post)
|
||||
<article wire:key="post_{{ $post->id }}"
|
||||
class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<div class="flex flex-start space-x-4">
|
||||
<!-- Avatar -->
|
||||
<div class="shrink-0 mt-1.5">
|
||||
<img class="w-8 h-8 rounded-full"
|
||||
src="{{ $post->einundzwanzigPleb->profile?->picture ?? asset('einundzwanzig-alpha.jpg') }}"
|
||||
width="32" height="32"
|
||||
alt="{{ $post->einundzwanzigPleb->profile?->name }}">
|
||||
</div>
|
||||
<!-- Content -->
|
||||
<div class="grow">
|
||||
<!-- Title -->
|
||||
<h2 class="font-semibold text-gray-800 dark:text-gray-100 mb-2">
|
||||
{{ $post->name }}
|
||||
</h2>
|
||||
<p class="mb-6">
|
||||
{{ $post->description }}
|
||||
</p>
|
||||
<!-- Footer -->
|
||||
<footer class="flex flex-wrap text-sm">
|
||||
<div
|
||||
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
|
||||
<div
|
||||
class="font-medium text-amber-500 hover:text-amber-600 dark:hover:text-amber-400">
|
||||
<div class="flex items-center">
|
||||
<svg class="mr-2 fill-current" width="16"
|
||||
height="16"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
|
||||
</svg>
|
||||
{{ $post->einundzwanzigPleb->profile->name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
|
||||
<span
|
||||
class="text-gray-500">{{ $post->created_at->format('d.m.Y') }}</span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 flex justify-end w-full space-x-2">
|
||||
<x-button
|
||||
xs
|
||||
target="_blank"
|
||||
:href="url()->temporarySignedRoute('dl', now()->addMinutes(30), ['media' => $post->getFirstMedia('pdf')])"
|
||||
label="Öffnen"
|
||||
primary icon="cloud-arrow-down"/>
|
||||
@if($canEdit)
|
||||
<x-button
|
||||
xs
|
||||
wire:click="delete({{ $post->id }})"
|
||||
label="Löschen"
|
||||
negative icon="trash"/>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@empty
|
||||
<article class="bg-white dark:bg-gray-800 shadow-sm rounded-xl p-5">
|
||||
<p>Keine News vorhanden.</p>
|
||||
</article>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Right content -->
|
||||
<div class="w-full mt-8 sm:mt-0 xl:w-72">
|
||||
<div
|
||||
class="lg:sticky lg:top-16 lg:h-[calc(100dvh-64px)] lg:overflow-x-hidden lg:overflow-y-auto no-scrollbar">
|
||||
<div class="md:py-8">
|
||||
|
||||
<!-- Blocks -->
|
||||
<div class="space-y-4">
|
||||
|
||||
@if($canEdit)
|
||||
<div class="bg-white dark:bg-gray-800 p-4 rounded-xl">
|
||||
<div
|
||||
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-4">
|
||||
News anlegen
|
||||
</div>
|
||||
<div class="mt-4 flex flex-col space-y-2">
|
||||
<div>
|
||||
<input class="text-gray-200" type="file" wire:model="file">
|
||||
@error('file') <span
|
||||
class="text-red-500">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<div>
|
||||
<x-native-select
|
||||
wire:model="form.category"
|
||||
label="Kategorie"
|
||||
placeholder="Wähle Kategorie"
|
||||
:options="\App\Enums\NewsCategory::selectOptions()"
|
||||
option-label="label" option-value="value"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<x-input label="Titel" wire:model="form.name"/>
|
||||
</div>
|
||||
<div>
|
||||
<x-textarea
|
||||
description="optional"
|
||||
label="Beschreibung" wire:model="form.description"/>
|
||||
</div>
|
||||
<button
|
||||
wire:click="save"
|
||||
class="btn-sm w-full bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-gray-800 dark:text-gray-300">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
News
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die News einzusehen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,794 +0,0 @@
|
||||
<?php
|
||||
|
||||
use swentel\nostr\Event\Event as NostrEvent;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Message\EventMessage;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Relay\RelaySet;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Sign\Sign;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
use WireUi\Actions\Notification;
|
||||
|
||||
use function Laravel\Folio\{name};
|
||||
use function Livewire\Volt\{form, mount, on, state, updated};
|
||||
|
||||
name('association.profile');
|
||||
|
||||
state([
|
||||
'no' => false,
|
||||
'showEmail' => true,
|
||||
'fax' => '',
|
||||
'email' => '',
|
||||
'yearsPaid' => [],
|
||||
'events' => [],
|
||||
'payments' => [],
|
||||
'amountToPay' => config('app.env') === 'production' ? 21000 : 1,
|
||||
'currentYearIsPaid' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
]);
|
||||
|
||||
form(\App\Livewire\Forms\ApplicationForm::class);
|
||||
|
||||
mount(function () {
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
|
||||
->with([
|
||||
'paymentEvents' => fn($query)
|
||||
=> $query->where('year', date('Y')),
|
||||
])
|
||||
->where('pubkey', $this->currentPubkey)->first();
|
||||
$this->email = $this->currentPleb->email;
|
||||
$this->no = $this->currentPleb->no_email;
|
||||
$this->showEmail = !$this->no;
|
||||
if ($this->currentPleb->association_status === \App\Enums\AssociationStatus::ACTIVE) {
|
||||
$this->amountToPay = config('app.env') === 'production' ? 21000 : 1;
|
||||
}
|
||||
if ($this->currentPleb->paymentEvents->count() < 1) {
|
||||
$this->createPaymentEvent();
|
||||
$this->currentPleb->load('paymentEvents');
|
||||
}
|
||||
$this->loadEvents();
|
||||
$this->listenForPayment();
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()
|
||||
->with([
|
||||
'paymentEvents' => fn($query)
|
||||
=> $query->where('year', date('Y')),
|
||||
])
|
||||
->where('pubkey', $pubkey)->first();
|
||||
$this->email = $this->currentPleb->email;
|
||||
$this->no = $this->currentPleb->no_email;
|
||||
$this->showEmail = !$this->no;
|
||||
if ($this->currentPleb->association_status === \App\Enums\AssociationStatus::ACTIVE) {
|
||||
$this->amountToPay = config('app.env') === 'production' ? 21000 : 1;
|
||||
}
|
||||
if ($this->currentPleb->paymentEvents->count() < 1) {
|
||||
$this->createPaymentEvent();
|
||||
$this->currentPleb->load('paymentEvents');
|
||||
}
|
||||
$this->loadEvents();
|
||||
$this->listenForPayment();
|
||||
},
|
||||
'nostrLoggedOut' => function () {
|
||||
\App\Support\NostrAuth::logout();
|
||||
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
$this->yearsPaid = [];
|
||||
$this->events = [];
|
||||
$this->payments = [];
|
||||
$this->qrCode = null;
|
||||
$this->amountToPay = config('app.env') === 'production' ? 21000 : 1;
|
||||
$this->currentYearIsPaid = false;
|
||||
},
|
||||
]);
|
||||
|
||||
updated([
|
||||
'no' => function () {
|
||||
$this->showEmail = !$this->no;
|
||||
$this->currentPleb->update([
|
||||
'no_email' => $this->no,
|
||||
]);
|
||||
},
|
||||
'fax' => function () {
|
||||
$this->js('alert("Markus Turm wird sich per Fax melden!")');
|
||||
},
|
||||
]);
|
||||
|
||||
$saveEmail = function () {
|
||||
$this->validate([
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
$this->currentPleb->update([
|
||||
'email' => $this->email,
|
||||
]);
|
||||
$notification = new Notification($this);
|
||||
$notification->success('E-Mail Adresse gespeichert.');
|
||||
};
|
||||
|
||||
$pay = function ($comment) {
|
||||
$paymentEvent = $this->currentPleb
|
||||
->paymentEvents()
|
||||
->where('year', date('Y'))
|
||||
->first();
|
||||
if ($paymentEvent->btc_pay_invoice) {
|
||||
return redirect('https://pay.einundzwanzig.space/i/'.$paymentEvent->btc_pay_invoice);
|
||||
}
|
||||
try {
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'token '.config('services.btc_pay.api_key'),
|
||||
])->post(
|
||||
'https://pay.einundzwanzig.space/api/v1/stores/98PF86BoMd3C8P1nHHyFdoeznCwtcm5yehcAgoCYDQ2a/invoices',
|
||||
[
|
||||
'amount' => $this->amountToPay,
|
||||
'metadata' => [
|
||||
'orderId' => $comment,
|
||||
'orderUrl' => url()->route('association.profile'),
|
||||
'itemDesc' => 'Mitgliedsbeitrag '.date('Y').' von nostr:'.$this->currentPleb->npub,
|
||||
'posData' => [
|
||||
'event' => $paymentEvent->event_id,
|
||||
'pubkey' => $this->currentPleb->pubkey,
|
||||
'npub' => $this->currentPleb->npub,
|
||||
],
|
||||
],
|
||||
'checkout' => [
|
||||
'expirationMinutes' => 60 * 24,
|
||||
'redirectURL' => url()->route('association.profile'),
|
||||
'redirectAutomatically' => true,
|
||||
'defaultLanguage' => 'de',
|
||||
],
|
||||
],
|
||||
)->throw();
|
||||
$paymentEvent->btc_pay_invoice = $response->json()['id'];
|
||||
$paymentEvent->save();
|
||||
|
||||
return redirect($response->json()['checkoutLink']);
|
||||
} catch (Exception $e) {
|
||||
$notification = new Notification($this);
|
||||
$notification->error(
|
||||
'Fehler beim Erstellen der Rechnung. Bitte versuche es später erneut: '.$e->getMessage(),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
$listenForPayment = function () {
|
||||
$paymentEvent = $this->currentPleb
|
||||
->paymentEvents()
|
||||
->where('year', date('Y'))
|
||||
->first();
|
||||
if ($paymentEvent->btc_pay_invoice) {
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'token '.config('services.btc_pay.api_key'),
|
||||
])
|
||||
->get(
|
||||
'https://pay.einundzwanzig.space/api/v1/stores/98PF86BoMd3C8P1nHHyFdoeznCwtcm5yehcAgoCYDQ2a/invoices/'.$paymentEvent->btc_pay_invoice,
|
||||
);
|
||||
if ($response->json()['status'] === 'Expired') {
|
||||
$paymentEvent->btc_pay_invoice = null;
|
||||
$paymentEvent->paid = false;
|
||||
$paymentEvent->save();
|
||||
}
|
||||
if ($response->json()['status'] === 'Settled') {
|
||||
$paymentEvent->paid = true;
|
||||
$paymentEvent->save();
|
||||
$this->currentYearIsPaid = true;
|
||||
}
|
||||
}
|
||||
if ($paymentEvent->paid) {
|
||||
$this->currentYearIsPaid = true;
|
||||
}
|
||||
$paymentEvent = $paymentEvent->refresh();
|
||||
$this->payments = $this->currentPleb
|
||||
->paymentEvents()
|
||||
->where('paid', true)
|
||||
->get();
|
||||
};
|
||||
|
||||
$save = function ($type) {
|
||||
$this->form->validate();
|
||||
if (!$this->form->check) {
|
||||
$this->js('alert("Du musst den Statuten zustimmen.")');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->currentPleb
|
||||
->update([
|
||||
'association_status' => $type,
|
||||
]);
|
||||
};
|
||||
|
||||
$createPaymentEvent = function () {
|
||||
$note = new NostrEvent();
|
||||
$note->setKind(32121);
|
||||
$note->setContent(
|
||||
'Dieses Event dient der Zahlung des Mitgliedsbeitrags für das Jahr '.date(
|
||||
'Y',
|
||||
).'. Bitte bezahle den Betrag von '.number_format($this->amountToPay, 0, ',', '.').' Satoshis.',
|
||||
);
|
||||
$note->setTags([
|
||||
['d', $this->currentPleb->pubkey.','.date('Y')],
|
||||
['zap', 'daf83d92768b5d0005373f83e30d4203c0b747c170449e02fea611a0da125ee6', config('services.relay'), '1'],
|
||||
]);
|
||||
$signer = new Sign();
|
||||
$signer->signEvent($note, config('services.nostr'));
|
||||
|
||||
$eventMessage = new EventMessage($note);
|
||||
|
||||
$relayUrl = config('services.relay');
|
||||
$relay = new Relay($relayUrl);
|
||||
$relay->setMessage($eventMessage);
|
||||
$result = $relay->send();
|
||||
|
||||
$this->currentPleb->paymentEvents()->create([
|
||||
'year' => date('Y'),
|
||||
'event_id' => $result->eventId,
|
||||
'amount' => $this->amountToPay,
|
||||
]);
|
||||
};
|
||||
|
||||
$loadEvents = function () {
|
||||
$subscription = new Subscription();
|
||||
$subscriptionId = $subscription->setId();
|
||||
|
||||
$filter1 = new Filter();
|
||||
$filter1->setKinds([32121]);
|
||||
$filter1->setAuthors(['daf83d92768b5d0005373f83e30d4203c0b747c170449e02fea611a0da125ee6']);
|
||||
$filters = [$filter1];
|
||||
|
||||
$requestMessage = new RequestMessage($subscriptionId, $filters);
|
||||
|
||||
$relays = [
|
||||
new Relay(config('services.relay')),
|
||||
];
|
||||
$relaySet = new RelaySet();
|
||||
$relaySet->setRelays($relays);
|
||||
|
||||
$request = new Request($relaySet, $requestMessage);
|
||||
$response = $request->send();
|
||||
|
||||
$this->events = collect($response[config('services.relay')])
|
||||
->map(function ($event) {
|
||||
if (!isset($event->event)) {
|
||||
return false;
|
||||
}
|
||||
return [
|
||||
'id' => $event->event->id,
|
||||
'kind' => $event->event->kind,
|
||||
'content' => $event->event->content,
|
||||
'pubkey' => $event->event->pubkey,
|
||||
'tags' => $event->event->tags,
|
||||
'created_at' => $event->event->created_at,
|
||||
];
|
||||
})
|
||||
->filter()
|
||||
->unique('id')
|
||||
->toArray();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app
|
||||
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Mitgliedschaft', description: 'Einundzwanzig ist, was du draus machst.')"
|
||||
>
|
||||
@volt
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
|
||||
<!-- Page header -->
|
||||
<div class="mb-8">
|
||||
|
||||
<!-- Title -->
|
||||
<h1 class="text-2xl md:text-3xl text-[#1B1B1B] dark:text-gray-100 font-bold">
|
||||
Einundzwanzig ist, was du draus machst
|
||||
</h1>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow-sm rounded-xl mb-8">
|
||||
<div class="flex flex-col md:flex-row md:-mr-px">
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div
|
||||
class="flex flex-nowrap overflow-x-scroll no-scrollbar md:block md:overflow-auto px-3 py-6 border-b md:border-b-0 md:border-r border-gray-200 dark:border-gray-700/60 min-w-60 md:space-y-3">
|
||||
<!-- Group 1 -->
|
||||
<div>
|
||||
<div class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3">
|
||||
Meine Mitgliedschaft
|
||||
</div>
|
||||
<ul class="flex flex-nowrap md:block mr-3 md:mr-0">
|
||||
<li class="mr-0.5 md:mr-0 md:mb-0.5">
|
||||
<a class="flex items-center px-2.5 py-2 rounded-lg whitespace-nowrap bg-[linear-gradient(135deg,var(--tw-gradient-stops))] from-orange-500/[0.12] dark:from-orange-500/[0.24] to-orange-500/[0.04]"
|
||||
href="#0">
|
||||
<i class="fa-sharp-duotone fa-solid fa-id-card-clip shrink-0 fill-current text-orange-400 mr-2"></i>
|
||||
<span
|
||||
class="text-sm font-medium text-orange-500 dark:text-orange-400">Status</span>
|
||||
</a>
|
||||
</li>
|
||||
{{--<li class="mr-0.5 md:mr-0 md:mb-0.5">
|
||||
<a class="flex items-center px-2.5 py-2 rounded-lg whitespace-nowrap"
|
||||
href="notifications.html">
|
||||
<svg class="shrink-0 fill-current text-gray-400 dark:text-gray-500 mr-2" width="16"
|
||||
height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="m9 12.614 4.806 1.374a.15.15 0 0 0 .174-.21L8.133 2.082a.15.15 0 0 0-.268 0L2.02 13.777a.149.149 0 0 0 .174.21L7 12.614V9a1 1 0 1 1 2 0v3.614Zm-1 1.794-5.257 1.503c-1.798.514-3.35-1.355-2.513-3.028L6.076 1.188c.791-1.584 3.052-1.584 3.845 0l5.848 11.695c.836 1.672-.714 3.54-2.512 3.028L8 14.408Z"/>
|
||||
</svg>
|
||||
<span
|
||||
class="text-sm font-medium text-gray-600 dark:text-gray-300 hover:text-gray-700 dark:hover:text-gray-200">My Notifications</span>
|
||||
</a>
|
||||
</li>--}}
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Group 2 -->
|
||||
{{--<div>
|
||||
<div class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3">Experience
|
||||
</div>
|
||||
<ul class="flex flex-nowrap md:block mr-3 md:mr-0">
|
||||
<li class="mr-0.5 md:mr-0 md:mb-0.5">
|
||||
<a class="flex items-center px-2.5 py-2 rounded-lg whitespace-nowrap"
|
||||
href="feedback.html">
|
||||
<svg class="shrink-0 fill-current text-gray-400 dark:text-gray-500 mr-2" width="16"
|
||||
height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M14.3.3c.4-.4 1-.4 1.4 0 .4.4.4 1 0 1.4l-8 8c-.2.2-.4.3-.7.3-.3 0-.5-.1-.7-.3-.4-.4-.4-1 0-1.4l8-8zM15 7c.6 0 1 .4 1 1 0 4.4-3.6 8-8 8s-8-3.6-8-8 3.6-8 8-8c.6 0 1 .4 1 1s-.4 1-1 1C4.7 2 2 4.7 2 8s2.7 6 6 6 6-2.7 6-6c0-.6.4-1 1-1z"/>
|
||||
</svg>
|
||||
<span
|
||||
class="text-sm font-medium text-gray-600 dark:text-gray-300 hover:text-gray-700 dark:hover:text-gray-200">Give Feedback</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>--}}
|
||||
</div>
|
||||
|
||||
<!-- Panel -->
|
||||
<div class="grow">
|
||||
|
||||
<!-- Panel body -->
|
||||
<div class="p-6 space-y-6">
|
||||
<h2 class="sm:text-2xl text-[#1B1B1B] dark:text-gray-100 font-bold mb-5">Aktueller Status</h2>
|
||||
|
||||
<section>
|
||||
|
||||
@if(!$currentPleb)
|
||||
<div class="space-y-2 mb-12">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<div class="text-xl text-gray-500 dark:text-gray-400 italic">Empfohlene Nostr
|
||||
Login und Signer-Apps
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-xl px-5 py-4">
|
||||
<div
|
||||
class="md:flex justify-between items-center space-y-4 md:space-y-0 space-x-2">
|
||||
<!-- Left side -->
|
||||
<div class="flex items-start space-x-3 md:space-x-4">
|
||||
<div>
|
||||
<a class="inline-flex font-semibold text-gray-800 dark:text-gray-100"
|
||||
href="https://github.com/greenart7c3/Amber">
|
||||
Amber
|
||||
</a>
|
||||
<div class="text-sm">Perfekt für mobile Android Geräte. Eine App, in
|
||||
der man alle Keys/nsecs verwalten kann.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right side -->
|
||||
<div class="flex items-center space-x-4 pl-10 md:pl-0">
|
||||
<div
|
||||
class="text-xs inline-flex font-medium bg-green-500/20 text-green-700 rounded-full text-center px-2.5 py-1">
|
||||
Android
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-xl px-5 py-4">
|
||||
<div
|
||||
class="md:flex justify-between items-center space-y-4 md:space-y-0 space-x-2">
|
||||
<!-- Left side -->
|
||||
<div class="flex items-start space-x-3 md:space-x-4">
|
||||
<div>
|
||||
<a class="inline-flex font-semibold text-gray-800 dark:text-gray-100"
|
||||
href="https://addons.mozilla.org/en-US/firefox/addon/alby/">
|
||||
Alby - Bitcoin Lightning Wallet & Nostr
|
||||
</a>
|
||||
<div class="text-sm">
|
||||
Browser-Erweiterung in die man seinen Key/nsec eingeben kann.
|
||||
Pro Alby-Konto ein nsec.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right side -->
|
||||
<div class="flex items-center space-x-4 pl-10 md:pl-0">
|
||||
<div
|
||||
class="text-xs inline-flex font-medium bg-yellow-500/20 text-yellow-700 rounded-full text-center px-2.5 py-1">
|
||||
Browser Chrome/Firefox
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-xl px-5 py-4">
|
||||
<div
|
||||
class="md:flex justify-between items-center space-y-4 md:space-y-0 space-x-2">
|
||||
<!-- Left side -->
|
||||
<div class="flex items-start space-x-3 md:space-x-4">
|
||||
<div>
|
||||
<a class="inline-flex font-semibold text-gray-800 dark:text-gray-100"
|
||||
href="https://chromewebstore.google.com/detail/nos2x/kpgefcfmnafjgpblomihpgmejjdanjjp">
|
||||
nos2x
|
||||
</a>
|
||||
<div class="text-sm">
|
||||
Browser-Erweiterung für Chrome Browser. Multi-Key fähig.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right side -->
|
||||
<div class="flex items-center space-x-4 pl-10 md:pl-0">
|
||||
<div
|
||||
class="text-xs inline-flex font-medium bg-red-500/20 text-red-700 rounded-full text-center px-2.5 py-1">
|
||||
Browser Chrome
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white dark:bg-gray-800 shadow-sm rounded-xl px-5 py-4">
|
||||
<div
|
||||
class="md:flex justify-between items-center space-y-4 md:space-y-0 space-x-2">
|
||||
<!-- Left side -->
|
||||
<div class="flex items-start space-x-3 md:space-x-4">
|
||||
<div>
|
||||
<a class="inline-flex font-semibold text-gray-800 dark:text-gray-100"
|
||||
href="https://addons.mozilla.org/en-US/firefox/addon/nos2x-fox/">
|
||||
nos2x-fox
|
||||
</a>
|
||||
<div class="text-sm">
|
||||
Browser-Erweiterung für Firefox Browser. Multi-Key fähig.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right side -->
|
||||
<div class="flex items-center space-x-4 pl-10 md:pl-0">
|
||||
<div
|
||||
class="text-xs inline-flex font-medium bg-amber-500/20 text-amber-700 rounded-full text-center px-2.5 py-1">
|
||||
Browser Firefox
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex flex-wrap space-y-2 sm:space-y-0 items-center justify-between">
|
||||
{{-- https://v.nostr.build/bomfuwLnOTIDrP4y.mp4 --}}
|
||||
<template x-if="$store.nostr.user">
|
||||
<div class="flex items">
|
||||
<img class="w-12 h-12 rounded-full"
|
||||
x-bind:src="$store.nostr.user.picture || '{{ asset('apple-touch-icon.png') }}'"
|
||||
alt="Avatar">
|
||||
<div class="ml-4">
|
||||
<h3 class="w-48 sm:w-full truncate text-lg leading-snug text-[#1B1B1B] dark:text-gray-100 font-bold"
|
||||
x-text="$store.nostr.user.display_name"></h3>
|
||||
<div
|
||||
class="w-48 sm:w-full truncate text-sm text-gray-500 dark:text-gray-400"
|
||||
x-text="$store.nostr.user.name"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@if($currentPubkey && $currentPleb->association_status->value < 2)
|
||||
<div
|
||||
class="inline-flex min-w-80 px-4 py-2 rounded-lg text-sm bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-100">
|
||||
<div class="flex w-full justify-between items-start">
|
||||
<div class="flex">
|
||||
<svg class="shrink-0 fill-current text-green-500 mt-[3px] mr-3"
|
||||
width="16" height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zM7 11.4L3.6 8 5 6.6l2 2 4-4L12.4 6 7 11.4z"></path>
|
||||
</svg>
|
||||
<div>Profil in der Datenbank vorhanden.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{--<section>
|
||||
@if($currentPubkey && !$currentPleb->application_for && $currentPleb->association_status->value < 2)
|
||||
<h3 class="text-xl leading-snug text-[#1B1B1B] dark:text-gray-100 font-bold mb-1">
|
||||
passives Mitglied werden
|
||||
</h3>
|
||||
<h4 class="text-xs leading-snug text-[#1B1B1B] dark:text-gray-100 font-italic mb-1">
|
||||
Passivmitglieder haben kein Stimmrecht. Firmen können nur Passivmitglieder werden und zahlen das 100-fache des festgelegten Beitrags.
|
||||
</h4>
|
||||
<div class="text-sm">
|
||||
<x-textarea
|
||||
corner="Beschreibe deine Motivation, passives Mitglied zu werden."
|
||||
label="Warum möchtest du passives Mitglied werden?"
|
||||
wire:model="form.reason"/>
|
||||
</div>
|
||||
<div class="sm:flex sm:items-center space-y-4 sm:space-y-0 sm:space-x-4 mt-5">
|
||||
<div class="sm:w-1/3 flex flex-col space-y-2">
|
||||
<x-button label="Für passive Mitgliedschaft bewerben"
|
||||
wire:click="save({{ \App\Enums\AssociationStatus::PASSIVE() }})"/>
|
||||
<x-badge outline
|
||||
label="Es wird im Anschluss ein Nostr Event erzeugt, das du mit dem Mitgliedsbeitrag zappen kannst, nachdem du bestätigt wurdest."/>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</section>--}}
|
||||
|
||||
<section>
|
||||
@if($currentPubkey && !$currentPleb->application_for && $currentPleb->association_status->value < 2)
|
||||
<h3 class="text-xl leading-snug text-[#1B1B1B] dark:text-gray-100 font-bold mb-1">
|
||||
Einundzwanzig Mitglied werden
|
||||
</h3>
|
||||
<h4 class="text-xs leading-snug text-[#1B1B1B] dark:text-gray-100 font-italic mb-1">
|
||||
Nur Personen können Mitglied werden und zahlen 21.000 Satoshis im Jahr.<br>
|
||||
<a href="https://einundzwanzig.space/verein/" class="text-amber-500">Firmen melden
|
||||
sich bitte direkt an den Vorstand.</a>
|
||||
</h4>
|
||||
<div class="sm:flex sm:items-center space-y-4 sm:space-y-0 sm:space-x-4 mt-5">
|
||||
<div class="sm:w-1/2 flex flex-col space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<div>
|
||||
<x-checkbox wire:model="form.check"
|
||||
label="Ich stimme den Vereins-Statuten zu"/>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://einundzwanzig.space/verein/" target="_blank"
|
||||
class="text-amber-500">Statuten</a>
|
||||
</div>
|
||||
</div>
|
||||
<x-button label="Mit deinem aktuellen Nostr-Profil Mitglied werden"
|
||||
wire:click="save({{ \App\Enums\AssociationStatus::PASSIVE() }})"/>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@if($currentPubkey)
|
||||
<div
|
||||
class="mt-6 inline-flex flex-col w-full px-4 py-2 rounded-lg text-sm bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-400">
|
||||
<div class="flex w-full justify-between items-start">
|
||||
<div class="flex w-full">
|
||||
<svg class="shrink-0 fill-current text-yellow-500 mt-[3px] mr-3"
|
||||
width="16"
|
||||
height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 12c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm1-3H7V4h2v5z"></path>
|
||||
</svg>
|
||||
<div class="w-full">
|
||||
<div
|
||||
class="w-full font-medium text-gray-800 dark:text-gray-100 mb-1">
|
||||
Falls du möchtest, kannst du hier eine E-Mail Adresse
|
||||
hinterlegen,
|
||||
damit der Verein dich darüber informieren kann, wenn es
|
||||
Neuigkeiten
|
||||
gibt.<br><br>
|
||||
Am besten eine anynomisierte E-Mail Adresse verwenden. Wir
|
||||
sichern
|
||||
diese Adresse AES-256 verschlüsselt in der Datenbank ab.
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col sm:flex-row space-y-2 sm:space-y-0 sm:space-x-2 text-amber-500">
|
||||
<x-toggle xl warning
|
||||
wire:model.live="no"
|
||||
label="NEIN">
|
||||
<x-slot name="description">
|
||||
<span class="py-2 text-amber-500">Ich informiere mich selbst in der News Sektion und gebe keine E-Mail Adresse raus.</span>
|
||||
</x-slot>
|
||||
</x-toggle>
|
||||
</div>
|
||||
@if($showEmail)
|
||||
<div wire:key="showEmail"
|
||||
class="flex flex-col sm:flex-row space-y-2 sm:space-y-0 sm:space-x-2">
|
||||
<x-input wire:model.live.debounce="fax" label="Fax-Nummer"/>
|
||||
<x-input wire:model.live.debounce="email"
|
||||
label="E-Mail Adresse"/>
|
||||
</div>
|
||||
<div wire:key="showSave" class="flex space-x-2 mt-2">
|
||||
<x-button wire:click="saveEmail" label="Speichern"/>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@if($currentPubkey && $currentPleb->application_for)
|
||||
<div
|
||||
class="inline-flex flex-col w-full max-w-lg px-4 py-2 rounded-lg text-sm bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-400">
|
||||
<div class="flex w-full justify-between items-start">
|
||||
<div class="flex">
|
||||
<svg class="shrink-0 fill-current text-yellow-500 mt-[3px] mr-3" width="16"
|
||||
height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 12c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm1-3H7V4h2v5z"></path>
|
||||
</svg>
|
||||
<div>
|
||||
<div class="font-medium text-gray-800 dark:text-gray-100 mb-1">
|
||||
Du hast dich erfolgreich mit folgendem Grund beworben:
|
||||
</div>
|
||||
<div>{{ $currentPleb->application_text }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-medium text-gray-800 dark:text-gray-100 mb-1">
|
||||
Schaue später vorbei, denn nun muss jemand aus dem Vorstand deine
|
||||
Bewerbung prüfen.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@if($currentPleb && $currentPleb->association_status->value > 1)
|
||||
<div class="flex flex-col space-y-4">
|
||||
<div
|
||||
class="inline-flex flex-col w-full max-w-lg px-4 py-2 rounded-lg text-sm bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-400">
|
||||
<div class="flex w-full justify-between items-start">
|
||||
<div class="flex">
|
||||
<svg class="shrink-0 fill-current text-green-500 mt-[3px] mr-3"
|
||||
width="16"
|
||||
height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 12c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm1-3H7V4h2v5z"></path>
|
||||
</svg>
|
||||
<div>
|
||||
<div class="font-medium text-gray-800 dark:text-gray-100 mb-1">
|
||||
Du bist derzeit ein Mitglied des Vereins.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@if($currentPleb && $currentPleb->association_status->value > 1)
|
||||
<div
|
||||
class="inline-flex flex-col w-full px-4 py-2 rounded-lg text-sm bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-400">
|
||||
<div class="flex w-full justify-between items-start">
|
||||
<div class="flex">
|
||||
<svg class="shrink-0 fill-current text-yellow-500 mt-[3px] mr-3" width="16"
|
||||
height="16" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 12c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm1-3H7V4h2v5z"></path>
|
||||
</svg>
|
||||
<div>
|
||||
<div
|
||||
class="font-medium text-gray-800 dark:text-gray-100 mb-1 space-y-2">
|
||||
<p>Nostr Event für die Zahlung des
|
||||
Mitgliedsbeitrags: <span
|
||||
class="break-all">{{ $currentPleb->paymentEvents->last()->event_id }}</span>
|
||||
</p>
|
||||
<div>
|
||||
@php
|
||||
// latest event by created_at field of $events
|
||||
$latestEvent = collect($events)->sortByDesc('created_at')->first();
|
||||
@endphp
|
||||
@if(isset($latestEvent))
|
||||
<p>{{ $latestEvent['content'] }}</p>
|
||||
<div class="mt-8">
|
||||
@if(!$currentYearIsPaid)
|
||||
<div class="flex justify-center">
|
||||
<button
|
||||
wire:click="pay('{{ date('Y') }}:{{ $currentPubkey }}')"
|
||||
class="btn text-2xl dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-green-500"
|
||||
>
|
||||
<i class="fa-sharp-duotone fa-solid fa-bolt-lightning mr-2"></i>
|
||||
Pay {{ $amountToPay }} Sats
|
||||
</button>
|
||||
</div>
|
||||
@else
|
||||
@if($currentYearIsPaid)
|
||||
<div class="flex sm:justify-center">
|
||||
<div
|
||||
class="btn sm:text-2xl dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 text-green-500"
|
||||
>
|
||||
<i class="fa-sharp-duotone fa-solid fa-check-circle mr-2"></i>
|
||||
aktuelles Jahr bezahlt
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
<div class="flex sm:justify-center">
|
||||
<button
|
||||
class="btn dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-amber-500"
|
||||
>
|
||||
<i class="fa-sharp-duotone fa-solid fa-user-helmet-safety mr-2"></i>
|
||||
Unser Nostr-Relay konnte derzeit nicht erreicht
|
||||
werden, um eine Zahlung zu initialisieren. Bitte
|
||||
versuche es später noch einmal.
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<section>
|
||||
<h3 class="text-xl leading-snug text-gray-800 dark:text-gray-100 font-bold mb-1">
|
||||
bisherige Zahlungen</h3>
|
||||
<!-- Table -->
|
||||
<table class="table-auto w-full dark:text-gray-400">
|
||||
<!-- Table header -->
|
||||
<thead
|
||||
class="text-xs uppercase text-gray-400 dark:text-gray-500">
|
||||
<tr class="flex flex-wrap md:table-row md:flex-no-wrap">
|
||||
<th class="w-full hidden md:w-auto md:table-cell py-2">
|
||||
<div class="font-semibold text-left">Satoshis</div>
|
||||
</th>
|
||||
<th class="w-full hidden md:w-auto md:table-cell py-2">
|
||||
<div class="font-semibold text-left">Jahr</div>
|
||||
</th>
|
||||
<th class="w-full hidden md:w-auto md:table-cell py-2">
|
||||
<div class="font-semibold text-left">Event-ID</div>
|
||||
</th>
|
||||
<th class="w-full hidden md:w-auto md:table-cell py-2">
|
||||
<div class="font-semibold text-left">Quittung</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- Table body -->
|
||||
<tbody class="text-sm">
|
||||
@foreach($payments as $payment)
|
||||
<tr class="flex flex-wrap md:table-row md:flex-no-wrap border-b border-gray-200 dark:border-gray-700/60 py-2 md:py-0">
|
||||
<td class="w-full block md:w-auto md:table-cell py-0.5 md:py-2">
|
||||
<div
|
||||
class="text-left font-medium text-gray-800 dark:text-gray-100">
|
||||
<span class="sm:hidden">Sats:</span>
|
||||
{{ $payment->amount }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-full block md:w-auto md:table-cell py-0.5 md:py-2">
|
||||
<div
|
||||
class="text-left"><span
|
||||
class="sm:hidden">Jahr:</span>{{ $payment->year }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-full block md:w-auto md:table-cell py-0.5 md:py-2">
|
||||
<div
|
||||
class="text-left font-medium break-all">{{ $payment->event_id }}</div>
|
||||
</td>
|
||||
<td class="w-full block md:w-auto md:table-cell py-0.5 md:py-2">
|
||||
@if($payment->btc_pay_invoice)
|
||||
<x-button target="_blank" xs
|
||||
label="Quittung"
|
||||
href="https://pay.einundzwanzig.space/i/{{ $payment->btc_pay_invoice }}/receipt"/>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,292 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Forms\VoteForm;
|
||||
use App\Models\Vote;
|
||||
use Livewire\Volt\Component;
|
||||
use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
use function Livewire\Volt\{state, mount, on, computed, form, with};
|
||||
|
||||
name('association.projectSupport.item');
|
||||
|
||||
form(VoteForm::class);
|
||||
|
||||
state([
|
||||
'projectProposal' => fn() => $projectProposal,
|
||||
'isAllowed' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
'ownVoteExists' => false,
|
||||
'boardVotes' => fn() => $this->getBoardVotes(),
|
||||
'otherVotes' => fn() => $this->getOtherVotes(),
|
||||
]);
|
||||
|
||||
mount(function () {
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$this->handleNostrLoggedIn($this->currentPubkey);
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => fn($pubkey) => $this->handleNostrLoggedIn($pubkey),
|
||||
'nostrLoggedOut' => fn() => $this->handleNostrLoggedOut(),
|
||||
]);
|
||||
|
||||
$approve = fn() => $this->handleApprove();
|
||||
$notApprove = fn() => $this->handleNotApprove();
|
||||
|
||||
$getBoardVotes = function () {
|
||||
return Vote::query()
|
||||
->where('project_proposal_id', $this->projectProposal->id)
|
||||
->whereHas('einundzwanzigPleb', fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board')))
|
||||
->get();
|
||||
};
|
||||
|
||||
$getOtherVotes = function () {
|
||||
return Vote::query()
|
||||
->where('project_proposal_id', $this->projectProposal->id)
|
||||
->whereDoesntHave(
|
||||
'einundzwanzigPleb',
|
||||
fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board'))
|
||||
)
|
||||
->get();
|
||||
};
|
||||
|
||||
$handleNostrLoggedIn = function ($pubkey) {
|
||||
$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();
|
||||
};
|
||||
|
||||
$handleNostrLoggedOut = function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
};
|
||||
|
||||
$handleApprove = function () {
|
||||
Vote::query()->updateOrCreate([
|
||||
'project_proposal_id' => $this->projectProposal->id,
|
||||
'einundzwanzig_pleb_id' => $this->currentPleb->id,
|
||||
], [
|
||||
'value' => true,
|
||||
]);
|
||||
$this->form->reset();
|
||||
$this->ownVoteExists = true;
|
||||
$this->boardVotes = $this->getBoardVotes();
|
||||
$this->otherVotes = $this->getOtherVotes();
|
||||
};
|
||||
|
||||
$handleNotApprove = function () {
|
||||
$this->form->validate();
|
||||
|
||||
Vote::query()->updateOrCreate([
|
||||
'project_proposal_id' => $this->projectProposal->id,
|
||||
'einundzwanzig_pleb_id' => $this->currentPleb->id,
|
||||
], [
|
||||
'value' => false,
|
||||
]);
|
||||
$this->form->reset();
|
||||
$this->ownVoteExists = true;
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app
|
||||
:seo="new SEOData(title: 'Unterstützung für: ' . $projectProposal->name, description: $projectProposal->accepted ? 'Wurde mit ' . number_format($projectProposal->sats_paid, 0, ',', '.') . ' Satoshis unterstützt!' :str($projectProposal->description)->limit(100, '...', true), image: $projectProposal->getFirstMediaUrl('main'))">
|
||||
@volt
|
||||
<div>
|
||||
@if($projectProposal->accepted || $isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full">
|
||||
|
||||
<!-- Page content -->
|
||||
<div class="max-w-5xl mx-auto flex flex-col lg:flex-row lg:space-x-8 xl:space-x-16">
|
||||
|
||||
<!-- Content -->
|
||||
<div>
|
||||
<div class="mb-6">
|
||||
<a class="btn-sm px-3 bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 text-gray-800 dark:text-gray-300"
|
||||
href="{{ route('association.projectSupport') }}"
|
||||
>
|
||||
<svg class="fill-current text-gray-400 dark:text-gray-500 mr-2" width="7" height="12"
|
||||
viewBox="0 0 7 12">
|
||||
<path d="M5.4.6 6.8 2l-4 4 4 4-1.4 1.4L0 6z"></path>
|
||||
</svg>
|
||||
<span>Zurück zur Übersicht</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="text-sm font-semibold text-violet-500 uppercase mb-2">
|
||||
{{ $projectProposal->created_at->translatedFormat('d.m.Y') }}
|
||||
</div>
|
||||
<header class="mb-4">
|
||||
<!-- Title -->
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold mb-2">
|
||||
{{ $projectProposal->name }}
|
||||
</h1>
|
||||
<x-markdown>
|
||||
{!! $projectProposal->description !!}
|
||||
</x-markdown>
|
||||
</header>
|
||||
|
||||
<div class="space-y-3 sm:flex sm:items-center sm:justify-between sm:space-y-0 mb-6">
|
||||
<!-- Author -->
|
||||
<div class="flex items-center sm:mr-4">
|
||||
<a class="block mr-2 shrink-0" href="#0">
|
||||
<img class="rounded-full"
|
||||
src="{{ $projectProposal->einundzwanzigPleb->profile?->picture ?? asset('einundzwanzig-alpha.jpg') }}"
|
||||
width="32" height="32" alt="User 04">
|
||||
</a>
|
||||
<div class="text-sm whitespace-nowrap">Eingereicht von
|
||||
<div
|
||||
class="font-semibold text-gray-800 dark:text-gray-100">{{ $projectProposal->einundzwanzigPleb?->profile->name ?? str($projectProposal->einundzwanzigPleb->npub)->limit(32) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right side -->
|
||||
<div class="flex flex-wrap items-center sm:justify-end space-x-2">
|
||||
<!-- Tags -->
|
||||
<div
|
||||
class="text-xs inline-flex items-center font-medium border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-400 rounded-full text-center px-2.5 py-1">
|
||||
<a target="_blank" href="{{ $projectProposal->website }}"><span>Webseite</span></a>
|
||||
</div>
|
||||
<div
|
||||
class="text-xs inline-flex font-medium uppercase bg-green-500/20 text-green-700 rounded-full text-center px-2.5 py-1">
|
||||
{{ number_format($projectProposal->support_in_sats, 0, ',', '.') }} Sats
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<figure class="mb-6">
|
||||
<img class="rounded-sm h-48" src="{{ $projectProposal->getFirstMediaUrl('main') }}"
|
||||
alt="Picture">
|
||||
</figure>
|
||||
|
||||
<hr class="my-6 border-t border-gray-100 dark:border-gray-700/60">
|
||||
|
||||
<!-- Reasons -->
|
||||
{{--<div>
|
||||
<h2 class="text-xl leading-snug text-gray-800 dark:text-gray-100 font-bold mb-2">
|
||||
Ablehnungen ({{ count($reasons) }})
|
||||
</h2>
|
||||
<ul class="space-y-5 my-6">
|
||||
@foreach($reasons as $reason)
|
||||
<li class="flex items-start">
|
||||
<a class="block mr-3 shrink-0" href="#0">
|
||||
<img class="rounded-full"
|
||||
src="{{ $reason->einundzwanzigPleb->profile->picture }}"
|
||||
width="32" height="32"
|
||||
alt="{{ $reason->einundzwanzigPleb->profile->name }}">
|
||||
</a>
|
||||
<div class="grow">
|
||||
<div class="text-sm font-semibold text-gray-800 dark:text-gray-100 mb-2">
|
||||
{{ $reason->einundzwanzigPleb->profile->name }}
|
||||
</div>
|
||||
<div class="italic">{{ $reason->reason }}</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>--}}
|
||||
|
||||
</div>
|
||||
|
||||
@if($isAllowed && !$projectProposal->accepted)
|
||||
<!-- Sidebar -->
|
||||
<div class="space-y-4">
|
||||
|
||||
<!-- 1st block -->
|
||||
<div class="bg-white dark:bg-gray-800 p-5 shadow-sm rounded-xl lg:w-72 xl:w-80">
|
||||
@if(!$ownVoteExists)
|
||||
<div class="space-y-2">
|
||||
<button
|
||||
wire:click="approve"
|
||||
class="btn w-full bg-gray-900 text-gray-100 hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-800 dark:hover:bg-white">
|
||||
<i class="fill-current shrink-0 fa-sharp-duotone fa-solid fa-thumbs-up"></i>
|
||||
<span class="ml-1">Zustimmen</span>
|
||||
</button>
|
||||
<button
|
||||
wire:click="notApprove"
|
||||
class="btn w-full bg-red-900 text-red-100 hover:bg-red-800 dark:bg-red-100 dark:text-red-800 dark:hover:bg-red-400">
|
||||
<i class="fill-current shrink-0 fa-sharp-duotone fa-solid fa-thumbs-down"></i>
|
||||
<span class="ml-1">Ablehnen</span>
|
||||
</button>
|
||||
{{--<x-textarea wire:model="form.reason" label="Grund für deine Ablehnung"/>--}}
|
||||
</div>
|
||||
@else
|
||||
<div class="space-y-2">
|
||||
<p>Du hast bereits abgestimmt.</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- 2nd block -->
|
||||
<div class="bg-white dark:bg-gray-800 p-5 shadow-sm rounded-xl lg:w-72 xl:w-80">
|
||||
<div class="flex justify-between space-x-1 mb-5">
|
||||
<div class="text-sm text-gray-800 dark:text-gray-100 font-semibold">
|
||||
Zustimmungen des Vorstands ({{ count($boardVotes->where('value', 1)) }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2nd block -->
|
||||
<div class="bg-white dark:bg-gray-800 p-5 shadow-sm rounded-xl lg:w-72 xl:w-80">
|
||||
<div class="flex justify-between space-x-1 mb-5">
|
||||
<div class="text-sm text-gray-800 dark:text-gray-100 font-semibold">
|
||||
Ablehnungen des Vorstands ({{ count($boardVotes->where('value', 0)) }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3rd block -->
|
||||
<div class="bg-white dark:bg-gray-800 p-5 shadow-sm rounded-xl lg:w-72 xl:w-80">
|
||||
<div class="flex justify-between space-x-1 mb-5">
|
||||
<div class="text-sm text-gray-800 dark:text-gray-100 font-semibold">
|
||||
Zustimmungen der übrigen Mitglieder ({{ count($otherVotes->where('value', 1)) }}
|
||||
)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3rd block -->
|
||||
<div class="bg-white dark:bg-gray-800 p-5 shadow-sm rounded-xl lg:w-72 xl:w-80">
|
||||
<div class="flex justify-between space-x-1 mb-5">
|
||||
<div class="text-sm text-gray-800 dark:text-gray-100 font-semibold">
|
||||
Ablehnungen der übrigen Mitglieder ({{ count($otherVotes->where('value', 0)) }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projekt-Unterstützung
|
||||
</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projekt-Unterstützungen einzusehen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,170 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Forms\ProjectProposalForm;
|
||||
use App\Models\ProjectProposal;
|
||||
use App\Support\NostrAuth;
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
use function Livewire\Volt\{state, mount, on, computed, form, usesFileUploads};
|
||||
|
||||
name('association.projectSupport.edit');
|
||||
|
||||
form(ProjectProposalForm::class);
|
||||
|
||||
state([
|
||||
'projectProposal' => fn() => $projectProposal,
|
||||
'image',
|
||||
'isAllowed' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
]);
|
||||
|
||||
usesFileUploads();
|
||||
|
||||
mount(function (ProjectProposal $projectProposal) {
|
||||
if (NostrAuth::check()) {
|
||||
$this->currentPubkey = NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
$this->form->fill($projectProposal->toArray());
|
||||
$this->image = $projectProposal->getFirstMedia('main');
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
},
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
$save = function () {
|
||||
$this->form->validate();
|
||||
if ($this->image && method_exists($this->image, 'temporaryUrl')) {
|
||||
$this->validate([
|
||||
'image' => 'nullable|image|max:1024',
|
||||
]);
|
||||
$this->projectProposal
|
||||
->addMedia($this->image->getRealPath())
|
||||
->toMediaCollection('main');
|
||||
}
|
||||
|
||||
$this->projectProposal->update([
|
||||
...$this->form->except('id', 'slug'),
|
||||
]);
|
||||
|
||||
return redirect()->route('association.projectSupport');
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="{{ $projectProposal->name }}">
|
||||
@volt
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<form class="space-y-8 divide-y divide-gray-700 pb-24">
|
||||
<div class="space-y-8 divide-y divide-gray-700 sm:space-y-5">
|
||||
<div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5">
|
||||
|
||||
<x-input.group :for=" md5('image')" :label="__('Bild')">
|
||||
<div class="py-4">
|
||||
@if ($image && method_exists($image, 'temporaryUrl') && str($image->getMimeType())->contains(['image/jpeg','image/jpg', 'image/png', 'image/gif', 'image/svg+xml', 'image/webp']))
|
||||
<div class="text-gray-200">{{ __('Preview') }}:</div>
|
||||
<img class="h-48 object-contain" src="{{ $image->temporaryUrl() }}">
|
||||
@endif
|
||||
@if (isset($projectProposal) && $projectProposal->getFirstMediaUrl('main'))
|
||||
<div class="text-gray-200">{{ __('Current picture') }}:</div>
|
||||
<img class="h-48 object-contain"
|
||||
src="{{ $projectProposal->getFirstMediaUrl('main') }}">
|
||||
@endif
|
||||
</div>
|
||||
<input class="text-gray-200" type="file" wire:model="image">
|
||||
@error('image') <span class="text-red-500">{{ $message }}</span> @enderror
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.name')" :label="__('Name')">
|
||||
<x-input autocomplete="off" wire:model.debounce="form.name"
|
||||
:placeholder="__('Name')"/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.website')" :label="__('Webseite des Projekts')">
|
||||
<x-input autocomplete="off" wire:model.debounce="form.website"
|
||||
:placeholder="__('Website')"
|
||||
description="Eine valide URL beginnt immer mit https://"
|
||||
/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.name')" :label="__('Beabsichtigte Unterstützung in Sats')">
|
||||
<x-input type="number" autocomplete="off" wire:model.debounce="form.support_in_sats"
|
||||
:placeholder="__('Beabsichtigte Unterstützung in Sats')"/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.accepted')" :label="__('Wurde angenommen')">
|
||||
<x-checkbox autocomplete="off" wire:model.debounce="form.accepted"/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.sats_paid')" :label="__('Letztendlich bezahlte Satoshis')">
|
||||
<x-input autocomplete="off" wire:model.debounce="form.sats_paid"
|
||||
:placeholder="__('Satoshi-Anzahl')"/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.description')">
|
||||
<x-slot name="label">
|
||||
<div>
|
||||
{{ __('Beschreibung') }}
|
||||
</div>
|
||||
<div
|
||||
class="text-amber-500 text-xs py-2">{{ __('Bitte verfasse einen ausführlichen und verständlichen Antragstext, damit die Abstimmung über eine mögliche Förderung erfolgen kann.') }}</div>
|
||||
</x-slot>
|
||||
<div
|
||||
class="text-amber-500 text-xs py-2">{{ __('Für Bilder in Markdown verwende bitte z.B. Imgur oder einen anderen Anbieter.') }}</div>
|
||||
<x-input.simple-mde model="form.description"/>
|
||||
@error('form.description') <span
|
||||
class="text-red-500 py-2">{{ $message }}</span> @enderror
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('save')" label="">
|
||||
<x-button secondary :href="route('association.projectSupport')">
|
||||
<i class="fa fa-thin fa-arrow-left"></i>
|
||||
{{ __('Zurück') }}
|
||||
</x-button>
|
||||
<x-button primary wire:click="save">
|
||||
<i class="fa fa-thin fa-save"></i>
|
||||
{{ __('Speichern') }}
|
||||
</x-button>
|
||||
</x-input.group>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projekt-Unterstützung</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projekt-Unterstützungen zu bearbeiten.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,157 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Forms\ProjectProposalForm;
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
use function Livewire\Volt\{state, mount, on, computed, form, usesFileUploads};
|
||||
|
||||
name('association.projectSupport.create');
|
||||
|
||||
form(ProjectProposalForm::class);
|
||||
|
||||
state([
|
||||
'image',
|
||||
'isAllowed' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
]);
|
||||
|
||||
usesFileUploads();
|
||||
|
||||
mount(function () {
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
},
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
$save = function () {
|
||||
$this->form->validate();
|
||||
|
||||
$projectProposal = \App\Models\ProjectProposal::query()->create([
|
||||
...$this->form->all(),
|
||||
'einundzwanzig_pleb_id' => $this->currentPleb->id,
|
||||
]);
|
||||
if ($this->image) {
|
||||
$this->validate([
|
||||
'image' => 'image|max:1024',
|
||||
]);
|
||||
$projectProposal
|
||||
->addMedia($this->image->getRealPath())
|
||||
->toMediaCollection('main');
|
||||
}
|
||||
|
||||
return redirect()->route('association.projectSupport');
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="Neuer Vorschlag für eine Unterstützung">
|
||||
@volt
|
||||
<div>
|
||||
@if($isAllowed)
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<form class="space-y-8 divide-y divide-gray-700 pb-24">
|
||||
<div class="space-y-8 divide-y divide-gray-700 sm:space-y-5">
|
||||
<div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5">
|
||||
|
||||
<x-input.group :for=" md5('image')" :label="__('Bild')">
|
||||
<div class="py-4">
|
||||
@if ($image && method_exists($image, 'temporaryUrl') && str($image->getMimeType())->contains(['image/jpeg','image/jpg', 'image/png', 'image/gif', 'image/svg+xml', 'image/webp']))
|
||||
<div class="text-gray-200">{{ __('Preview') }}:</div>
|
||||
<img class="h-48 object-contain" src="{{ $image->temporaryUrl() }}">
|
||||
@endif
|
||||
@if (isset($projectProposal) && $projectProposal->getFirstMediaUrl('main'))
|
||||
<div class="text-gray-200">{{ __('Current picture') }}:</div>
|
||||
<img class="h-48 object-contain"
|
||||
src="{{ $projectProposal->getFirstMediaUrl('main') }}">
|
||||
@endif
|
||||
</div>
|
||||
<input class="text-gray-200" type="file" wire:model="image">
|
||||
@error('image') <span class="text-red-500">{{ $message }}</span> @enderror
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.name')" :label="__('Name')">
|
||||
<x-input autocomplete="off" wire:model.debounce="form.name"
|
||||
:placeholder="__('Name')"/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.website')" :label="__('Webseite des Projekts')">
|
||||
<x-input autocomplete="off" wire:model.debounce="form.website"
|
||||
:placeholder="__('Website')"
|
||||
description="Eine valide URL beginnt immer mit https://"
|
||||
/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.name')" :label="__('Beabsichtigte Unterstützung in Sats')">
|
||||
<x-input type="number" autocomplete="off" wire:model.debounce="form.support_in_sats"
|
||||
:placeholder="__('Beabsichtigte Unterstützung in Sats')"/>
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('form.description')">
|
||||
<x-slot name="label">
|
||||
<div>
|
||||
{{ __('Beschreibung') }}
|
||||
</div>
|
||||
<div
|
||||
class="text-amber-500 text-xs py-2">{{ __('Bitte verfasse einen ausführlichen und verständlichen Antragstext, damit die Abstimmung über eine mögliche Förderung erfolgen kann.') }}</div>
|
||||
</x-slot>
|
||||
<div
|
||||
class="text-amber-500 text-xs py-2">{{ __('Für Bilder in Markdown verwende bitte z.B. Imgur oder einen anderen Anbieter.') }}</div>
|
||||
<x-input.simple-mde model="form.description"/>
|
||||
@error('form.description') <span
|
||||
class="text-red-500 py-2">{{ $message }}</span> @enderror
|
||||
</x-input.group>
|
||||
|
||||
<x-input.group :for="md5('save')" label="">
|
||||
<x-button secondary :href="route('association.projectSupport')">
|
||||
<i class="fa fa-thin fa-arrow-left"></i>
|
||||
{{ __('Zurück') }}
|
||||
</x-button>
|
||||
<x-button primary wire:click="save">
|
||||
<i class="fa fa-thin fa-save"></i>
|
||||
{{ __('Save') }}
|
||||
</x-button>
|
||||
</x-input.group>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@else
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="bg-white dark:bg-[#1B1B1B] shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">
|
||||
Projekt-Unterstützung</h3>
|
||||
<p class="mt-1 max-w">
|
||||
Du bist nicht berechtigt, die Projekt-Unterstützungen zu bearbeiten.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,187 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
use WireUi\Actions\Notification;
|
||||
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
use function Livewire\Volt\{state, mount, on, computed, updated};
|
||||
|
||||
name('association.projectSupport');
|
||||
|
||||
state(['activeFilter' => 'all',])->url();
|
||||
|
||||
state([
|
||||
'search' => '',
|
||||
'projects' => fn()
|
||||
=> \App\Models\ProjectProposal::query()
|
||||
->with([
|
||||
'einundzwanzigPleb.profile',
|
||||
'votes',
|
||||
])
|
||||
->orderBy('created_at', 'desc')
|
||||
->get(),
|
||||
'isAllowed' => false,
|
||||
'currentPubkey' => null,
|
||||
'currentPleb' => null,
|
||||
]);
|
||||
|
||||
updated([
|
||||
'search' => function () {
|
||||
$this->projects = \App\Models\ProjectProposal::query()
|
||||
->with([
|
||||
'einundzwanzigPleb.profile',
|
||||
'votes',
|
||||
])
|
||||
->where(function ($query) {
|
||||
$query
|
||||
->where('name', 'ilike', '%'.$this->search.'%')
|
||||
->orWhere('description', 'ilike', '%'.$this->search.'%')
|
||||
->orWhereHas('einundzwanzigPleb.profile', function ($q) {
|
||||
$q->where('name', 'ilike', '%'.$this->search.'%');
|
||||
});
|
||||
})
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
},
|
||||
]);
|
||||
|
||||
$projects = computed(function () {
|
||||
return $this->projects;
|
||||
});
|
||||
|
||||
mount(function () {
|
||||
if (\App\Support\NostrAuth::check()) {
|
||||
$this->currentPubkey = \App\Support\NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
});
|
||||
|
||||
on([
|
||||
'nostrLoggedIn' => function ($pubkey) {
|
||||
\App\Support\NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
},
|
||||
'nostrLoggedOut' => function () {
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
},
|
||||
]);
|
||||
|
||||
$confirmDelete = function ($id) {
|
||||
$notification = new Notification($this);
|
||||
$notification->confirm([
|
||||
'title' => 'Projektunterstützung löschen',
|
||||
'message' => 'Bist du sicher, dass du diese Projektunterstützung löschen möchtest?',
|
||||
'accept' => [
|
||||
'label' => 'Ja, löschen',
|
||||
'method' => 'delete',
|
||||
'params' => $id,
|
||||
],
|
||||
]);
|
||||
};
|
||||
|
||||
$setFilter = function ($filter) {
|
||||
$this->activeFilter = $filter;
|
||||
};
|
||||
|
||||
$delete = function ($id) {
|
||||
\App\Models\ProjectProposal::query()->findOrFail($id)->delete();
|
||||
$this->projects = \App\Models\ProjectProposal::query()
|
||||
->with([
|
||||
'einundzwanzigPleb.profile',
|
||||
'votes',
|
||||
])
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app
|
||||
:seo="new \RalphJSmit\Laravel\SEO\Support\SEOData(title: 'Projekt Unterstützungen', description: 'Einundzwanzig Projektunterstützungen')"
|
||||
>
|
||||
@volt
|
||||
<div>
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
|
||||
<!-- Page header -->
|
||||
<div class="sm:flex sm:justify-between sm:items-center mb-5">
|
||||
|
||||
<!-- Left: Title -->
|
||||
<div class="mb-4 sm:mb-0">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">
|
||||
Einundzwanzig Projektunterstützungen
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<!-- Right: Actions -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 justify-start sm:justify-end gap-2">
|
||||
|
||||
<!-- Search form -->
|
||||
<form class="relative">
|
||||
<x-input type="search" wire:model.live.debounce="search"
|
||||
placeholder="Suche…"/>
|
||||
</form>
|
||||
|
||||
<!-- Add meetup button -->
|
||||
@if($currentPleb && $currentPleb->association_status->value > 1 && $currentPleb->paymentEvents()->where('year', date('Y'))->where('paid', true)->exists())
|
||||
<x-button :href="route('association.projectSupport.create')" icon="plus"
|
||||
label="Projekt einreichen"/>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="mb-5">
|
||||
<ul class="flex flex-wrap -m-1">
|
||||
<li class="m-1">
|
||||
<button wire:click="setFilter('all')"
|
||||
class="inline-flex items-center justify-center text-sm font-medium leading-5 rounded-full px-3 py-1 border {{ $activeFilter === 'all' ? 'border-transparent shadow-sm bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-800' : 'border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 shadow-sm bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400' }} transition">
|
||||
Alle
|
||||
</button>
|
||||
</li>
|
||||
<li class="m-1">
|
||||
<button wire:click="setFilter('new')"
|
||||
class="inline-flex items-center justify-center text-sm font-medium leading-5 rounded-full px-3 py-1 border {{ $activeFilter === 'new' ? 'border-transparent shadow-sm bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-800' : 'border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 shadow-sm bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400' }} transition">
|
||||
Neu
|
||||
</button>
|
||||
</li>
|
||||
<li class="m-1">
|
||||
<button wire:click="setFilter('supported')"
|
||||
class="inline-flex items-center justify-center text-sm font-medium leading-5 rounded-full px-3 py-1 border {{ $activeFilter === 'supported' ? 'border-transparent shadow-sm bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-800' : 'border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 shadow-sm bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400' }} transition">
|
||||
Unterstützt
|
||||
</button>
|
||||
</li>
|
||||
<li class="m-1">
|
||||
<button wire:click="setFilter('rejected')"
|
||||
class="inline-flex items-center justify-center text-sm font-medium leading-5 rounded-full px-3 py-1 border {{ $activeFilter === 'rejected' ? 'border-transparent shadow-sm bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-800' : 'border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 shadow-sm bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400' }} transition">
|
||||
Abgelehnt
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400 italic mb-4">{{ $this->projects->count() }}Projekte
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="grid xl:grid-cols-2 gap-6 mb-8">
|
||||
@foreach($this->projects as $project)
|
||||
<x-project-card :project="$project" :currentPleb="$currentPleb" :section="$activeFilter"/>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('changelog');
|
||||
|
||||
state(['entries' => []]);
|
||||
|
||||
mount(function () {
|
||||
$output = shell_exec('git log -n1000 --pretty=format:"%H|%s|%an|%ad" --date=format:"%Y-%m-%d %H:%M:%S"');
|
||||
$lines = explode("\n", trim($output));
|
||||
$entries = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
[$hash, $message, $author, $date] = explode('|', $line);
|
||||
$entries[] = [
|
||||
'hash' => $hash,
|
||||
'message' => $message,
|
||||
'author' => $author,
|
||||
'date' => $date,
|
||||
];
|
||||
}
|
||||
$this->entries = $entries;
|
||||
});
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="{{ __('Changelog') }}">
|
||||
@volt
|
||||
<div>
|
||||
<div
|
||||
class="sm:flex sm:justify-between sm:items-center px-4 sm:px-6 py-8 border-b border-gray-200 dark:border-gray-700/60">
|
||||
|
||||
<!-- Left: Title -->
|
||||
<div class="mb-4 sm:mb-0">
|
||||
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">Changelog</h1>
|
||||
</div>
|
||||
|
||||
<!-- Right: Actions -->
|
||||
<div class="grid grid-flow-col sm:auto-cols-max justify-start sm:justify-end gap-2">
|
||||
|
||||
{{--<!-- Add entry button -->
|
||||
<button
|
||||
class="btn bg-gray-900 text-gray-100 hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-800 dark:hover:bg-white">
|
||||
Add Entry
|
||||
</button>--}}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
|
||||
<div class="max-w-3xl m-auto">
|
||||
|
||||
<!-- Posts -->
|
||||
<div class="xl:-translate-x-16">
|
||||
@foreach($entries as $entry)
|
||||
<article class="pt-6">
|
||||
<div class="xl:flex">
|
||||
<div class="w-32 shrink-0">
|
||||
<div
|
||||
class="text-xs font-semibold uppercase text-gray-400 dark:text-gray-500 xl:leading-8">
|
||||
{{ $entry['date'] }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="grow pb-6 border-b border-gray-200 dark:border-gray-700/60">
|
||||
<header>
|
||||
<div class="flex flex-nowrap items-center space-x-2 mb-4">
|
||||
<div class="flex items-center">
|
||||
<a class="block text-sm font-semibold text-gray-800 dark:text-gray-100"
|
||||
href="#0">
|
||||
{{ $entry['author'] }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="text-gray-400 dark:text-gray-600">·</div>
|
||||
<div>
|
||||
<div
|
||||
class="text-xs inline-flex font-medium bg-green-500/20 text-green-700 rounded-full text-center px-2.5 py-1">
|
||||
{{ $entry['hash'] }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="space-y-3 font-mono">
|
||||
{!! $entry['message'] !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('einundzwanzig-feed');
|
||||
|
||||
state(
|
||||
['events' => []],
|
||||
);
|
||||
|
||||
state(
|
||||
['newEvents' => false],
|
||||
);
|
||||
|
||||
mount(function () {
|
||||
$this->events = \App\Models\Event::query()
|
||||
->where('type', 'root')
|
||||
->orderBy('created_at', 'desc')
|
||||
->with([
|
||||
'renderedEvent',
|
||||
])
|
||||
->get()
|
||||
->toArray();
|
||||
});
|
||||
|
||||
on(['echo:events,.newEvents' => function () {
|
||||
$this->newEvents = true;
|
||||
}]);
|
||||
|
||||
$loadMore = function () {
|
||||
// Load more events
|
||||
$this->newEvents = false;
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="Einundzwanzig Feed">
|
||||
@volt
|
||||
<div class="px-8 py-8 space-y-6">
|
||||
<div>
|
||||
@if($newEvents)
|
||||
<div class="rounded-md bg-blue-50 p-4">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-blue-400" viewBox="0 0 20 20" fill="currentColor"
|
||||
aria-hidden="true">
|
||||
<path fill-rule="evenodd"
|
||||
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z"
|
||||
clip-rule="evenodd"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3 flex-1 md:flex md:justify-between">
|
||||
<p class="text-sm text-blue-700">Es gibt neue Events...</p>
|
||||
<div class="mt-3 text-sm md:ml-6 md:mt-0">
|
||||
<div wire:click="loadMore"
|
||||
class="cursor-pointer whitespace-nowrap font-medium text-blue-700 hover:text-blue-600">
|
||||
Anzeigen
|
||||
<span aria-hidden="true"> →</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@foreach($events as $event)
|
||||
<article class="flex flex-col items-start justify-between"
|
||||
wire:key="{{ $event['rendered_event']['event_id'] }}">
|
||||
<div class="relative flex items-center gap-x-4">
|
||||
<img
|
||||
src="{{ $event['rendered_event']['profile_image'] }}"
|
||||
alt="" class="h-10 w-10 rounded-full bg-gray-50">
|
||||
<div class="text-sm leading-6">
|
||||
<div class="font-semibold text-gray-900">
|
||||
<div>
|
||||
<span class="absolute inset-0"></span>
|
||||
{{ $event['rendered_event']['profile_name'] }}
|
||||
</div>
|
||||
</div>
|
||||
{{--<div class="text-gray-600">{{ $event['event_id'] }}</div>--}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-x-4 text-xs">
|
||||
<time datetime="{{ $event['rendered_event']['created_at'] }}"
|
||||
class="text-gray-500">{{ $event['rendered_event']['created_at'] }}</time>
|
||||
</div>
|
||||
<div class="group relative">
|
||||
<div class="mt-5 line-clamp-3 text-sm leading-6 text-gray-600">
|
||||
{!! $event['rendered_event']['html'] !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="group relative">
|
||||
<div class="mt-5 line-clamp-3 text-sm leading-6 text-gray-600">
|
||||
<pre>{{ json_encode(json_decode($event['json'], true, 512, JSON_THROW_ON_ERROR)['tags']) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@endforeach
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Laravel\Folio\{middleware, name};
|
||||
use function Livewire\Volt\{state, mount, on, computed};
|
||||
|
||||
name('welcome');
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="Welcome">
|
||||
@volt
|
||||
<div>
|
||||
TEST
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,251 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
with,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('meetups.grid');
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<x-layouts.app title="{{ __('Meetups') }}">
|
||||
@volt
|
||||
<div class="relative flex">
|
||||
|
||||
<!-- Profile sidebar -->
|
||||
<div
|
||||
id="profile-sidebar"
|
||||
class="absolute z-20 top-0 bottom-0 w-full md:w-auto md:static md:top-auto md:bottom-auto -mr-px md:translate-x-0 transition-transform duration-200 ease-in-out"
|
||||
:class="profileSidebarOpen ? 'translate-x-0' : '-translate-x-full'"
|
||||
>
|
||||
<div
|
||||
class="sticky top-16 bg-white dark:bg-[#1B1B1B] overflow-x-hidden overflow-y-auto no-scrollbar shrink-0 border-r border-gray-200 dark:border-gray-700/60 md:w-[18rem] xl:w-[20rem] h-[calc(100dvh-64px)]">
|
||||
|
||||
<!-- Profile group -->
|
||||
<div>
|
||||
<!-- Group header -->
|
||||
<div class="sticky top-0 z-10">
|
||||
<div
|
||||
class="flex items-center bg-white dark:bg-[#1B1B1B] border-b border-gray-200 dark:border-gray-700/60 px-5 h-16">
|
||||
<div class="w-full flex items-center justify-between">
|
||||
<!-- Profile image -->
|
||||
<div class="relative">
|
||||
<div class="grow flex items-center truncate">
|
||||
<div class="truncate">
|
||||
<span
|
||||
class="font-semibold text-gray-800 dark:text-gray-100">All meetups</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Add button -->
|
||||
<button
|
||||
class="p-1.5 shrink-0 rounded-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 shadow-sm ml-2">
|
||||
<svg class="fill-current text-violet-500" width="16" height="16"
|
||||
viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M15 7H9V1c0-.6-.4-1-1-1S7 .4 7 1v6H1c-.6 0-1 .4-1 1s.4 1 1 1h6v6c0 .6.4 1 1 1s1-.4 1-1V9h6c.6 0 1-.4 1-1s-.4-1-1-1Z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Group body -->
|
||||
<div class="px-5 py-4">
|
||||
<!-- Search form -->
|
||||
<div class="relative">
|
||||
<label for="profile-search" class="sr-only">Search</label>
|
||||
<input id="profile-search" class="form-input w-full pl-9 bg-white dark:bg-gray-800 rounded"
|
||||
type="search" placeholder="Search…"/>
|
||||
<button class="absolute inset-0 right-auto group cursor-default" aria-label="Search">
|
||||
<svg
|
||||
class="shrink-0 fill-current text-gray-400 dark:text-gray-500 group-hover:text-gray-500 dark:group-hover:text-gray-400 ml-3 mr-2"
|
||||
width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M7 14c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7zM7 2C4.243 2 2 4.243 2 7s2.243 5 5 5 5-2.243 5-5-2.243-5-5-5z"/>
|
||||
<path
|
||||
d="M15.707 14.293L13.314 11.9a8.019 8.019 0 01-1.414 1.414l2.393 2.393a.997.997 0 001.414 0 .999.999 0 000-1.414z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Team members -->
|
||||
<div class="mt-4">
|
||||
<div class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-3">
|
||||
Countries
|
||||
</div>
|
||||
<ul class="mb-6">
|
||||
<li class="-mx-2">
|
||||
<button
|
||||
class="w-full p-2 rounded-lg bg-[linear-gradient(135deg,var(--tw-gradient-stops))] from-violet-500/[0.12] dark:from-violet-500/[0.24] to-violet-500/[0.04]"
|
||||
@click="profileSidebarOpen = false">
|
||||
<div class="flex items-center">
|
||||
<div class="relative mr-2">
|
||||
<img class="w-8 h-8 rounded-full"
|
||||
src="{{ asset('vendor/blade-country-flags/1x1-de.svg') }}"
|
||||
width="32" height="32" alt="User 08"/>
|
||||
</div>
|
||||
<div class="truncate">
|
||||
<span class="text-sm font-medium text-gray-800 dark:text-gray-100">Deutschland</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
<li class="-mx-2">
|
||||
<button
|
||||
class="w-full p-2"
|
||||
@click="profileSidebarOpen = false">
|
||||
<div class="flex items-center">
|
||||
<div class="relative mr-2">
|
||||
<img class="w-8 h-8 rounded-full"
|
||||
src="{{ asset('vendor/blade-country-flags/1x1-at.svg') }}"
|
||||
width="32" height="32" alt="User 08"/>
|
||||
</div>
|
||||
<div class="truncate">
|
||||
<span class="text-sm font-medium text-gray-800 dark:text-gray-100">Österreich</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
<li class="-mx-2">
|
||||
<button
|
||||
class="w-full p-2"
|
||||
@click="profileSidebarOpen = false">
|
||||
<div class="flex items-center">
|
||||
<div class="relative mr-2">
|
||||
<img class="w-8 h-8 rounded-full"
|
||||
src="{{ asset('vendor/blade-country-flags/1x1-ch.svg') }}"
|
||||
width="32" height="32" alt="User 08"/>
|
||||
</div>
|
||||
<div class="truncate">
|
||||
<span class="text-sm font-medium text-gray-800 dark:text-gray-100">Schweiz</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Profile body -->
|
||||
<div
|
||||
class="grow flex flex-col md:translate-x-0 transition-transform duration-300 ease-in-out"
|
||||
:class="profileSidebarOpen ? 'translate-x-1/3' : 'translate-x-0'"
|
||||
>
|
||||
|
||||
<!-- Profile background -->
|
||||
<div class="relative h-56 bg-gray-200 dark:bg-gray-900">
|
||||
<img class="object-cover object-top h-full w-full" src="{{ asset('img/meetup_saarland.jpg') }}"
|
||||
width="979" height="220"
|
||||
alt="Profile background"/>
|
||||
<!-- Close button -->
|
||||
<button
|
||||
class="md:hidden absolute top-4 left-4 sm:left-6 text-white opacity-80 hover:opacity-100"
|
||||
@click.stop="profileSidebarOpen = !profileSidebarOpen"
|
||||
aria-controls="profile-sidebar"
|
||||
:aria-expanded="profileSidebarOpen"
|
||||
>
|
||||
<span class="sr-only">Close sidebar</span>
|
||||
<svg class="w-6 h-6 fill-current" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10.7 18.7l1.4-1.4L7.8 13H20v-2H7.8l4.3-4.3-1.4-1.4L4 12z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="relative px-4 sm:px-6 pb-8">
|
||||
|
||||
<!-- Pre-header -->
|
||||
<div class="-mt-16 mb-6 sm:mb-3">
|
||||
|
||||
<div class="flex flex-col items-center sm:flex-row sm:justify-between sm:items-end">
|
||||
|
||||
<!-- Avatar -->
|
||||
<div class="inline-flex -ml-1 -mt-1 mb-4 sm:mb-0" style="height: 128px">
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="flex space-x-2 sm:mb-2">
|
||||
{{-- ACTIONS --}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid xl:grid-cols-2 gap-6 mb-8">
|
||||
|
||||
<!-- Item 1 -->
|
||||
<article class="flex bg-white dark:bg-[#1B1B1B] shadow-sm rounded-xl overflow-hidden">
|
||||
<!-- Image -->
|
||||
<a class="relative block w-24 sm:w-56 xl:sidebar-expanded:w-40 2xl:sidebar-expanded:w-56 shrink-0" href="meetups-post.html">
|
||||
<img class="absolute object-cover object-center w-full h-full" src="./images/meetups-thumb-01.jpg" width="220" height="236" alt="Meetup 01" />
|
||||
<!-- Like button -->
|
||||
<button class="absolute top-0 right-0 mt-4 mr-4">
|
||||
<div class="text-gray-100 bg-gray-900 bg-opacity-60 rounded-full">
|
||||
<span class="sr-only">Like</span>
|
||||
<svg class="h-8 w-8 fill-current" viewBox="0 0 32 32">
|
||||
<path d="M22.682 11.318A4.485 4.485 0 0019.5 10a4.377 4.377 0 00-3.5 1.707A4.383 4.383 0 0012.5 10a4.5 4.5 0 00-3.182 7.682L16 24l6.682-6.318a4.5 4.5 0 000-6.364zm-1.4 4.933L16 21.247l-5.285-5A2.5 2.5 0 0112.5 12c1.437 0 2.312.681 3.5 2.625C17.187 12.681 18.062 12 19.5 12a2.5 2.5 0 011.785 4.251h-.003z" />
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</a>
|
||||
<!-- Content -->
|
||||
<div class="grow p-5 flex flex-col">
|
||||
<div class="grow">
|
||||
<div class="text-sm font-semibold text-violet-500 uppercase mb-2">Mon 27 Dec, 2024</div>
|
||||
<a class="inline-flex mb-2" href="meetups-post.html">
|
||||
<h3 class="text-lg font-bold text-gray-800 dark:text-gray-100">Silicon Valley Bootstrapper Breakfast Online for 2024</h3>
|
||||
</a>
|
||||
<div class="text-sm">Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts.</div>
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<div class="flex justify-between items-center mt-3">
|
||||
<!-- Tag -->
|
||||
<div class="text-xs inline-flex items-center font-medium border border-gray-200 dark:border-gray-700/60 text-gray-600 dark:text-gray-400 rounded-full text-center px-2.5 py-1">
|
||||
<svg class="w-4 h-3 fill-gray-400 dark:fill-gray-500 mr-2" viewBox="0 0 16 12">
|
||||
<path d="m16 2-4 2.4V2a2 2 0 0 0-2-2H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7.6l4 2.4V2ZM2 10V2h8v8H2Z" />
|
||||
</svg>
|
||||
<span>Online Event</span>
|
||||
</div>
|
||||
<!-- Avatars -->
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="flex -space-x-3 -ml-0.5">
|
||||
<img class="rounded-full border-2 border-white dark:border-gray-800 box-content" src="./images/avatar-01.jpg" width="28" height="28" alt="User 01" />
|
||||
<img class="rounded-full border-2 border-white dark:border-gray-800 box-content" src="./images/avatar-04.jpg" width="28" height="28" alt="User 04" />
|
||||
<img class="rounded-full border-2 border-white dark:border-gray-800 box-content" src="./images/avatar-05.jpg" width="28" height="28" alt="User 05" />
|
||||
</div>
|
||||
<div class="text-xs font-medium text-gray-400 dark:text-gray-500 italic">+22</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\EventMessage;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Relay\RelaySet;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
use swentel\nostr\Event\Event as NostrEvent;
|
||||
use swentel\nostr\Sign\Sign;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
with,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('meetups.mockup');
|
||||
|
||||
state(['events' => []]);
|
||||
state(['title' => '']);
|
||||
state(['description' => '']);
|
||||
state(['signThisEvent' => '']);
|
||||
|
||||
mount(function () {
|
||||
$this->loadEvents();
|
||||
});
|
||||
|
||||
$loadEvents = function() {
|
||||
$subscription = new Subscription();
|
||||
$subscriptionId = $subscription->setId();
|
||||
|
||||
$filter1 = new Filter();
|
||||
$filter1->setKinds([31924]); // You can add multiple kind numbers
|
||||
$filter1->setLimit(25); // Limit to fetch only a maximum of 25 events
|
||||
$filters = [$filter1]; // You can add multiple filters.
|
||||
|
||||
$requestMessage = new RequestMessage($subscriptionId, $filters);
|
||||
|
||||
$relays = [
|
||||
new Relay('ws://nostream:8008'),
|
||||
];
|
||||
$relaySet = new RelaySet();
|
||||
$relaySet->setRelays($relays);
|
||||
|
||||
$request = new Request($relaySet, $requestMessage);
|
||||
$response = $request->send();
|
||||
|
||||
$this->events = collect($response['ws://nostream:8008'])
|
||||
->map(function($event) {
|
||||
if(!isset($event->event)) {
|
||||
return false;
|
||||
}
|
||||
return [
|
||||
'id' => $event->event->id,
|
||||
'kind' => $event->event->kind,
|
||||
'content' => $event->event->content,
|
||||
'pubkey' => $event->event->pubkey,
|
||||
'tags' => $event->event->tags,
|
||||
'created_at' => $event->event->created_at,
|
||||
];
|
||||
})
|
||||
->filter()
|
||||
->toArray();
|
||||
};
|
||||
|
||||
$save = function () {
|
||||
$note = new NostrEvent();
|
||||
$note->setContent($this->description);
|
||||
$note->setKind(31924);
|
||||
$note->setTags([
|
||||
['d', str()->uuid()->toString()],
|
||||
['title', $this->title],
|
||||
]);
|
||||
$this->signThisEvent = $note->toJson();
|
||||
};
|
||||
|
||||
$signEvent = function ($event) {
|
||||
$note = new NostrEvent();
|
||||
$note->setId($event['id']);
|
||||
$note->setSignature($event['sig']);
|
||||
$note->setKind($event['kind']);
|
||||
$note->setContent($event['content']);
|
||||
$note->setPublicKey($event['pubkey']);
|
||||
$note->setTags($event['tags']);
|
||||
$note->setCreatedAt($event['created_at']);
|
||||
$eventMessage = new EventMessage($note);
|
||||
$relayUrl = 'ws://nostream:8008';
|
||||
$relay = new Relay($relayUrl);
|
||||
$relay->setMessage($eventMessage);
|
||||
$result = $relay->send();
|
||||
|
||||
$this->title = '';
|
||||
$this->description = '';
|
||||
$this->loadEvents();
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
<x-layouts.app title="{{ __('Mockup') }}">
|
||||
@volt
|
||||
<div class="relative" x-data="nostrApp(@this)">
|
||||
<div class="flex items-center space-x-2 mt-12">
|
||||
<div>
|
||||
<x-input wire:model.live.debounce="title" label="Title"/>
|
||||
</div>
|
||||
<div>
|
||||
<x-textarea wire:model.live.debounce="description" label="Description"/>
|
||||
</div>
|
||||
<div>
|
||||
<x-button wire:click="save" label="Save"/>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="text-2x font-bold py-6">Meetups</h1>
|
||||
<ul class="border-t border-white space-y-4 divide-y divide-white">
|
||||
@foreach($events as $event)
|
||||
<li>
|
||||
<div class="flex items">
|
||||
<div class="flex items-center space-x-2">
|
||||
<div>
|
||||
Name: {{ collect($event['tags'])->firstWhere(0, 'title')[1] }}
|
||||
</div>
|
||||
<div>
|
||||
Beschreibung: {{ $event['content'] }}
|
||||
</div>
|
||||
<div>
|
||||
@dump($event)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
with,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('meetups.table');
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<x-layouts.app title="{{ __('Meetups') }}">
|
||||
@volt
|
||||
<div>
|
||||
<livewire:meetup-table />
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Livewire\Volt\Component;
|
||||
use swentel\nostr\Filter\Filter;
|
||||
use swentel\nostr\Key\Key;
|
||||
use swentel\nostr\Message\RequestMessage;
|
||||
use swentel\nostr\Relay\Relay;
|
||||
use swentel\nostr\Request\Request;
|
||||
use swentel\nostr\Subscription\Subscription;
|
||||
|
||||
use function Livewire\Volt\{
|
||||
computed,
|
||||
mount,
|
||||
state,
|
||||
with,
|
||||
on
|
||||
};
|
||||
use function Laravel\Folio\{
|
||||
middleware,
|
||||
name
|
||||
};
|
||||
|
||||
name('meetups.worldmap');
|
||||
|
||||
with(['markers' => []])
|
||||
|
||||
?>
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('dist/jquery.js') }}"></script>
|
||||
<script src="{{ asset('vendor/jvector/jquery-jvectormap-2.0.5.min.js') }}"></script>
|
||||
<script src="{{ asset('vendor/jvector/maps/world-mill.js') }}"></script>
|
||||
<link rel="stylesheet" href="{{ asset('vendor/jvector/jquery-jvectormap-2.0.5.css') }}" type="text/css"
|
||||
media="screen"/>
|
||||
@endpush
|
||||
|
||||
<x-layouts.app title="{{ __('Worldmap') }}">
|
||||
@volt
|
||||
<div
|
||||
wire:ignore
|
||||
class="w-full flex justify-center"
|
||||
x-data="{
|
||||
init() {
|
||||
let markers = {{ Js::from($markers) }};
|
||||
|
||||
$('#mapworld').vectorMap({
|
||||
zoomButtons : true,
|
||||
zoomOnScroll: true,
|
||||
map: 'world_mill',
|
||||
backgroundColor: 'transparent',
|
||||
markers: markers.map(function(h){ return {name: h.name, latLng: h.coords} }),
|
||||
onMarkerClick: function(event, index) {
|
||||
$wire.call('filterByMarker', markers[index].id)
|
||||
},
|
||||
markerStyle: {
|
||||
initial: {
|
||||
image: '{{ asset('img/btc.png') }}',
|
||||
}
|
||||
},
|
||||
regionStyle: {
|
||||
initial: {
|
||||
fill: '#a4a4a4'
|
||||
},
|
||||
hover: {
|
||||
'fill-opacity': 1,
|
||||
cursor: 'default'
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}"
|
||||
>
|
||||
<div id="mapworld" style="width: 100%;" class="h-[200px] sm:h-[400px]"></div>
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
Reference in New Issue
Block a user