feat: add academic advising log management with CRUD operations and UI integration
Some checks failed
tests / ci (pull_request) Has been cancelled
Some checks failed
tests / ci (pull_request) Has been cancelled
This commit is contained in:
parent
4577d45e62
commit
daff18996f
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin\Manage;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Admin\Manage\AcademicAdvisingLogRequest;
|
||||||
|
use App\Http\Requests\PaginatedRequest;
|
||||||
|
use App\Models\AcademicAdvisingLog;
|
||||||
|
use App\Services\Admin\Manage\AcademicAdvisingLogService;
|
||||||
|
use App\Services\Admin\Users\LecturerService;
|
||||||
|
use App\Services\Admin\Users\StudentService;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Inertia\Response;
|
||||||
|
|
||||||
|
class AcademicAdvisingLogController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly AcademicAdvisingLogService $service,
|
||||||
|
private readonly StudentService $studentService,
|
||||||
|
private readonly LecturerService $lecturerService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function index(PaginatedRequest $request): Response
|
||||||
|
{
|
||||||
|
return Inertia::render('admin/manage/academic-advising-logs/index', [
|
||||||
|
'logs' => $this->service->paginated(...$request->validatedWithDefaults()),
|
||||||
|
'students' => $this->studentService->getAllForSelect(),
|
||||||
|
'lecturers' => $this->lecturerService->getAllForSelect(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(AcademicAdvisingLogRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->service->create($request->validated());
|
||||||
|
|
||||||
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Bimbingan akademik berhasil ditambahkan.']);
|
||||||
|
|
||||||
|
return to_route('admin.manage.academic-advising-logs.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(AcademicAdvisingLogRequest $request, AcademicAdvisingLog $academicAdvisingLog): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->service->update($academicAdvisingLog, $request->validated());
|
||||||
|
|
||||||
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Bimbingan akademik berhasil diperbarui.']);
|
||||||
|
|
||||||
|
return to_route('admin.manage.academic-advising-logs.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(AcademicAdvisingLog $academicAdvisingLog): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->service->delete($academicAdvisingLog);
|
||||||
|
|
||||||
|
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Bimbingan akademik berhasil dihapus.'])->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Admin\Manage;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class AcademicAdvisingLogRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'student_id' => ['required', 'integer', Rule::exists('students', 'id')],
|
||||||
|
'lecturer_id' => ['required', 'integer', Rule::exists('lecturers', 'id')],
|
||||||
|
'topic' => ['nullable', 'string', 'max:150'],
|
||||||
|
'notes' => ['nullable', 'string'],
|
||||||
|
'session_date' => ['nullable', 'date'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Models/AcademicAdvisingLog.php
Normal file
31
app/Models/AcademicAdvisingLog.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
#[Guarded(['id'])]
|
||||||
|
class AcademicAdvisingLog extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'session_date' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Student::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lecturer(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Lecturer::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,4 +33,9 @@ public function leaderships(): HasMany
|
|||||||
{
|
{
|
||||||
return $this->hasMany(DepartmentLeadership::class);
|
return $this->hasMany(DepartmentLeadership::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function academicAdvisingLogs(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(AcademicAdvisingLog::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,4 +66,9 @@ public function letterRequests(): HasMany
|
|||||||
{
|
{
|
||||||
return $this->hasMany(LetterRequest::class);
|
return $this->hasMany(LetterRequest::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function academicAdvisingLogs(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(AcademicAdvisingLog::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
app/Services/Admin/Manage/AcademicAdvisingLogService.php
Normal file
53
app/Services/Admin/Manage/AcademicAdvisingLogService.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Admin\Manage;
|
||||||
|
|
||||||
|
use App\Models\AcademicAdvisingLog;
|
||||||
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
|
|
||||||
|
class AcademicAdvisingLogService
|
||||||
|
{
|
||||||
|
public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator
|
||||||
|
{
|
||||||
|
return AcademicAdvisingLog::query()
|
||||||
|
->select(['id', 'student_id', 'lecturer_id', 'topic', 'notes', 'session_date', 'created_at'])
|
||||||
|
->with([
|
||||||
|
'student.user.profile',
|
||||||
|
'student.department',
|
||||||
|
'lecturer.user.profile',
|
||||||
|
])
|
||||||
|
->when($search, fn ($q) => $q->where('topic', 'like', "%{$search}%")
|
||||||
|
->orWhereHas('student', fn ($q) => $q->where('student_number', 'like', "%{$search}%")
|
||||||
|
->orWhereHas('user.profile', fn ($q) => $q->where('full_name', 'like', "%{$search}%"))))
|
||||||
|
->orderBy($sort, $direction)
|
||||||
|
->paginate($perPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(array $data): AcademicAdvisingLog
|
||||||
|
{
|
||||||
|
return AcademicAdvisingLog::create([
|
||||||
|
'student_id' => $data['student_id'],
|
||||||
|
'lecturer_id' => $data['lecturer_id'],
|
||||||
|
'topic' => $data['topic'] ?? null,
|
||||||
|
'notes' => $data['notes'] ?? null,
|
||||||
|
'session_date' => $data['session_date'] ?? now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(AcademicAdvisingLog $log, array $data): AcademicAdvisingLog
|
||||||
|
{
|
||||||
|
$log->student_id = $data['student_id'];
|
||||||
|
$log->lecturer_id = $data['lecturer_id'];
|
||||||
|
$log->topic = $data['topic'] ?? null;
|
||||||
|
$log->notes = $data['notes'] ?? null;
|
||||||
|
$log->session_date = $data['session_date'] ?? now();
|
||||||
|
$log->update();
|
||||||
|
|
||||||
|
return $log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(AcademicAdvisingLog $log): bool
|
||||||
|
{
|
||||||
|
return $log->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('academic_advising_logs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('student_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->foreignId('lecturer_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->string('topic', 150)->nullable();
|
||||||
|
$table->text('notes')->nullable();
|
||||||
|
$table->timestamp('session_date')->nullable()->useCurrent();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('academic_advising_logs');
|
||||||
|
}
|
||||||
|
};
|
||||||
33
database/seeders/AcademicAdvisingLogSeeder.php
Normal file
33
database/seeders/AcademicAdvisingLogSeeder.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\AcademicAdvisingLog;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class AcademicAdvisingLogSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
AcademicAdvisingLog::insert([
|
||||||
|
[
|
||||||
|
'student_id' => 1,
|
||||||
|
'lecturer_id' => 1,
|
||||||
|
'topic' => 'Konsultasi KRS Semester 5',
|
||||||
|
'notes' => 'Mahasiswa mengambil 21 SKS, disetujui',
|
||||||
|
'session_date' => '2026-01-20 13:00:00',
|
||||||
|
'created_at' => '2026-01-20 13:00:00',
|
||||||
|
'updated_at' => '2026-01-20 13:00:00',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'student_id' => 2,
|
||||||
|
'lecturer_id' => 2,
|
||||||
|
'topic' => 'Bimbingan Tugas Akhir Bab 1',
|
||||||
|
'notes' => 'Perlu perbaikan rumusan masalah',
|
||||||
|
'session_date' => '2026-07-15 13:00:00',
|
||||||
|
'created_at' => '2026-07-15 13:00:00',
|
||||||
|
'updated_at' => '2026-07-15 13:00:00',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -30,6 +30,7 @@ public function run(): void
|
|||||||
TuitionPaymentSeeder::class,
|
TuitionPaymentSeeder::class,
|
||||||
AnnouncementSeeder::class,
|
AnnouncementSeeder::class,
|
||||||
LetterRequestSeeder::class,
|
LetterRequestSeeder::class,
|
||||||
|
AcademicAdvisingLogSeeder::class,
|
||||||
NotificationSeeder::class,
|
NotificationSeeder::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import {
|
|||||||
GraduationCap,
|
GraduationCap,
|
||||||
Mail,
|
Mail,
|
||||||
Megaphone,
|
Megaphone,
|
||||||
|
MessageCircle,
|
||||||
Receipt,
|
Receipt,
|
||||||
School,
|
School,
|
||||||
User,
|
User,
|
||||||
@ -37,6 +38,7 @@ import {
|
|||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from '@/components/ui/sidebar';
|
} from '@/components/ui/sidebar';
|
||||||
|
import { index as academicAdvisingLogsRoute } from '@/routes/admin/manage/academic-advising-logs';
|
||||||
import { index as announcementsRoute } from '@/routes/admin/manage/announcements';
|
import { index as announcementsRoute } from '@/routes/admin/manage/announcements';
|
||||||
import { index as assignmentsRoute } from '@/routes/admin/manage/assignments';
|
import { index as assignmentsRoute } from '@/routes/admin/manage/assignments';
|
||||||
import { index as attendancesRoute } from '@/routes/admin/manage/attendances';
|
import { index as attendancesRoute } from '@/routes/admin/manage/attendances';
|
||||||
@ -151,6 +153,11 @@ const data: {
|
|||||||
url: letterRequestsRoute.url(),
|
url: letterRequestsRoute.url(),
|
||||||
icon: Mail,
|
icon: Mail,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Bimbingan Akademik',
|
||||||
|
url: academicAdvisingLogsRoute.url(),
|
||||||
|
icon: MessageCircle,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -0,0 +1,100 @@
|
|||||||
|
import type { ColumnDef } from '@tanstack/react-table';
|
||||||
|
import { format } from 'date-fns';
|
||||||
|
import { Pencil, Trash2 } from 'lucide-react';
|
||||||
|
import { RowActions } from '@/components/row-actions';
|
||||||
|
import type { AcademicAdvisingLog } from '@/types/academic-advising-log';
|
||||||
|
|
||||||
|
export type { AcademicAdvisingLog } from '@/types/academic-advising-log';
|
||||||
|
|
||||||
|
type CreateColumnsParams = {
|
||||||
|
handleEdit: (log: AcademicAdvisingLog) => void;
|
||||||
|
handleDeleteClick: (log: AcademicAdvisingLog) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createAcademicAdvisingLogColumns(
|
||||||
|
params: CreateColumnsParams,
|
||||||
|
): ColumnDef<AcademicAdvisingLog>[] {
|
||||||
|
const { handleEdit, handleDeleteClick } = params;
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
accessorKey: 'student.student_number',
|
||||||
|
header: () => <span>Mahasiswa</span>,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const student = row.original.student;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p className="font-medium">
|
||||||
|
{student?.user?.profile?.full_name ?? 'N/A'}
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{student?.student_number} ·{' '}
|
||||||
|
{student?.department?.name ?? '-'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: 'lecturer.user.profile.full_name',
|
||||||
|
header: () => <span>Dosen Wali</span>,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const lecturer = row.original.lecturer;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p className="font-medium">
|
||||||
|
{lecturer?.user?.profile?.full_name ?? 'N/A'}
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{lecturer?.lecturer_number}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: 'topic',
|
||||||
|
header: () => <span>Topik</span>,
|
||||||
|
cell: ({ row }) => row.original.topic ?? '-',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: 'session_date',
|
||||||
|
header: () => <span>Tanggal Sesi</span>,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const sessionDate = row.original.session_date;
|
||||||
|
|
||||||
|
return sessionDate
|
||||||
|
? format(new Date(sessionDate), 'd MMM yyyy, HH:mm')
|
||||||
|
: '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'actions',
|
||||||
|
header: () => <span className="block text-center">Aksi</span>,
|
||||||
|
meta: {
|
||||||
|
className: 'w-[100px] text-center',
|
||||||
|
headerClassName: 'w-[100px] text-center',
|
||||||
|
},
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<RowActions
|
||||||
|
actions={[
|
||||||
|
{
|
||||||
|
label: 'Edit',
|
||||||
|
icon: <Pencil className="h-4 w-4" />,
|
||||||
|
onClick: () => handleEdit(row.original),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Hapus',
|
||||||
|
icon: (
|
||||||
|
<Trash2 className="h-4 w-4 text-destructive" />
|
||||||
|
),
|
||||||
|
onClick: () => handleDeleteClick(row.original),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
346
resources/js/pages/admin/manage/academic-advising-logs/index.tsx
Normal file
346
resources/js/pages/admin/manage/academic-advising-logs/index.tsx
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
import { Head, router } from '@inertiajs/react';
|
||||||
|
import { Plus } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import type { PaginationState } from '@/components/data-table';
|
||||||
|
import { DataTable } from '@/components/data-table';
|
||||||
|
import { DateTimeField } from '@/components/datetime-field';
|
||||||
|
import { DeleteConfirmDialog } from '@/components/delete-confirm-dialog';
|
||||||
|
import { FormDialog } from '@/components/form-dialog';
|
||||||
|
import InputError from '@/components/input-error';
|
||||||
|
import { PageHeader } from '@/components/page-header';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
|
import { useServerTable } from '@/hooks/use-server-table';
|
||||||
|
import {
|
||||||
|
index as academicAdvisingLogIndex,
|
||||||
|
destroy,
|
||||||
|
store,
|
||||||
|
update,
|
||||||
|
} from '@/routes/admin/manage/academic-advising-logs';
|
||||||
|
import type {
|
||||||
|
AcademicAdvisingLog,
|
||||||
|
AcademicAdvisingLogLecturer,
|
||||||
|
AcademicAdvisingLogStudent,
|
||||||
|
} from '@/types/academic-advising-log';
|
||||||
|
import { createAcademicAdvisingLogColumns } from './columns';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
logs: {
|
||||||
|
data: AcademicAdvisingLog[];
|
||||||
|
current_page: number;
|
||||||
|
last_page: number;
|
||||||
|
per_page: number;
|
||||||
|
total: number;
|
||||||
|
};
|
||||||
|
students: AcademicAdvisingLogStudent[];
|
||||||
|
lecturers: AcademicAdvisingLogLecturer[];
|
||||||
|
highlight?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
function studentLabel(student: AcademicAdvisingLogStudent): string {
|
||||||
|
return `${student.user?.profile?.full_name ?? 'N/A'} - ${student.student_number}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function lecturerLabel(lecturer: AcademicAdvisingLogLecturer): string {
|
||||||
|
return `${lecturer.user?.profile?.full_name ?? 'N/A'} - ${lecturer.lecturer_number}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AcademicAdvisingLogIndex({
|
||||||
|
logs,
|
||||||
|
students,
|
||||||
|
lecturers,
|
||||||
|
highlight,
|
||||||
|
}: Props) {
|
||||||
|
const [createOpen, setCreateOpen] = useState(false);
|
||||||
|
const [editing, setEditing] = useState<AcademicAdvisingLog | null>(null);
|
||||||
|
const [deleting, setDeleting] = useState<AcademicAdvisingLog | null>(null);
|
||||||
|
|
||||||
|
const pagination: PaginationState = {
|
||||||
|
current_page: logs.current_page,
|
||||||
|
last_page: logs.last_page,
|
||||||
|
per_page: logs.per_page,
|
||||||
|
total: logs.total,
|
||||||
|
};
|
||||||
|
|
||||||
|
const {
|
||||||
|
search,
|
||||||
|
handlePageChange,
|
||||||
|
handlePerPageChange,
|
||||||
|
handleSearchChange,
|
||||||
|
} = useServerTable({
|
||||||
|
route: () => academicAdvisingLogIndex.url(),
|
||||||
|
pagination,
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleDelete() {
|
||||||
|
if (!deleting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
router.delete(destroy(deleting.id), {
|
||||||
|
onSuccess: () => setDeleting(null),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = createAcademicAdvisingLogColumns({
|
||||||
|
handleEdit: (log) => setEditing(log),
|
||||||
|
handleDeleteClick: (log) => setDeleting(log),
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head title="Bimbingan Akademik" />
|
||||||
|
|
||||||
|
<div className="flex h-full flex-1 flex-col gap-6 overflow-x-auto p-4 md:p-6">
|
||||||
|
<PageHeader
|
||||||
|
title="Bimbingan Akademik"
|
||||||
|
description={
|
||||||
|
highlight && (
|
||||||
|
<p className="mt-1 text-sm text-muted-foreground">
|
||||||
|
Menampilkan log bimbingan dari notifikasi.
|
||||||
|
</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
actions={
|
||||||
|
<Button asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setCreateOpen(true)}
|
||||||
|
>
|
||||||
|
<Plus className="h-4 w-4" />
|
||||||
|
Tambah
|
||||||
|
</button>
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CreateForm
|
||||||
|
open={createOpen}
|
||||||
|
onOpenChange={setCreateOpen}
|
||||||
|
students={students}
|
||||||
|
lecturers={lecturers}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<EditForm
|
||||||
|
key={editing?.id}
|
||||||
|
open={editing !== null}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
setEditing(null);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
editing={editing}
|
||||||
|
students={students}
|
||||||
|
lecturers={lecturers}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DataTable
|
||||||
|
columns={columns}
|
||||||
|
data={logs.data}
|
||||||
|
emptyText="Belum ada data bimbingan akademik."
|
||||||
|
pagination={pagination}
|
||||||
|
onPageChange={handlePageChange}
|
||||||
|
onPerPageChange={handlePerPageChange}
|
||||||
|
onSearchChange={handleSearchChange}
|
||||||
|
searchValue={search}
|
||||||
|
searchKey="student"
|
||||||
|
searchPlaceholder="Cari nama atau NIM mahasiswa..."
|
||||||
|
/>
|
||||||
|
|
||||||
|
<DeleteConfirmDialog
|
||||||
|
target={deleting}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
setDeleting(null);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
title="Hapus Log Bimbingan"
|
||||||
|
description={(log) =>
|
||||||
|
`Apakah Anda yakin ingin menghapus log bimbingan untuk "${log.student?.user?.profile?.full_name ?? 'mahasiswa ini'}"? Tindakan ini tidak dapat dibatalkan.`
|
||||||
|
}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function AdvisingLogFields({
|
||||||
|
errors,
|
||||||
|
editing,
|
||||||
|
students,
|
||||||
|
lecturers,
|
||||||
|
}: {
|
||||||
|
errors: Record<string, string>;
|
||||||
|
editing?: AcademicAdvisingLog;
|
||||||
|
students: AcademicAdvisingLogStudent[];
|
||||||
|
lecturers: AcademicAdvisingLogLecturer[];
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label>
|
||||||
|
Mahasiswa <span className="text-destructive">*</span>
|
||||||
|
</Label>
|
||||||
|
{!editing && <input type="hidden" name="student_id" />}
|
||||||
|
<Select
|
||||||
|
name="student_id"
|
||||||
|
defaultValue={
|
||||||
|
editing ? String(editing.student_id) : undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full">
|
||||||
|
<SelectValue placeholder="Pilih mahasiswa" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{students.map((student) => (
|
||||||
|
<SelectItem
|
||||||
|
key={student.id}
|
||||||
|
value={String(student.id)}
|
||||||
|
>
|
||||||
|
{studentLabel(student)}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<InputError message={errors.student_id} />
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label>
|
||||||
|
Dosen Wali <span className="text-destructive">*</span>
|
||||||
|
</Label>
|
||||||
|
{!editing && <input type="hidden" name="lecturer_id" />}
|
||||||
|
<Select
|
||||||
|
name="lecturer_id"
|
||||||
|
defaultValue={
|
||||||
|
editing ? String(editing.lecturer_id) : undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full">
|
||||||
|
<SelectValue placeholder="Pilih dosen" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{lecturers.map((lecturer) => (
|
||||||
|
<SelectItem
|
||||||
|
key={lecturer.id}
|
||||||
|
value={String(lecturer.id)}
|
||||||
|
>
|
||||||
|
{lecturerLabel(lecturer)}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<InputError message={errors.lecturer_id} />
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label htmlFor={editing ? 'edit-topic' : 'topic'}>Topik</Label>
|
||||||
|
<Input
|
||||||
|
id={editing ? 'edit-topic' : 'topic'}
|
||||||
|
name="topic"
|
||||||
|
placeholder="Masukkan topik bimbingan"
|
||||||
|
defaultValue={editing?.topic ?? ''}
|
||||||
|
/>
|
||||||
|
<InputError message={errors.topic} />
|
||||||
|
</div>
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label htmlFor={editing ? 'edit-notes' : 'notes'}>
|
||||||
|
Catatan
|
||||||
|
</Label>
|
||||||
|
<Textarea
|
||||||
|
id={editing ? 'edit-notes' : 'notes'}
|
||||||
|
name="notes"
|
||||||
|
placeholder="Masukkan catatan bimbingan"
|
||||||
|
defaultValue={editing?.notes ?? ''}
|
||||||
|
/>
|
||||||
|
<InputError message={errors.notes} />
|
||||||
|
</div>
|
||||||
|
<DateTimeField
|
||||||
|
label="Tanggal Sesi"
|
||||||
|
name="session_date"
|
||||||
|
defaultValue={editing?.session_date}
|
||||||
|
placeholder="Pilih tanggal sesi"
|
||||||
|
error={errors.session_date}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CreateForm({
|
||||||
|
open,
|
||||||
|
onOpenChange,
|
||||||
|
students,
|
||||||
|
lecturers,
|
||||||
|
}: {
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
students: AcademicAdvisingLogStudent[];
|
||||||
|
lecturers: AcademicAdvisingLogLecturer[];
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<FormDialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={onOpenChange}
|
||||||
|
title="Tambah Bimbingan Akademik"
|
||||||
|
action={store()}
|
||||||
|
resetOnSuccess
|
||||||
|
onSuccess={() => onOpenChange(false)}
|
||||||
|
>
|
||||||
|
{({ errors }) => (
|
||||||
|
<div className="grid gap-4">
|
||||||
|
<AdvisingLogFields
|
||||||
|
errors={errors}
|
||||||
|
students={students}
|
||||||
|
lecturers={lecturers}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</FormDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function EditForm({
|
||||||
|
open,
|
||||||
|
onOpenChange,
|
||||||
|
editing,
|
||||||
|
students,
|
||||||
|
lecturers,
|
||||||
|
}: {
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
editing: AcademicAdvisingLog | null;
|
||||||
|
students: AcademicAdvisingLogStudent[];
|
||||||
|
lecturers: AcademicAdvisingLogLecturer[];
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<FormDialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={onOpenChange}
|
||||||
|
title="Edit Bimbingan Akademik"
|
||||||
|
action={editing ? update(editing.id) : ''}
|
||||||
|
resetOnSuccess
|
||||||
|
onSuccess={() => onOpenChange(false)}
|
||||||
|
>
|
||||||
|
{({ errors }) =>
|
||||||
|
editing && (
|
||||||
|
<div className="grid gap-4">
|
||||||
|
<AdvisingLogFields
|
||||||
|
errors={errors}
|
||||||
|
editing={editing}
|
||||||
|
students={students}
|
||||||
|
lecturers={lecturers}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</FormDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
25
resources/js/types/academic-advising-log.ts
Normal file
25
resources/js/types/academic-advising-log.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export type AcademicAdvisingLogStudent = {
|
||||||
|
id: number;
|
||||||
|
student_number: string;
|
||||||
|
department: { id: number; name: string } | null;
|
||||||
|
user: { profile: { full_name: string } | null } | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AcademicAdvisingLogLecturer = {
|
||||||
|
id: number;
|
||||||
|
lecturer_number: string;
|
||||||
|
user: { profile: { full_name: string } | null } | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AcademicAdvisingLog = {
|
||||||
|
id: number;
|
||||||
|
student_id: number;
|
||||||
|
student: AcademicAdvisingLogStudent | null;
|
||||||
|
lecturer_id: number;
|
||||||
|
lecturer: AcademicAdvisingLogLecturer | null;
|
||||||
|
topic: string | null;
|
||||||
|
notes: string | null;
|
||||||
|
session_date: string | null;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
};
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\Admin\Manage\AcademicAdvisingLogController;
|
||||||
use App\Http\Controllers\Admin\Manage\AnnouncementController;
|
use App\Http\Controllers\Admin\Manage\AnnouncementController;
|
||||||
use App\Http\Controllers\Admin\Manage\AssignmentController;
|
use App\Http\Controllers\Admin\Manage\AssignmentController;
|
||||||
use App\Http\Controllers\Admin\Manage\AttendanceController;
|
use App\Http\Controllers\Admin\Manage\AttendanceController;
|
||||||
@ -76,6 +77,8 @@
|
|||||||
Route::resource('announcements', AnnouncementController::class)->except(['create', 'edit', 'show']);
|
Route::resource('announcements', AnnouncementController::class)->except(['create', 'edit', 'show']);
|
||||||
|
|
||||||
Route::resource('letter-requests', LetterRequestController::class)->except(['create', 'edit', 'show']);
|
Route::resource('letter-requests', LetterRequestController::class)->except(['create', 'edit', 'show']);
|
||||||
|
|
||||||
|
Route::resource('academic-advising-logs', AcademicAdvisingLogController::class)->except(['create', 'edit', 'show']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('admin/users')->name('admin.users.')->group(function () {
|
Route::prefix('admin/users')->name('admin.users.')->group(function () {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user