feat: let students customize public profiles
This commit is contained in:
@@ -209,6 +209,7 @@ export const adminApi = {
|
||||
export const profileApi = {
|
||||
async me() { return apiRequest<{ data: Profile }>('/profiles/me'); },
|
||||
async update(input: ProfileInput) { return apiRequest<{ data: Profile }>('/profiles/me', { method: 'PATCH', body: JSON.stringify(input) }); },
|
||||
async public(profileId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/${profileId}`); },
|
||||
async instructor(instructorId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/instructors/${instructorId}`); },
|
||||
};
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ export const getCourses = async (): Promise<Course[]> => {
|
||||
export type InstructorProfileData = {
|
||||
id: string;
|
||||
name: string;
|
||||
role: 'student' | 'instructor' | 'admin';
|
||||
avatarImageUrl: string | null;
|
||||
headline: string;
|
||||
bio: string;
|
||||
@@ -225,6 +226,11 @@ export const getInstructorProfile = async (instructorId: string): Promise<Instru
|
||||
return { ...response.data, courses: response.data.courses.map(toCourse) };
|
||||
};
|
||||
|
||||
export const getPublicProfile = async (profileId: string): Promise<InstructorProfileData> => {
|
||||
const response = await apiRequest<{ data: Omit<InstructorProfileData, 'courses'> & { courses: ApiCourse[] } }>(`/profiles/${profileId}`);
|
||||
return { ...response.data, courses: response.data.courses.map(toCourse) };
|
||||
};
|
||||
|
||||
export const getLearningPaths = async (): Promise<PublicLearningPath[]> => {
|
||||
const response = await apiRequest<{ data: PublicLearningPath[] }>('/courses/paths');
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user