First Commit

This commit is contained in:
marco
2026-09-01 07:49:48 -03:00
commit 28b1044038
399 changed files with 41659 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
@extends("layouts.app")
@section("title", __("Edit Custom Subject"))
@section("header")
<div class="flex justify-between items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __("Edit Custom Subject") }}
</h2>
</div>
@endsection
@section("content")
<div class="py-6">
<div class="max-w-3xl mx-auto sm:px-6 lg:px-8">
@if(session("success"))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-6">
{{ session("success") }}
</div>
@endif
@if(session("error"))
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg mb-6">
{{ session("error") }}
</div>
@endif
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-900">{{ $customSubject->name }}</h3>
<p class="text-sm text-gray-500">{{ __("Created") }}: {{ $customSubject->created_at->format("d/m/Y H:i") }}</p>
</div>
<form action="{{ route("admin.custom-subjects.update", $customSubject) }}" method="POST">
@csrf
@method("PUT")
<div class="mb-4">
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Subject Name") }} *</label>
<input type="text"
name="name"
id="name"
value="{{ old("name", $customSubject->name) }}"
required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 @error("name") border-red-500 @enderror">
@error("name")
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-6">
<div class="flex items-center">
<input type="checkbox"
name="is_active"
id="is_active"
value="1"
{{ old("is_active", $customSubject->is_active) ? "checked" : "" }}
class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
<label for="is_active" class="ml-2 block text-sm text-gray-900">
{{ __("Active") }}
</label>
</div>
<p class="text-xs text-gray-500 mt-1">{{ __("Inactive subjects will not receive scheduled insights.") }}</p>
</div>
<div class="flex items-center gap-3">
<button type="submit"
class="px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
{{ __("Save Changes") }}
</button>
<a href="{{ route("admin.custom-subjects.index") }}"
class="px-4 py-2 bg-gray-200 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-300 transition">
{{ __("Cancel") }}
</a>
</div>
</form>
</div>
</div>
</div>
@endsection
+137
View File
@@ -0,0 +1,137 @@
@extends("layouts.app")
@section("title", __("My Custom Subjects"))
@section("header")
<div class="flex justify-between items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __("My Custom Subjects") }}
</h2>
</div>
@endsection
@section("content")
<div class="py-6">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
@if(session("success"))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-6">
{{ session("success") }}
</div>
@endif
@if(session("error"))
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg mb-6">
{{ session("error") }}
</div>
@endif
<!-- Upload Form -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4">{{ __("Upload PDF") }}</h3>
<form action="{{ route("admin.custom-subjects.store") }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="md:col-span-1">
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Subject Name") }} *</label>
<input type="text" name="name" id="name" value="{{ old("name") }}" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 @error("name") border-red-500 @enderror">
@error("name")
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div class="md:col-span-1">
<label for="pdf" class="block text-sm font-medium text-gray-700 mb-2">{{ __("PDF File") }} *</label>
<input type="file" name="pdf" id="pdf" accept=".pdf,application/pdf" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 @error("pdf") border-red-500 @enderror">
@error("pdf")
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
<p class="text-xs text-gray-500 mt-1">{{ __("Maximum file size: 10MB") }}</p>
</div>
<div class="md:col-span-1 flex items-end">
<button type="submit"
class="w-full px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
<svg class="w-4 h-4 inline mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"/>
</svg>
{{ __("Upload and Process") }}
</button>
</div>
</div>
</form>
</div>
<!-- Custom Subjects List -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4">{{ __("My Custom Subjects") }}</h3>
@if($customSubjects->count() === 0)
<p class="text-gray-500 text-center py-8">{{ __("No custom subjects yet. Upload a PDF to get started.") }}</p>
@else
<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">{{ __("Name") }}</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">{{ __("Created") }}</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Actions") }}</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($customSubjects as $subject)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">{{ $subject->name }}</td>
<td class="px-6 py-4 whitespace-nowrap">
@if($subject->processing_status === "completed")
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{{ __("Ready") }}
</span>
@elseif($subject->processing_status === "processing")
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
{{ __("Processing") }}
</span>
@elseif($subject->processing_status === "failed")
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
{{ __("Failed") }}
</span>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $subject->created_at->format("d/m/Y H:i") }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
@if($subject->processing_status === "completed")
<a href="{{ route("admin.custom-subjects.edit", $subject) }}"
class="text-indigo-600 hover:text-indigo-900 mr-3">
{{ __("Edit") }}
</a>
<a href="{{ route("admin.custom-subjects.show", $subject) }}"
class="text-indigo-600 hover:text-indigo-900 mr-3">
{{ __("Ask Questions") }}
</a>
@else
<a href="{{ route("admin.custom-subjects.edit", $subject) }}"
class="text-indigo-600 hover:text-indigo-900 mr-3">
{{ __("Edit") }}
</a>
@endif
<form action="{{ route("admin.custom-subjects.destroy", $subject) }}" method="POST" class="inline"
onsubmit="return confirm('{{ __("Delete this custom subject? This action cannot be undone.") }}')">
@csrf
@method("DELETE")
<button type="submit" class="text-red-600 hover:text-red-900">
{{ __("Delete") }}
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
</div>
@endsection
+126
View File
@@ -0,0 +1,126 @@
@extends("layouts.app")
@section("title", $customSubject->name)
@section("header")
<div class="flex justify-between items-center">
<div>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ $customSubject->name }}
</h2>
<p class="text-sm text-gray-500 mt-1">{{ __("Ask questions about the PDF content") }}</p>
</div>
<div class="flex gap-2">
<a href="{{ route("admin.custom-subjects.index") }}"
class="inline-flex items-center px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 transition">
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
</svg>
{{ __("Back") }}
</a>
</div>
</div>
@endsection
@section("content")
<div class="py-6">
<div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
@if(session("success"))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-6">
{{ session("success") }}
</div>
@endif
@if(session("error"))
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg mb-6">
{{ session("error") }}
</div>
@endif
<!-- Q&A Form -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
<form action="{{ route("admin.custom-subjects.ask", $customSubject) }}" method="POST">
@csrf
<div class="mb-4">
<label for="question" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Your Question") }}</label>
<textarea name="question" id="question" rows="3" required
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 @error("question") border-red-500 @enderror"
placeholder="{{ __("Ask something about the PDF content...") }}">{{ old("question") }}</textarea>
@error("question")
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div class="bg-blue-50 border-l-4 border-blue-400 p-3 mb-4">
<p class="text-sm text-blue-700">
{{ __("Tip: Always specify the desired language in your question, e.g. \"Answer in English\" or \"Responda em português\".") }}
</p>
</div>
<div class="flex justify-end">
<button type="submit"
class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>
</svg>
{{ __("Ask") }}
</button>
</div>
</form>
</div>
<!-- Questions History -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4">{{ __("Questions History") }}</h3>
@if($questions->count() === 0)
<p class="text-gray-500 text-center py-8">{{ __("No questions asked yet.") }}</p>
@else
<div class="space-y-4">
@foreach($questions as $q)
<div class="border border-gray-200 rounded-lg p-4">
<div class="flex items-start gap-3">
<div class="flex-shrink-0 w-8 h-8 bg-indigo-100 rounded-full flex items-center justify-center">
<svg class="w-4 h-4 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900">{{ $q->question }}</p>
<p class="text-xs text-gray-500 mt-1">{{ $q->asked_at->format("d/m/Y H:i") }}</p>
</div>
</div>
@if($q->answer)
<div class="mt-3 ml-11 p-3 bg-gray-50 rounded-lg">
<div class="prose prose-sm max-w-none text-gray-700">
{!! nl2br(e($q->answer)) !!}
</div>
</div>
@endif
<div class="flex items-center gap-2 ml-11 mt-2">
<form action="{{ route('admin.custom-subjects.questions.translate', [$customSubject, $q]) }}" method="POST" class="flex items-center gap-1">
@csrf
<select name="target_language" class="text-xs border border-gray-300 rounded-lg px-2 py-1 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="pt_BR" {{ app()->getLocale() === 'pt_BR' ? 'selected' : '' }}>PT</option>
<option value="en" {{ app()->getLocale() === 'en' ? 'selected' : '' }}>EN</option>
<option value="es" {{ app()->getLocale() === 'es' ? 'selected' : '' }}>ES</option>
</select>
<button type="submit" class="text-xs text-indigo-500 hover:text-indigo-700 font-medium" title="{{ __('Translate') }}">
{{ __('Translate') }}
</button>
</form>
<form action="{{ route('admin.custom-subjects.questions.destroy', [$customSubject, $q]) }}" method="POST"
onsubmit="return confirm('{{ __("Delete this question?") }}')">
@csrf
@method('DELETE')
<button type="submit" class="text-xs text-red-500 hover:text-red-700">
{{ __("Delete") }}
</button>
</form>
</div>
</div>
@endforeach
</div>
@endif
</div>
</div>
</div>
@endsection