From 7b70621c5a67d24e656768e3bc9d2b08afec44d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Wed, 1 Jul 2026 17:20:19 +0300 Subject: [PATCH] feat: implement interactive intern dashboard journal features and correct resource component namespace --- .../InternApplicationResource.php | 2 +- .../front/career/intern_dashboard.blade.php | 151 +++++++++++++++++- 2 files changed, 146 insertions(+), 7 deletions(-) diff --git a/app/Filament/Admin/Resources/InternApplications/InternApplicationResource.php b/app/Filament/Admin/Resources/InternApplications/InternApplicationResource.php index 53e4779..fca75f2 100644 --- a/app/Filament/Admin/Resources/InternApplications/InternApplicationResource.php +++ b/app/Filament/Admin/Resources/InternApplications/InternApplicationResource.php @@ -225,7 +225,7 @@ class InternApplicationResource extends Resource }) ->columnSpanFull(), - \Filament\Forms\Components\Section::make('Onay ve İmza Bilgileri') + \Filament\Schemas\Components\Section::make('Onay ve İmza Bilgileri') ->schema([ \Filament\Forms\Components\Toggle::make('notebook_supervisor_signed') ->label('Staj Sorumlusu İmzala / Onayla') diff --git a/resources/views/front/career/intern_dashboard.blade.php b/resources/views/front/career/intern_dashboard.blade.php index aa385cd..dbdb46c 100644 --- a/resources/views/front/career/intern_dashboard.blade.php +++ b/resources/views/front/career/intern_dashboard.blade.php @@ -870,12 +870,151 @@ }); }) .catch(err => { - return text - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); + console.warn('Commits could not be pre-loaded in memory.', err); + }); + } + + function selectNotebookDay(idx) { + const oldBtn = document.getElementById(`btn-day-${activeDayIdx}`); + if (oldBtn) { + oldBtn.classList.remove('border-blue-200', 'bg-blue-50/50'); + oldBtn.classList.add('border-slate-100', 'bg-white'); + const oldTitle = oldBtn.querySelector('span.text-xs'); + if (oldTitle) { + oldTitle.classList.remove('text-blue-700'); + oldTitle.classList.add('text-slate-800'); + } + } + + activeDayIdx = idx; + const newBtn = document.getElementById(`btn-day-${idx}`); + if (newBtn) { + newBtn.classList.add('border-blue-200', 'bg-blue-50/50'); + newBtn.classList.remove('border-slate-100', 'bg-white'); + const newTitle = newBtn.querySelector('span.text-xs'); + if (newTitle) { + newTitle.classList.add('text-blue-700'); + newTitle.classList.remove('text-slate-800'); + } + + const dayNum = newBtn.getAttribute('data-day-num'); + const dateVal = newBtn.getAttribute('data-date'); + const dateFormatted = newBtn.getAttribute('data-formatted-date'); + const savedContent = newBtn.getAttribute('data-saved-content'); + + document.getElementById('editor-day-title').textContent = `${dayNum}. Gün`; + document.getElementById('editor-day-date').textContent = dateFormatted; + document.getElementById('editor-content').value = savedContent; + document.getElementById('save-status').textContent = ''; + } + } + + function fillFromGithub() { + const btn = document.getElementById(`btn-day-${activeDayIdx}`); + if (!btn) return; + + const dateVal = btn.getAttribute('data-date'); + const dayCommits = allGithubCommits[dateVal] || []; + + if (dayCommits.length === 0) { + alert("Bu staj gününe ait GitHub commit'i bulunamadı. Lütfen commit attığınızdan ve tarihin doğru olduğundan emin olun."); + return; + } + + let commitText = ""; + const sorted = [...dayCommits].reverse(); + sorted.forEach(c => { + const msg = c.commit.message; + const sha = c.sha.substring(0, 7); + const authorDate = new Date(c.commit.author.date); + const time = authorDate.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' }); + commitText += `- [${time}] (${sha}) ${msg}\n`; + }); + + const textarea = document.getElementById('editor-content'); + if (textarea.value.trim() !== "") { + if (confirm("Mevcut rapor içeriğinizin sonuna bu günün commitlerini eklemek ister misiniz? (Hayır derseniz mevcut içerik silinip commitler yazılır.)")) { + textarea.value = textarea.value.trim() + "\n\n" + commitText.trim(); + } else { + textarea.value = commitText.trim(); + } + } else { + textarea.value = commitText.trim(); + } + } + + function saveActiveDay() { + const btn = document.getElementById(`btn-day-${activeDayIdx}`); + if (!btn) return; + + const dayNum = btn.getAttribute('data-day-num'); + const dateVal = btn.getAttribute('data-date'); + const contentVal = document.getElementById('editor-content').value; + const statusText = document.getElementById('save-status'); + + statusText.textContent = "Kaydediliyor..."; + statusText.className = "text-xs font-semibold text-slate-400 animate-pulse"; + + fetch("{{ route('intern.save-journal') }}", { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-CSRF-TOKEN": "{{ csrf_token() }}" + }, + body: JSON.stringify({ + day_number: dayNum, + date: dateVal, + content: contentVal + }) + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + statusText.textContent = "Başarıyla kaydedildi."; + statusText.className = "text-xs font-semibold text-green-600"; + + btn.setAttribute('data-saved-content', contentVal); + + const badge = document.getElementById(`badge-day-${activeDayIdx}`); + if (badge) { + if (contentVal.trim() !== '') { + badge.textContent = 'DOLU'; + badge.className = "inline-flex px-2 py-0.5 rounded-lg text-[9px] font-extrabold uppercase bg-green-50 text-green-700 border border-green-200"; + } else { + badge.textContent = 'BOŞ'; + badge.className = "inline-flex px-2 py-0.5 rounded-lg text-[9px] font-extrabold uppercase bg-slate-50 text-slate-400 border border-slate-200"; + } + } + } else { + statusText.textContent = data.message || "Kaydedilemedi."; + statusText.className = "text-xs font-semibold text-red-600"; + } + }) + .catch(err => { + console.error(err); + statusText.textContent = "Bağlantı hatası oluştu."; + statusText.className = "text-xs font-semibold text-red-600"; + }); + } + + function openPrintModal() { + const modal = document.getElementById('print-modal'); + const card = document.getElementById('print-modal-card'); + modal.classList.remove('hidden'); + setTimeout(() => { + card.classList.remove('scale-95', 'opacity-0'); + card.classList.add('scale-100', 'opacity-100'); + }, 10); + } + + function closePrintModal() { + const modal = document.getElementById('print-modal'); + const card = document.getElementById('print-modal-card'); + card.classList.remove('scale-100', 'opacity-100'); + card.classList.add('scale-95', 'opacity-0'); + setTimeout(() => { + modal.classList.add('hidden'); + }, 300); } function handleFileSelected(input) {