feat: implement authentication system, role-based routing, and profile settings for interns and mentors

This commit is contained in:
Kemas M. Aryadary Rasyad
2026-06-28 10:13:50 +07:00
parent ad26a53f21
commit 37e21a1f39
17 changed files with 369 additions and 226 deletions
+6 -3
View File
@@ -1,5 +1,5 @@
// hooks/useMahasiswa.ts
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import type { Mahasiswa } from '../types/project.types';
import { getMahasiswa } from '../services/MahasiswaService';
@@ -8,12 +8,15 @@ export const useMahasiswa = () => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
const refetch = useCallback(() => {
setLoading(true);
getMahasiswa()
.then(setMahasiswa)
.catch(() => setError('Gagal memuat data mahasiswa.'))
.finally(() => setLoading(false));
}, []);
return { mahasiswa, loading, error };
useEffect(() => { refetch(); }, [refetch]);
return { mahasiswa, loading, error, refetch };
};