feat: Implement instructor module with course management pages and API services.
This commit is contained in:
parent
07ab43a785
commit
a24f8c4982
6 changed files with 135 additions and 27 deletions
|
|
@ -44,6 +44,7 @@ export interface LoginResponse {
|
|||
firstName: string;
|
||||
lastName: string;
|
||||
role: string;
|
||||
avatarUrl?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +133,8 @@ export const authService = {
|
|||
email: response.user.email,
|
||||
firstName: response.user.profile.first_name,
|
||||
lastName: response.user.profile.last_name,
|
||||
role: response.user.role.code
|
||||
role: response.user.role.code,
|
||||
avatarUrl: response.user.profile.avatar_url
|
||||
}
|
||||
};
|
||||
} catch (error: any) {
|
||||
|
|
|
|||
|
|
@ -225,6 +225,25 @@ export const instructorService = {
|
|||
return response.data;
|
||||
},
|
||||
|
||||
async uploadCourseThumbnail(courseId: number, file: File): Promise<{ thumbnail_url: string }> {
|
||||
const config = useRuntimeConfig();
|
||||
const useMockData = config.public.useMockData as boolean;
|
||||
|
||||
if (useMockData) {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
return { thumbnail_url: URL.createObjectURL(file) };
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const response = await authRequest<{ code: number; data: { thumbnail_url: string } }>(
|
||||
`/api/instructors/courses/${courseId}/thumbnail`,
|
||||
{ method: 'POST', body: formData }
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async deleteCourse(courseId: number): Promise<void> {
|
||||
const config = useRuntimeConfig();
|
||||
const useMockData = config.public.useMockData as boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue