'use client'; import { FC, ReactElement, useState } from 'react'; import { useParams } from 'react-router-dom'; import { ProfileForm, ProfileSidebar, ProfileHeader } from '../_components'; import { ArrowLeftOutlined } from '@ant-design/icons'; import { Button } from '@imphnen-frontend-service/ui/atoms'; import { NotificationModal, NotificationType } from '../_components/modals/notification-modal'; import { ProfileProvider, useProfile } from '../_components/contexts/profile-context'; import { EditProfileModal } from '../_components/modals/edit-profile-modal'; const ProfileByIdPage: FC = (): ReactElement => { const params = useParams(); const id = (params && params.id) ? params.id as string : undefined; if (!id) { return (

Profile ID not found.

); } return ( ); }; const ProfileByIdContent: FC = (): ReactElement => { const { profileData, isLoading, error, profileType } = useProfile(); const [notification, setNotification] = useState<{ isOpen: boolean; type: 'success' | 'error'; title: string; message?: string; }>({ isOpen: false, type: 'success', title: '', message: '' }); const [isEditProfileModalOpen, setIsEditProfileModalOpen] = useState(false); const getProfileTitle = () => { if (profileData?.fullname) { return `${profileData.fullname}'s Profile`; } return profileType === 'user' ? 'User Profile' : 'Mentor Profile'; }; const showNotification = (type: NotificationType['type'], title: string, message?: string) => { setNotification({ isOpen: true, type, title, message }); }; const hideNotification = () => { setNotification(prev => ({ ...prev, isOpen: false })); }; const openEditProfileModal = () => { setIsEditProfileModalOpen(true); }; const closeEditProfileModal = () => { setIsEditProfileModalOpen(false); }; // Set isViewOnly to true for this page const isViewOnly = true; if (isLoading) { return (

Loading profile...

); } if (error) { return (

Failed to load profile

Profile not found or you don't have permission to view it.

); } return (

{getProfileTitle()}

{/* Only render EditProfileModal if not in view-only mode */} {!isViewOnly && ( )}
); }; export default ProfileByIdPage;