Files

90 lines
6.0 KiB
PHP
Raw Permalink Normal View History

2026-03-19 18:42:19 +02:00
<x-analytics-layout :website="$website" title="Annotations">
@if (session('success'))
<div class="mb-6 rounded-xl bg-emerald-50 border border-emerald-200 p-4">
<p class="text-sm font-medium text-emerald-800">{{ session('success') }}</p>
</div>
@endif
<div class="grid gap-6 lg:grid-cols-3">
{{-- Add annotation form --}}
<div class="lg:col-span-1">
<div class="bg-white rounded-xl border border-gray-200 p-6">
<h3 class="text-base font-semibold text-gray-900 mb-4">Add Annotation</h3>
<form method="POST" action="{{ route('annotations.store', $website) }}" class="space-y-4">
@csrf
<div>
<label for="date" class="block text-sm font-medium text-gray-700 mb-1">Date</label>
<input type="date" name="date" id="date" value="{{ old('date', now()->format('Y-m-d')) }}" required
class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label for="category" class="block text-sm font-medium text-gray-700 mb-1">Category</label>
<select name="category" id="category"
class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
@foreach (\App\Models\Annotation::$categories as $value => $label)
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
</select>
</div>
<div>
<label for="text" class="block text-sm font-medium text-gray-700 mb-1">Note</label>
<textarea name="text" id="text" rows="3" required maxlength="500"
placeholder="e.g. Launched new ad campaign"
class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('text') }}</textarea>
</div>
<button type="submit" class="inline-flex items-center gap-2 px-4 py-2 bg-indigo-600 rounded-lg text-sm font-medium text-white hover:bg-indigo-500 transition">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>
Add Annotation
</button>
</form>
</div>
</div>
{{-- Annotations list --}}
<div class="lg:col-span-2">
@if ($annotations->isEmpty())
<x-empty-state
icon='<svg class="w-10 h-10" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 0 1 .865-.501 48.172 48.172 0 0 0 3.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z" /></svg>'
title="No annotations yet"
message="Add notes on specific dates to mark important events on your charts."
/>
@else
<div class="bg-white rounded-xl border border-gray-200 overflow-hidden">
<div class="divide-y divide-gray-200">
@foreach ($annotations as $annotation)
<div class="flex items-start justify-between px-6 py-4">
<div class="flex items-start gap-3">
@php
$categoryColors = [
'general' => 'bg-gray-100 text-gray-600',
'deployment' => 'bg-blue-100 text-blue-700',
'campaign' => 'bg-purple-100 text-purple-700',
'incident' => 'bg-red-100 text-red-700',
];
@endphp
<span class="inline-flex px-2 py-0.5 rounded text-xs font-medium {{ $categoryColors[$annotation->category] ?? $categoryColors['general'] }} mt-0.5">
{{ \App\Models\Annotation::$categories[$annotation->category] ?? $annotation->category }}
</span>
<div>
<p class="text-sm text-gray-900">{{ $annotation->text }}</p>
<p class="text-xs text-gray-400 mt-0.5">
{{ $annotation->date->format('M j, Y') }}
· {{ $annotation->user->name }}
</p>
</div>
</div>
<form method="POST" action="{{ route('annotations.destroy', [$website, $annotation]) }}" onsubmit="return confirm('Delete this annotation?')">
@csrf
@method('DELETE')
<button type="submit" class="text-sm text-red-600 hover:text-red-800 font-medium transition">Delete</button>
</form>
</div>
@endforeach
</div>
</div>
<div class="mt-4">{{ $annotations->links() }}</div>
@endif
</div>
</div>
</x-analytics-layout>