Files
riksdagen-app/resources/views/livewire/person/show.blade.php

775 lines
42 KiB
PHP

<div class="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100">
<div class="container mx-auto py-12 px-4">
<!-- Breadcrumb Navigation -->
<nav class="mb-8" aria-label="Breadcrumb">
<div
class="bg-white rounded-lg shadow-sm border border-gray-200 px-4 py-3"
>
<ol class="flex items-center space-x-2 text-sm text-gray-600">
<li>
<a
wire:navigate
href="{{ route('home') }}"
class="text-blue-600 hover:text-blue-700 flex items-center"
>
<svg
class="w-4 h-4 mr-1"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"
></path>
</svg>
Hem
</a>
</li>
<li>
<svg
class="w-4 h-4 text-gray-400"
fill="currentColor"
viewBox="0 0 20 20"
>
<path
fill-rule="evenodd"
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
clip-rule="evenodd"
></path>
</svg>
</li>
<li>
<a
wire:navigate
href="{{ route('person.search') }}"
class="text-blue-600 hover:text-blue-700"
>
Sök Ledamöter
</a>
</li>
<li>
<svg
class="w-4 h-4 text-gray-400"
fill="currentColor"
viewBox="0 0 20 20"
>
<path
fill-rule="evenodd"
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
clip-rule="evenodd"
></path>
</svg>
</li>
<li class="font-medium text-gray-900">
{{ $person->tilltalsnamn ?? 'Laddar...' }}
{{ $person->efternamn ?? '' }}
</li>
</ol>
</div>
</nav>
@if ($person)
<!-- Main Profile Section -->
<div
class="bg-white rounded-lg shadow-md border border-gray-200 p-8 mb-8"
>
<div class="flex flex-col md:flex-row gap-8">
<div class="md:w-48">
<img
src="{{ $person->bild_url_max ?? '' }}"
alt="{{ $person->tilltalsnamn }}"
class="w-full h-64 md:w-48 object-cover rounded-lg shadow-lg border border-gray-200"
/>
<span class="text-xs text-gray-500 mt-2 block">
Foto: Sveriges Riksdag
</span>
</div>
<div class="flex-1">
<div class="mb-6">
<h1 class="text-4xl font-bold text-gray-900 mb-2">
{{ $person->tilltalsnamn }}
{{ $person->efternamn }}
({{ $person->parti }})
</h1>
<div class="flex flex-wrap items-center gap-4 mb-4">
<span
class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800 grap-2"
>
{{ App\Enums\Parties::from($person->parti)->label() }}
<img
src="{{ App\Enums\Parties::from($person->parti)->logo() }}"
width="32"
/>
</span>
<span class="text-gray-600">
{{ $person->valkrets }} valkrets
</span>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
<div class="bg-gray-50 rounded-lg p-4">
<div
class="text-sm font-medium text-gray-500 mb-1"
>
Född
</div>
<div class="text-gray-900">
{{ $person->fodd_ar }}
({{ Carbon\Carbon::parse($person->fodd_ar)->age }}
år)
</div>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<div
class="text-sm font-medium text-gray-500 mb-1"
>
Kön
</div>
<div class="text-gray-900">
{{ ucfirst($person->kon) }}
</div>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<div
class="text-sm font-medium text-gray-500 mb-1"
>
Status
</div>
<div class="text-gray-900">
{{ $person->status }}
</div>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<div
class="text-sm font-medium text-gray-500 mb-1"
>
E-post
</div>
<div class="text-gray-900 text-sm">
{{ str_replace('[på]', '@', collect($person->personuppgift->uppgift ?? [])->firstWhere('kod', 'Officiell e-postadress')->uppgift[0] ?? '-') }}
</div>
</div>
</div>
</div>
</div>
</div>
@if (! empty($votesByYear))
<!-- Voting Section -->
<div
class="bg-white rounded-lg shadow-md border border-gray-200 p-6 mb-8"
>
<div class="flex items-center mb-6">
<div
class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center mr-3"
>
<svg
class="w-5 h-5 text-blue-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"
/>
</svg>
</div>
<h2 class="text-2xl font-bold text-gray-900">
Voteringar
</h2>
</div>
<!-- Year tabs -->
<div class="border-b border-gray-200 mb-4">
<nav class="-mb-px flex space-x-8">
@foreach (array_keys($votesByYear) as $year)
<button
wire:click="selectVotesYear('{{ $year }}')"
class="cursor-pointer py-2 px-1 border-b-2 font-medium text-sm {{ $votesSelectedYear == $year ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }}"
>
{{ $year }}
</button>
@endforeach
</nav>
</div>
@if ($votesSelectedYear && isset($votesByYear[$votesSelectedYear]))
<!-- Voting Statistics -->
<div
class="mb-8 bg-gray-200 p-6 rounded-lg shadow border"
>
@if (! empty($this->votingStatistics))
<div class="flex flex-col lg:flex-row gap-6">
<div style="height: 23rem">
<livewire:livewire-pie-chart
:pie-chart-model="$this->pieChartModel"
key="{{ 'pie-chart-' . $votesSelectedYear }}"
/>
</div>
<div class="lg:w-1/2 my-auto">
<div class="space-y-2">
@php($totalVotes = array_sum($this->votingStatistics))
@foreach ($this->votingStatistics as $voteType => $count)
<div
class="flex justify-between items-center p-3 bg-gray-50 rounded"
>
<span
class="text-black font-medium"
>
{{ $voteType }}
</span>
<span
class="text-black text-lg font-bold"
>
{{ $count }}
({{ round(($count / $totalVotes) * 100, 2) }}%)
</span>
</div>
@endforeach
<div
class="flex justify-between items-center p-3 bg-blue-50 rounded border-t-2 border-blue-500"
>
<span
class="text-black font-bold"
>
Totalt antal voteringar
</span>
<span
class="text-black text-lg font-bold"
>
{{ $totalVotes }}
</span>
</div>
</div>
</div>
</div>
@else
<p class="text-gray-500">
Ingen voteringsstatistik tillgänglig för
detta år.
</p>
@endif
</div>
<!-- Votes table -->
<div
class="overflow-x-auto overflow-y-auto max-h-[400px]"
>
<table
class="min-w-full bg-white border border-gray-200"
>
<thead class="bg-gray-50 sticky top-0">
<tr>
<th
class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
>
Datum
</th>
<th
class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
>
Beteckning
</th>
<th
class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
>
Punkt
</th>
<th
class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
>
Röst
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@foreach ($votesByYear[$votesSelectedYear] as $vote)
<tr class="bg-gray-200">
<td
class="px-4 py-2 text-sm text-gray-900"
>
{{ \Carbon\Carbon::parse($vote->systemdatum)->format('Y-m-d') }}
</td>
<td class="px-4 py-2 text-sm">
<a
href="{{ $vote->votering_url_xml }}"
class="text-blue-600 hover:underline"
target="_blank"
>
{{ $vote->beteckning }}
</a>
</td>
<td
class="px-4 py-2 text-sm text-gray-900"
>
{{ $vote->punkt }}
</td>
<td class="px-4 py-2 text-sm">
<span
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full {{
$vote->rost === 'Ja'
? 'bg-green-100 text-green-800'
: ($vote->rost === 'Nej'
? 'bg-red-100 text-red-800'
: 'bg-gray-100 text-gray-800')
}}"
>
{{ $vote->rost }}
</span>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<p class="text-gray-500">
Inga voteringar tillgängliga för detta år.
</p>
@endif
</div>
@endif
<!-- Motions Section -->
<div
class="bg-white rounded-lg shadow-md border border-gray-200 p-6 mb-8"
>
<div class="flex items-center mb-6">
<div
class="w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center mr-3"
>
<svg
class="w-5 h-5 text-green-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
></path>
</svg>
</div>
<h2 class="text-2xl font-bold text-gray-900">Motioner</h2>
</div>
<!-- Year tabs for motions -->
@if (! empty($motionsByYear))
<div class="border-b border-gray-200 mb-4">
<nav class="-mb-px flex space-x-8">
@foreach (array_keys($motionsByYear) as $year)
<button
wire:click="selectMotionsYear('{{ $year }}')"
class="cursor-pointer py-2 px-1 border-b-2 font-medium text-sm {{ $motionsSelectedYear == $year ? 'border-green-500 text-green-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }}"
>
{{ $year }}
({{ count($motionsByYear[$year]) }})
</button>
@endforeach
</nav>
</div>
@if ($motionsSelectedYear && isset($motionsByYear[$motionsSelectedYear]))
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
>
Beteckning
</th>
<th
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
>
Titel
</th>
<th
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
>
Typ
</th>
<th
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
>
Datum
</th>
<th
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
>
Status
</th>
<th
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
>
Åtgärder
</th>
</tr>
</thead>
<tbody
class="bg-white divide-y divide-gray-200"
>
@foreach ($motionsByYear[$motionsSelectedYear] as $motion)
<tr class="hover:bg-gray-50">
<td
class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"
>
{{ $motionsSelectedYear }}:{{ $motion->beteckning }}
</td>
<td
class="px-6 py-4 text-sm text-gray-900"
>
<div
class="max-w-xs truncate"
title="{{ $motion->titel }}"
>
{{ $motion->titel }}
</div>
@if (! empty($motion->undertitel))
<div
class="text-xs text-gray-500 mt-1"
>
{{ $motion->undertitel }}
</div>
@endif
</td>
<td
class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"
>
<span
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full {{ $motion->subtyp == 'Partimotion' ? 'bg-blue-100 text-blue-800' : 'bg-gray-100 text-gray-800' }}"
>
{{ $motion->subtyp }}
</span>
</td>
<td
class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"
>
{{ \Carbon\Carbon::parse($motion->datum)->format('Y-m-d') }}
</td>
<td
class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"
>
<span
class="inline-flex px-2 py-1 text-xs font-semibold rounded-full {{
$motion->status == 'LagdTillHandlingarna'
? 'bg-yellow-100 text-yellow-800'
: ($motion->status == 'Avslutad'
? 'bg-green-100 text-green-800'
: 'bg-gray-100 text-gray-800')
}}"
>
{{ $motion->status }}
</span>
</td>
<td
class="px-6 py-4 whitespace-nowrap text-sm font-medium"
>
@if (! empty($motion->dokument_url_html))
<a
href="https:{{ $motion->dokument_url_html }}"
target="_blank"
class="text-green-600 hover:text-green-900 mr-4"
>
<svg
class="w-4 h-4 inline"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
></path>
</svg>
Läs
</a>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<p class="text-gray-500">
Inga motioner tillgängliga för detta år.
</p>
@endif
@else
<p class="text-gray-500">
Inga motioner tillgängliga för denna person.
</p>
@endif
</div>
<!-- Assignments Section -->
<div
class="bg-white rounded-lg shadow-md border border-gray-200 p-6 mb-8"
>
<div class="flex items-center mb-6">
<div
class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center mr-3"
>
<svg
class="w-5 h-5 text-blue-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2-2v2m8 0H8m8 0v2a2 2 0 01-2 2H10a2 2 0 01-2-2V6"
></path>
</svg>
</div>
<h2 class="text-2xl font-bold text-gray-900">Uppdrag</h2>
</div>
<!-- Uppdrag tabs -->
<div class="border-b border-gray-200 mb-6">
<nav class="-mb-px flex space-x-8">
<button
wire:click="selectUppdragTab('current')"
class="py-3 px-1 border-b-2 font-medium text-sm transition-colors {{ $selectedUppdragTab == 'current' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }}"
>
<span class="flex items-center">
<svg
class="w-4 h-4 mr-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
></path>
</svg>
Pågående ({{ count($currentUppdrag) }})
</span>
</button>
<button
wire:click="selectUppdragTab('previous')"
class="py-3 px-1 border-b-2 font-medium text-sm transition-colors {{ $selectedUppdragTab == 'previous' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }}"
>
<span class="flex items-center">
<svg
class="w-4 h-4 mr-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
></path>
</svg>
Tidigare ({{ count($previousUppdrag) }})
</span>
</button>
</nav>
</div>
<!-- Current assignments -->
@if ($selectedUppdragTab == 'current' && ! empty($currentUppdrag))
<div class="space-y-3">
@foreach ($currentUppdrag as $uppdrag)
<div
class="bg-green-50 border border-green-200 rounded-lg p-4"
>
<div class="flex justify-between items-start">
<div>
<h4
class="font-semibold text-green-800"
>
{{ $uppdrag->roll_kod }}
</h4>
{{--
@if (!empty($uppdrag->uppgift[0]) && is_array($uppdrag->uppgift))
<p class="text-sm text-green-700 mt-1">{{ implode(', ', $uppdrag->uppgift) }}</p>
@endif
--}}
<p class="text-sm text-green-600 mt-2">
<span class="font-medium">
Typ:
</span>
{{ ucfirst($uppdrag->typ) }}
@if (isset($uppdrag->status) && $uppdrag->status)
|
<span class="font-medium">
Status:
</span>
{{ $uppdrag->status }}
@endif
</p>
</div>
<div
class="text-right text-sm text-green-600"
>
<div>
Från:
{{ Carbon\Carbon::parse($uppdrag->from)->format('Y-m-d') }}
</div>
@if (! empty($uppdrag->tom))
<div>
Till:
{{ Carbon\Carbon::parse($uppdrag->tom)->format('Y-m-d') }}
</div>
@else
<div
class="font-semibold text-green-700"
>
Pågående
</div>
@endif
</div>
</div>
</div>
@endforeach
</div>
@elseif ($selectedUppdragTab == 'current' && empty($currentUppdrag))
<p class="text-gray-500 italic">Inga pågående uppdrag.</p>
@endif
<!-- Previous assignments -->
@if ($selectedUppdragTab == 'previous' && ! empty($previousUppdrag))
<div class="space-y-3">
@foreach ($previousUppdrag as $uppdrag)
<div
class="bg-gray-50 border border-gray-200 rounded-lg p-4"
>
<div class="flex justify-between items-start">
<div>
<h4 class="font-semibold text-gray-800">
{{ $uppdrag->roll_kod }}
</h4>
{{--
@if (!empty($uppdrag->uppgift[0]) && is_array($uppdrag->uppgift))
<p class="text-sm text-gray-700 mt-1">{{ implode(', ', $uppdrag->uppgift) }}</p>
@endif
--}}
<p class="text-sm text-gray-600 mt-2">
<span class="font-medium">
Typ:
</span>
{{ ucfirst($uppdrag->typ) }}
@if (isset($uppdrag->status) && $uppdrag->status)
|
<span class="font-medium">
Status:
</span>
{{ $uppdrag->status }}
@endif
</p>
</div>
<div
class="text-right text-sm text-gray-600"
>
<div>
{{ Carbon\Carbon::parse($uppdrag->from)->format('Y-m-d') }}
-
{{ Carbon\Carbon::parse($uppdrag->tom)->format('Y-m-d') }}
</div>
<div class="text-xs text-gray-500 mt-1">
{{ Carbon\Carbon::parse($uppdrag->from)->diffForHumans(Carbon\Carbon::parse($uppdrag->tom), true) }}
</div>
</div>
</div>
</div>
@endforeach
</div>
@elseif ($selectedUppdragTab == 'previous' && empty($previousUppdrag))
<p class="text-gray-500 italic">
Inga tidigare uppdrag registrerade.
</p>
@endif
</div>
<!-- Biography Section -->
<div
class="bg-white rounded-lg shadow-md border border-gray-200 p-6 mb-8"
>
<div class="flex items-center mb-6">
<div
class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center mr-3"
>
<svg
class="w-5 h-5 text-blue-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.746 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
></path>
</svg>
</div>
<h2 class="text-2xl font-bold text-gray-900">Biografi</h2>
</div>
<div class="space-y-4">
@foreach (collect($person->personuppgift->uppgift ?? [])->where('typ', 'biografi') as $bio)
<div class="bg-gray-50 rounded-lg p-4">
<div class="font-semibold text-gray-900 mb-2">
{{ $bio->kod }}
</div>
<div class="text-gray-700">
{{ is_array($bio->uppgift) ? implode(', ', $bio->uppgift) : $bio->uppgift }}
</div>
</div>
@endforeach
</div>
</div>
@else
<div
class="bg-white rounded-lg shadow-md border border-gray-200 p-8 text-center"
>
<svg
class="w-16 h-16 text-gray-400 mx-auto mb-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
></path>
</svg>
<h3 class="text-lg font-medium text-gray-900 mb-2">
Person inte hittad
</h3>
<p class="text-gray-600">
Personen kunde inte hittas i databasen.
</p>
</div>
@endif
</div>
</div>