60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { defineStore } from 'pinia';
|
|
|
|
interface Course {
|
|
id: string;
|
|
title: string;
|
|
students: number;
|
|
lessons: number;
|
|
icon: string;
|
|
}
|
|
|
|
interface DashboardStats {
|
|
totalCourses: number;
|
|
totalStudents: number;
|
|
completedStudents: number;
|
|
}
|
|
|
|
export const useInstructorStore = defineStore('instructor', {
|
|
state: () => ({
|
|
stats: {
|
|
totalCourses: 5,
|
|
totalStudents: 125,
|
|
completedStudents: 45
|
|
} as DashboardStats,
|
|
|
|
recentCourses: [
|
|
{
|
|
id: '1',
|
|
title: 'Python เบื้องต้น',
|
|
students: 45,
|
|
lessons: 8,
|
|
icon: '📘'
|
|
},
|
|
{
|
|
id: '2',
|
|
title: 'JavaScript สำหรับเว็บ',
|
|
students: 32,
|
|
lessons: 12,
|
|
icon: '📗'
|
|
}
|
|
] as Course[]
|
|
}),
|
|
|
|
getters: {
|
|
getDashboardStats: (state) => state.stats,
|
|
getRecentCourses: (state) => state.recentCourses
|
|
},
|
|
|
|
actions: {
|
|
async fetchDashboardData() {
|
|
// TODO: Replace with real API call
|
|
// const { $api } = useNuxtApp();
|
|
// const data = await $api('/instructor/dashboard');
|
|
// this.stats = data.stats;
|
|
// this.recentCourses = data.recentCourses;
|
|
|
|
// Using mock data for now
|
|
console.log('Using mock data for instructor dashboard');
|
|
}
|
|
}
|
|
});
|