feat: implement core micro-learning components and hooks for diverse educational formats
This commit is contained in:
@@ -1,19 +1,11 @@
|
||||
import pb from '../lib/pb';
|
||||
import { useAuthStore } from '../store/authStore';
|
||||
import { pb } from '../lib/pb';
|
||||
|
||||
export function useMicroLearningCompletions() {
|
||||
const { user } = useAuthStore?.() || { user: pb.authStore.model };
|
||||
|
||||
// Note: user in PB context for team_members usually matches user_id or team_member_id.
|
||||
// We need the team_member record. If the frontend is currently storing it in authStore, we can get it.
|
||||
|
||||
const recordCompletion = async ({ microLearningId, topicId, type, sessionWeek }) => {
|
||||
try {
|
||||
// Find the team_member record for the current user
|
||||
let teamMemberId = user?.id;
|
||||
// If user is just the auth user, we might need to query the team_members collection
|
||||
// but in many setups, the auth user is the team_member or there's a 1-to-1.
|
||||
// Let's ensure we fetch team_member_id properly if needed.
|
||||
const user = pb.authStore.model;
|
||||
if (!user) throw new Error("No authenticated user");
|
||||
|
||||
const teamMemberRec = await pb.collection('team_members').getFirstListItem(`user_id = "${user.id}"`);
|
||||
|
||||
if (!teamMemberRec) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import pb from '../lib/pb';
|
||||
import { pb } from '../lib/pb';
|
||||
|
||||
export function useMicroLearnings() {
|
||||
const getMicroLearningsByTopic = async (topicId) => {
|
||||
|
||||
Reference in New Issue
Block a user