127 lines
7.3 KiB
PHP
Executable File
127 lines
7.3 KiB
PHP
Executable File
@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
|