Image resolve
This commit is contained in:
@ -74,8 +74,15 @@ export class FacultyService {
|
||||
}
|
||||
}
|
||||
|
||||
static async getFacultyById(id: number): Promise<TeamMember | null> {
|
||||
// ✅ FIXED: Now accepts both numeric ID and UUID professorId
|
||||
static async getFacultyById(id: number | string): Promise<TeamMember | null> {
|
||||
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<TeamMember[]> => {
|
||||
return await FacultyService.getAllFaculty();
|
||||
};
|
||||
|
||||
// Helper function to get team member by ID
|
||||
export const getTeamMemberById = async (id: number): Promise<TeamMember | null> => {
|
||||
// Helper function to get team member by ID (now accepts both numeric and UUID)
|
||||
export const getTeamMemberById = async (id: number | string): Promise<TeamMember | null> => {
|
||||
return await FacultyService.getFacultyById(id);
|
||||
};
|
||||
|
||||
// Helper function to get team member by professorId (UUID)
|
||||
export const getTeamMemberByProfessorId = async (professorId: string): Promise<TeamMember | null> => {
|
||||
return await FacultyService.getFacultyByProfessorId(professorId);
|
||||
};
|
||||
Reference in New Issue
Block a user