127 lines
5.6 KiB
TypeScript
127 lines
5.6 KiB
TypeScript
import React from 'react';
|
|
import { useAppContext } from '../context/AppContext.tsx';
|
|
import { UserShieldIcon, UsersIcon, CheckIcon } from './icons/Icons.tsx';
|
|
import InfoCard from './profile/InfoCard.tsx';
|
|
import InfoItem from './profile/InfoItem.tsx';
|
|
import { userAvatars } from './auth/PersonaSelector.tsx';
|
|
|
|
const ProfilePage: React.FC = () => {
|
|
const { currentUser, roles, groups } = useAppContext();
|
|
|
|
if (!currentUser) {
|
|
return <div className="p-8 text-center">Pengguna tidak ditemukan. Silakan login kembali.</div>;
|
|
}
|
|
|
|
const userRole = roles.find((r) => r.id === currentUser.roleId)?.name || 'Peran Tidak Diketahui';
|
|
const userGroup =
|
|
groups.find((g) => g.id === currentUser.groupId)?.name || 'Grup Tidak Diketahui';
|
|
const avatarUrl = userAvatars[currentUser.id] || 'https://randomuser.me/api/portraits/lego/1.jpg';
|
|
|
|
return (
|
|
<div className="bg-gray-50 min-h-full">
|
|
{/* Profile Header */}
|
|
<div className="bg-white shadow-sm">
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div className="py-10">
|
|
<div className="flex flex-col sm:flex-row items-center sm:space-x-8">
|
|
<img
|
|
className="w-32 h-32 rounded-full object-cover border-4 border-white shadow-lg flex-shrink-0"
|
|
src={avatarUrl}
|
|
alt="Foto Profil Pengguna"
|
|
/>
|
|
<div className="mt-4 sm:mt-0 text-center sm:text-left">
|
|
<h1 className="text-3xl font-bold text-gray-900">{currentUser.name}</h1>
|
|
<p className="text-lg text-gray-600">{userRole}</p>
|
|
<p className="text-sm text-gray-500">{currentUser.email}</p>
|
|
</div>
|
|
<div className="mt-4 sm:mt-0 sm:ml-auto">
|
|
<button className="flex items-center space-x-2 bg-red-600 text-white px-4 py-2 rounded-lg hover:bg-red-700 transition duration-300 shadow-sm font-semibold">
|
|
<i className="fa-solid fa-pencil"></i>
|
|
<span>Edit Profil</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Profile Body */}
|
|
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pb-8">
|
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
|
<div className="md:col-span-2 space-y-8">
|
|
<InfoCard title="Detail Akun">
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
|
<InfoItem icon={<UserShieldIcon />} label="Peran Sistem" value={userRole} />
|
|
<InfoItem icon={<UsersIcon />} label="Grup Pengguna" value={userGroup} />
|
|
<InfoItem
|
|
icon={<CheckIcon className="text-green-500" />}
|
|
label="Status Akun"
|
|
value="Aktif"
|
|
/>
|
|
<InfoItem
|
|
icon={<i className="fa-solid fa-calendar-alt"></i>}
|
|
label="Bergabung Sejak"
|
|
value="12 Januari 2023"
|
|
/>
|
|
</div>
|
|
</InfoCard>
|
|
|
|
<InfoCard title="Aktivitas Terbaru">
|
|
<ul className="space-y-4">
|
|
<li className="flex items-center space-x-3">
|
|
<div className="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center">
|
|
<i className="fa-solid fa-file-pdf text-blue-600"></i>
|
|
</div>
|
|
<p className="text-sm text-gray-600">
|
|
Membuat <strong>Laporan Harian</strong>.
|
|
</p>
|
|
<p className="text-xs text-gray-400 ml-auto">5 menit yang lalu</p>
|
|
</li>
|
|
<li className="flex items-center space-x-3">
|
|
<div className="w-8 h-8 rounded-full bg-green-100 flex items-center justify-center">
|
|
<i className="fa-solid fa-camera text-green-600"></i>
|
|
</div>
|
|
<p className="text-sm text-gray-600">
|
|
Menambahkan kamera baru <strong>Kamera Gudang #2</strong>.
|
|
</p>
|
|
<p className="text-xs text-gray-400 ml-auto">2 jam yang lalu</p>
|
|
</li>
|
|
<li className="flex items-center space-x-3">
|
|
<div className="w-8 h-8 rounded-full bg-yellow-100 flex items-center justify-center">
|
|
<i className="fa-solid fa-triangle-exclamation text-yellow-600"></i>
|
|
</div>
|
|
<p className="text-sm text-gray-600">
|
|
Menangani notifikasi <strong>Kepadatan Berlebih</strong> di Kandang C.
|
|
</p>
|
|
<p className="text-xs text-gray-400 ml-auto">Kemarin</p>
|
|
</li>
|
|
</ul>
|
|
</InfoCard>
|
|
</div>
|
|
|
|
<div className="md:col-span-1">
|
|
<InfoCard title="Hak Akses">
|
|
<ul className="text-sm space-y-2 text-gray-600">
|
|
<li className="flex items-center">
|
|
<CheckIcon className="text-green-500 mr-2" /> Lihat Semua Dashboard
|
|
</li>
|
|
<li className="flex items-center">
|
|
<CheckIcon className="text-green-500 mr-2" /> Kelola Pengguna
|
|
</li>
|
|
<li className="flex items-center">
|
|
<CheckIcon className="text-green-500 mr-2" /> Kelola Perangkat
|
|
</li>
|
|
<li className="flex items-center">
|
|
<CheckIcon className="text-green-500 mr-2" /> Konfigurasi Sistem
|
|
</li>
|
|
</ul>
|
|
</InfoCard>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ProfilePage;
|