From 1701eb0af0d9b21b65941961f873a69c5997bcb6 Mon Sep 17 00:00:00 2001 From: mukeshs Date: Tue, 14 Oct 2025 10:05:28 +0530 Subject: [PATCH] Image resolve --- src/lib/facultyData.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/lib/facultyData.ts b/src/lib/facultyData.ts index 8c38555..ce985e3 100644 --- a/src/lib/facultyData.ts +++ b/src/lib/facultyData.ts @@ -74,8 +74,15 @@ export class FacultyService { } } - static async getFacultyById(id: number): Promise { + // ✅ FIXED: Now accepts both numeric ID and UUID professorId + static async getFacultyById(id: number | string): Promise { try { + // If it's a UUID (string with dashes), fetch directly from API + if (typeof id === 'string' && id.includes('-')) { + return await this.getFacultyByProfessorId(id); + } + + // Otherwise, fetch all and find by numeric ID const allFaculty = await this.getAllFaculty(); return allFaculty.find(member => member.id === id) || null; } catch (error) { @@ -142,9 +149,14 @@ export class FacultyService { // If it's already a full URL, use it as is if (prof.profileImageUrl.startsWith('http')) { imageUrl = prof.profileImageUrl; + // ✅ FIX: Replace /user/ with /professor/ in the URL + imageUrl = imageUrl.replace('/user/', '/professor/'); } else { // If it's a relative URL, construct the full URL - imageUrl = `${imageBaseUrl}${prof.profileImageUrl}`; + let relativePath = prof.profileImageUrl; + // ✅ FIX: Replace /user/ with /professor/ in relative paths too + relativePath = relativePath.replace('/user/', '/professor/'); + imageUrl = `${imageBaseUrl}${relativePath}`; } } @@ -157,7 +169,8 @@ export class FacultyService { position: prof.position || 'Faculty Member', designation: prof.designation || prof.position || 'Faculty Member', image: imageUrl, - profileUrl: `/faculty/${index + 1}`, + // ✅ FIXED: Use professorId in URL instead of numeric ID + profileUrl: `/faculty/${prof.professorId}`, phone: prof.phone || 'Not available', email: prof.email, experience: prof.experience || 'Not specified', @@ -207,6 +220,7 @@ export class FacultyService { position: "Please wait while we fetch the latest faculty information", designation: "System Message", image: "/images/default-avatar.jpg", + profileUrl: '/faculty/fallback-1', phone: "Not available", email: "support@institution.edu", experience: "N/A", @@ -228,7 +242,12 @@ export const getTeamMembers = async (): Promise => { return await FacultyService.getAllFaculty(); }; -// Helper function to get team member by ID -export const getTeamMemberById = async (id: number): Promise => { +// Helper function to get team member by ID (now accepts both numeric and UUID) +export const getTeamMemberById = async (id: number | string): Promise => { return await FacultyService.getFacultyById(id); +}; + +// Helper function to get team member by professorId (UUID) +export const getTeamMemberByProfessorId = async (professorId: string): Promise => { + return await FacultyService.getFacultyByProfessorId(professorId); }; \ No newline at end of file