diff --git a/src/components/micro_learning/ConceptExplainer.jsx b/src/components/micro_learning/ConceptExplainer.jsx
index e798bb8..e1503ba 100644
--- a/src/components/micro_learning/ConceptExplainer.jsx
+++ b/src/components/micro_learning/ConceptExplainer.jsx
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from 'react';
-import { Card, CardContent, CardHeader, CardTitle } from '../ui/card'; // assuming some UI library, otherwise use standard divs
+import Card from '../ui/Card';
export default function ConceptExplainer({ content, onComplete }) {
const containerRef = useRef(null);
@@ -25,12 +25,12 @@ export default function ConceptExplainer({ content, onComplete }) {
}, [onComplete]);
return (
-
-
- Concept Explainer
-
-
+
+
Concept Explainer
+
+
{content?.sections?.map((section, i) => (
@@ -39,7 +39,7 @@ export default function ConceptExplainer({ content, onComplete }) {
))}
-
+
);
}
diff --git a/src/components/micro_learning/FlashcardSet.jsx b/src/components/micro_learning/FlashcardSet.jsx
index 16a841c..c28fdbc 100644
--- a/src/components/micro_learning/FlashcardSet.jsx
+++ b/src/components/micro_learning/FlashcardSet.jsx
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
-import { Card, CardContent } from '../ui/card';
-import { Button } from '../ui/button';
+import Card from '../ui/Card';
+import Button from '../ui/Button';
export default function FlashcardSet({ content, onComplete }) {
const [currentIndex, setCurrentIndex] = useState(0);
@@ -12,12 +12,10 @@ export default function FlashcardSet({ content, onComplete }) {
const handleFlip = () => {
setIsFlipped(!isFlipped);
- // Once flipped, mark this card as viewed
const newViewed = new Set(viewedCards);
newViewed.add(currentIndex);
setViewedCards(newViewed);
- // If all cards are viewed, trigger completion
if (newViewed.size === cards.length && cards.length > 0) {
onComplete();
}
@@ -41,25 +39,25 @@ export default function FlashcardSet({ content, onComplete }) {
return (
-
+
Card {currentIndex + 1} of {cards.length}
-
+
{isFlipped ? (
) : (
-
diff --git a/src/components/micro_learning/MicroLearningSelector.jsx b/src/components/micro_learning/MicroLearningSelector.jsx
index ca22bfc..4faf36c 100644
--- a/src/components/micro_learning/MicroLearningSelector.jsx
+++ b/src/components/micro_learning/MicroLearningSelector.jsx
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from 'react';
import { useMicroLearnings } from '../../hooks/useMicroLearnings';
import MicroLearningContainer from './MicroLearningContainer';
-import { Button } from '../ui/button';
-import { Card, CardContent, CardHeader, CardTitle } from '../ui/card';
+import Button from '../ui/Button';
+import Card from '../ui/Card';
const TYPE_LABELS = {
'concept_explainer': 'Concept Explainer',
@@ -40,19 +40,21 @@ export default function MicroLearningSelector({ topicId, sessionWeek, onTopicCom
setSelectedML(ml);
};
- if (loading) return
Loading learning formats...
;
+ if (loading) return
Loading learning formats...
;
if (availableMLs.length === 0) {
- return
No micro learnings available for this topic yet.
;
+ return
No micro learnings available for this topic yet.
;
}
- // If one is selected, render it
if (selectedML) {
return (
-
setSelectedML(null)} className="mb-4">
+ setSelectedML(null)}
+ className="text-fg-muted hover:text-teal mb-4 text-sm font-medium"
+ >
← Back to selection
-
+
-
- Choose a Learning Format
-
-
-
- {availableMLs.map((ml) => (
-
handleSelection(ml)}
- >
-
- {TYPE_LABELS[ml.type] || ml.type}
- {TYPE_DESCRIPTIONS[ml.type]}
-
-
- ))}
-
-
+
+
Choose a Learning Format
+
+
+ {availableMLs.map((ml) => (
+
handleSelection(ml)}
+ >
+
{TYPE_LABELS[ml.type] || ml.type}
+
{TYPE_DESCRIPTIONS[ml.type]}
+
+ ))}
+
);
}
diff --git a/src/components/micro_learning/ReflectionPrompt.jsx b/src/components/micro_learning/ReflectionPrompt.jsx
index 39ecd91..af12411 100644
--- a/src/components/micro_learning/ReflectionPrompt.jsx
+++ b/src/components/micro_learning/ReflectionPrompt.jsx
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
-import { Card, CardContent, CardHeader, CardTitle } from '../ui/card';
-import { Button } from '../ui/button';
+import Card from '../ui/Card';
+import Button from '../ui/Button';
export default function ReflectionPrompt({ content, onComplete }) {
const [response, setResponse] = useState('');
@@ -11,15 +11,15 @@ export default function ReflectionPrompt({ content, onComplete }) {
if (!response.trim() || submitted) return;
setSubmitted(true);
- onComplete(); // Trigger completion when a response is submitted
+ onComplete();
};
return (
-
- Reflection Prompt
-
-
+
+
Reflection Prompt
+
+
@@ -27,7 +27,7 @@ export default function ReflectionPrompt({ content, onComplete }) {
{!submitted ? (
) : (
-
-
Your Reflection
+
+
Your Reflection
{response}
-
);
}
diff --git a/src/components/micro_learning/ScenarioQuiz.jsx b/src/components/micro_learning/ScenarioQuiz.jsx
index 9ba09c4..d8e0c94 100644
--- a/src/components/micro_learning/ScenarioQuiz.jsx
+++ b/src/components/micro_learning/ScenarioQuiz.jsx
@@ -1,24 +1,24 @@
import React, { useState } from 'react';
-import { Card, CardContent, CardHeader, CardTitle, CardFooter } from '../ui/card';
-import { Button } from '../ui/button';
+import Card from '../ui/Card';
+import Button from '../ui/Button';
export default function ScenarioQuiz({ content, onComplete }) {
const [selectedOptionId, setSelectedOptionId] = useState(null);
const [showExplanations, setShowExplanations] = useState(false);
const handleSelect = (idx) => {
- if (showExplanations) return; // Prevent changing after selection
+ if (showExplanations) return;
setSelectedOptionId(idx);
setShowExplanations(true);
- onComplete(); // Trigger completion immediately after an option is selected
+ onComplete();
};
return (
-
- Scenario Quiz
-
-
+
+
Scenario Quiz
+
+
@@ -27,18 +27,19 @@ export default function ScenarioQuiz({ content, onComplete }) {
{content?.options?.map((option, idx) => {
const isSelected = selectedOptionId === idx;
- // Basic styling for the option buttons
let buttonStyle = "w-full justify-start text-left h-auto p-4 ";
if (showExplanations) {
if (option.isCorrect) buttonStyle += "bg-green-100 dark:bg-green-900 border-green-500 ";
else if (isSelected && !option.isCorrect) buttonStyle += "bg-red-100 dark:bg-red-900 border-red-500 ";
else buttonStyle += "opacity-70 ";
+ } else {
+ if (isSelected) buttonStyle += "bg-teal/10 ";
}
return (
handleSelect(idx)}
disabled={showExplanations}
@@ -47,7 +48,7 @@ export default function ScenarioQuiz({ content, onComplete }) {
{showExplanations && (
-
+
{option.isCorrect ? '✓ ' : '✗ '}
{option.explanation}
@@ -56,7 +57,7 @@ export default function ScenarioQuiz({ content, onComplete }) {
);
})}
-
+
);
}
diff --git a/src/hooks/useMicroLearningCompletions.js b/src/hooks/useMicroLearningCompletions.js
index 2536516..63f8e19 100644
--- a/src/hooks/useMicroLearningCompletions.js
+++ b/src/hooks/useMicroLearningCompletions.js
@@ -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) {
diff --git a/src/hooks/useMicroLearnings.js b/src/hooks/useMicroLearnings.js
index 2d2da59..f0eccc9 100644
--- a/src/hooks/useMicroLearnings.js
+++ b/src/hooks/useMicroLearnings.js
@@ -1,4 +1,4 @@
-import pb from '../lib/pb';
+import { pb } from '../lib/pb';
export function useMicroLearnings() {
const getMicroLearningsByTopic = async (topicId) => {