Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: track progress in ui

Brad Barbin811b9e078c86
diff --git a/apps/university/app/components/AvatarMenu.tsx b/apps/university/app/components/AvatarMenu.tsx
index 3a5236dc08..fdd96ebf02 100644
--- a/apps/university/app/components/AvatarMenu.tsx
+++ b/apps/university/app/components/AvatarMenu.tsx
@@ -1,4 +1,5 @@
import {
+ cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuIcon,
@@ -17,7 +18,7 @@ import { useMode } from "~/hooks/useMode";
import type { action } from "~/root";
import { path } from "~/utils/path";
-const AvatarMenu = () => {
+const AvatarMenu = ({ className }: { className?: string }) => {
const user = useUser();
const name = `${user.firstName} ${user.lastName}`;
@@ -31,7 +32,12 @@ const AvatarMenu = () => {
return (
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
- <DropdownMenuTrigger className="outline-none focus-visible:outline-none">
+ <DropdownMenuTrigger
+ className={cn(
+ "outline-none focus-visible:outline-none cursor-pointer",
+ className
+ )}
+ >
<Avatar path={user.avatarUrl} name={name} />
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-56">
diff --git a/apps/university/app/config.tsx b/apps/university/app/config.tsx
index fdd7dab893..4ae0dec408 100644
--- a/apps/university/app/config.tsx
+++ b/apps/university/app/config.tsx
@@ -1,11 +1,4 @@
-import {
- LuBookOpen,
- LuCode,
- LuCrown,
- LuShield,
- LuShoppingCart,
- LuSquareStack,
-} from "react-icons/lu";
+import { LuCirclePlay, LuHexagon } from "react-icons/lu";
type Config = Section[];
@@ -14,7 +7,6 @@ type Section = {
id: string;
background: string;
foreground: string;
- icon: React.ReactNode;
courses: Course[];
};
@@ -22,6 +14,7 @@ type Course = {
name: string;
id: string;
description: string;
+ icon: React.ReactNode;
topics: Topic[];
};
@@ -54,13 +47,13 @@ export const sections: Config = [
background: "#6041d0",
foreground: "#fff",
id: "getting-started",
- icon: <LuBookOpen />,
courses: [
{
name: "Carbon Overview",
id: "carbon-overview",
description:
"Welcome to Carbon, a powerful ERP/MES/QMS software that uses web technology and a modular platform to offer a wide variety of configurations based on the customer's needs. Learn about Carbon's architecture and setup in this first course.",
+ icon: <LuHexagon />,
topics: [
{
name: "Introducing Carbon",
@@ -133,6 +126,7 @@ export const sections: Config = [
name: "Getting Setup",
id: "getting-setup",
description: "Learn how to setup your organization to use Carbon.",
+ icon: <LuCirclePlay />,
topics: [
{
name: "Setting Up Your Company",
@@ -208,7 +202,6 @@ export const sections: Config = [
background: "#4AA99D",
foreground: "#fff",
id: "bom",
- icon: <LuSquareStack />,
courses: [],
},
{
@@ -216,7 +209,6 @@ export const sections: Config = [
background: "#488FB9",
foreground: "#fff",
id: "selling",
- icon: <LuCrown />,
courses: [],
},
{
@@ -224,7 +216,6 @@ export const sections: Config = [
background: "#78B2C4",
foreground: "#fff",
id: "selling",
- icon: <LuCrown />,
courses: [],
},
{
@@ -232,7 +223,6 @@ export const sections: Config = [
background: "#EFB655",
foreground: "#fff",
id: "buying",
- icon: <LuShoppingCart />,
courses: [],
},
{
@@ -240,7 +230,6 @@ export const sections: Config = [
background: "#EF8729",
foreground: "#fff",
id: "quality",
- icon: <LuShield />,
courses: [],
},
{
@@ -248,7 +237,6 @@ export const sections: Config = [
background: "#DD6444",
foreground: "#fff",
id: "developing",
- icon: <LuCode />,
courses: [],
},
{
@@ -256,7 +244,6 @@ export const sections: Config = [
background: "#8487C5", // "#AB7DB3",
foreground: "#fff",
id: "example-1",
- icon: <LuCrown />,
courses: [],
},
// {
@@ -264,7 +251,6 @@ export const sections: Config = [
// background: "#8487C5",
// foreground: "#fff",
// id: "example-2",
- // icon: <LuCrown />,
// courses: [],
// },
];
diff --git a/apps/university/app/hooks/index.ts b/apps/university/app/hooks/index.ts
index 408d24c5e3..f797aae629 100644
--- a/apps/university/app/hooks/index.ts
+++ b/apps/university/app/hooks/index.ts
@@ -4,6 +4,14 @@ import {
useUrlParams,
} from "@carbon/remix";
import { useMode } from "./useMode";
+import { useProgress } from "./useProgress";
import { useUser } from "./useUser";
-export { useMode, useOptimisticLocation, useRouteData, useUrlParams, useUser };
+export {
+ useMode,
+ useOptimisticLocation,
+ useProgress,
+ useRouteData,
+ useUrlParams,
+ useUser,
+};
diff --git a/apps/university/app/hooks/useProgress.tsx b/apps/university/app/hooks/useProgress.tsx
new file mode 100644
index 0000000000..ac4c2218aa
--- /dev/null
+++ b/apps/university/app/hooks/useProgress.tsx
@@ -0,0 +1,42 @@
+import { useRouteData } from "@carbon/remix";
+import { path } from "~/utils/path";
+
+interface LessonCompletion {
+ lessonId: string;
+ courseId: string;
+}
+
+interface ChallengeAttempt {
+ topicId: string;
+ courseId: string;
+ passed: boolean;
+}
+
+interface ProgressData {
+ lessonCompletions: LessonCompletion[];
+ challengeAttempts: ChallengeAttempt[];
+}
+
+function isProgressData(value: any): value is ProgressData {
+ return (
+ Array.isArray(value?.lessonCompletions) &&
+ Array.isArray(value?.challengeAttempts)
+ );
+}
+
+export function useProgress(): ProgressData {
+ const data = useRouteData<{
+ lessonCompletions: unknown;
+ challengeAttempts: unknown;
+ }>(path.to.root);
+
+ if (data && isProgressData(data)) {
+ return data;
+ }
+
+ // Return empty arrays if no data or user not authenticated
+ return {
+ lessonCompletions: [],
+ challengeAttempts: [],
+ };
+}
diff --git a/apps/university/app/root.tsx b/apps/university/app/root.tsx
index c5768d186a..f3e679a860 100644
--- a/apps/university/app/root.tsx
+++ b/apps/university/app/root.tsx
@@ -6,12 +6,14 @@ import {
import { validator } from "@carbon/form";
import {
Button,
+ cn,
Heading,
IconButton,
Progress,
toast,
Toaster,
TooltipProvider,
+ useDisclosure,
} from "@carbon/react";
import {
isRouteErrorResponse,
@@ -40,7 +42,7 @@ import Background from "~/styles/background.css?url";
import NProgress from "~/styles/nprogress.css?url";
import Tailwind from "~/styles/tailwind.css?url";
-import { LuFingerprint, LuMoon, LuSun } from "react-icons/lu";
+import { LuChevronDown, LuFingerprint, LuMoon, LuSun } from "react-icons/lu";
import AvatarMenu from "./components/AvatarMenu";
import { useMode } from "./hooks/useMode";
import { useOptionalUser } from "./hooks/useUser";
@@ -77,35 +79,45 @@ export async function loader({ request }: LoaderFunctionArgs) {
let session = await getOrRefreshAuthSession(request);
let user = null;
- let completedChallenges: {
+ let lessonCompletions: {
+ lessonId: string;
courseId: string;
+ }[] = [];
+ let challengeAttempts: {
topicId: string;
+ courseId: string;
+ passed: boolean;
}[] = [];
if (session) {
const client = getCarbon(session.accessToken);
- const [authUser, challengeAttempts] = await Promise.all([
+ const [authUser, completions, attempts] = await Promise.all([
client.from("user").select("*").eq("id", session.userId).single(),
+ client
+ .from("lessonCompletion")
+ .select("lessonId, courseId")
+ .eq("userId", session.userId),
client
.from("challengeAttempt")
- .select("courseId, topicId")
- .eq("userId", session.userId)
- .eq("passed", true),
+ .select("topicId, courseId, passed")
+ .eq("userId", session.userId),
]);
if (authUser.data) {
user = authUser.data;
}
- completedChallenges = challengeAttempts.data ?? [];
+ lessonCompletions = completions.data ?? [];
+ challengeAttempts = attempts.data ?? [];
}
const sessionFlash = await getSessionFlash(request);
return json(
{
- completedChallenges,
+ lessonCompletions,
+ challengeAttempts,
env: {
POSTHOG_API_HOST,
POSTHOG_PROJECT_PUBLIC_KEY,
@@ -179,7 +191,10 @@ export default function App() {
const env = loaderData?.env ?? {};
const result = loaderData?.result;
const theme = loaderData?.theme ?? "zinc";
- const completedChallenges = loaderData?.completedChallenges ?? [];
+
+ const challengeAttempts = loaderData?.challengeAttempts ?? [];
+
+ const disclosure = useDisclosure();
/* Toast Messages */
useEffect(() => {
@@ -211,8 +226,13 @@ export default function App() {
);
}, 0);
- const completionPercentage = Math.round(
- (completedChallenges.length / totalChallenges) * 100
+ const completionPercentage = Math.min(
+ Math.round(
+ (challengeAttempts.filter((attempt) => attempt.passed).length /
+ totalChallenges) *
+ 100
+ ),
+ 100
);
return (
@@ -240,7 +260,7 @@ export default function App() {
<NavLink to={path.to.about}>About</NavLink>
</Button>
{user ? (
- <AvatarMenu />
+ <AvatarMenu className="ml-2" />
) : (
<>
<Button
@@ -272,9 +292,95 @@ export default function App() {
</div>
</header>
{user && (
- <div className="w-full bg-primary dark:bg-[#6041d0]">
- <div className="max-w-5xl mx-auto px-3 py-4 flex flex-col gap-2 z-logo text-white w-full">
- <Progress value={completionPercentage} />
+ <div className="w-full bg-primary dark:bg-[#2f31ae]">
+ <div className="max-w-5xl mx-auto px-3 py-4 flex gap-8 z-logo items-center text-white w-full">
+ <span className="text-xl font-display">
+ {/* <span className="hidden lg:inline">Credential</span> */}
+ Progress
+ </span>
+ <div className="flex items-center justify-between gap-2 flex-1">
+ <Progress value={completionPercentage} />
+ <span className="text-xl font-display">
+ {completionPercentage}%
+ </span>
+ </div>
+ <Button
+ variant="ghost"
+ className="text-white hover:text-white/90"
+ rightIcon={
+ <LuChevronDown
+ className={`transition-transform duration-300 ${
+ disclosure.isOpen ? "rotate-180" : ""
+ }`}
+ />
+ }
+ onClick={disclosure.onToggle}
+ >
+ {disclosure.isOpen ? "Less" : "More"}
+ </Button>
+ </div>
+ <div
+ className={cn(
+ "w-full bg-black/20 transition-all duration-300 ease-in-out",
+ disclosure.isOpen
+ ? "h-auto opacity-100"
+ : "h-0 opacity-0 overflow-hidden"
+ )}
+ >
+ <div className="max-w-5xl mx-auto px-3 py-4 flex gap-8 z-logo items-center text-white w-full">
+ <div className="w-full bg-white/10 rounded-lg p-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
+ {sections.map((section) =>
+ section.courses.map((course) => {
+ const totalChallenges = course.topics.reduce(
+ (acc, topic) => acc + (topic.challenge ? 1 : 0),
+ 0
+ );
+
+ const completedChallenges = challengeAttempts.filter(
+ (attempt) =>
+ attempt.courseId === course.id && attempt.passed
+ ).length;
+
+ const percentage = Math.min(
+ Math.round((completedChallenges / totalChallenges) * 100),
+ 100
+ );
+
+ if (totalChallenges === 0) {
+ return null;
+ }
+
+ return (
+ <Link
+ to={path.to.course(section.id, course.id)}
+ key={course.id}
+ className={cn(
+ "cursor-pointer flex items-center gap-2",
+ percentage === 0 && "opacity-50"
+ )}
+ >
+ <div
+ className="size-8 rounded-lg flex items-center justify-center"
+ style={{
+ backgroundColor: section.background,
+ color: section.foreground,
+ }}
+ >
+ {course.icon}
+ </div>
+ <div className="flex-1 text-xs flex flex-col gap-2">
+ <div className="flex items-center justify-between gap-2">
+ <span className="font-medium">{course.name}</span>
+ <span>{percentage}%</span>
+ </div>
+ <Progress value={percentage} className="h-2" />
+ </div>
+ </Link>
+ );
+ })
+ )}
+ </div>
+ </div>
</div>
</div>
)}
diff --git a/apps/university/app/routes/about.tsx b/apps/university/app/routes/about.tsx
index 862ed4e1a1..0766bbc8bd 100644
--- a/apps/university/app/routes/about.tsx
+++ b/apps/university/app/routes/about.tsx
@@ -1,6 +1,6 @@
import { Button, Heading } from "@carbon/react";
import { Link } from "@remix-run/react";
-import { LuBookOpen, LuCirclePlay } from "react-icons/lu";
+import { LuCirclePlay } from "react-icons/lu";
import { Hero } from "~/components/Hero";
import { sections } from "~/config";
import { path } from "~/utils/path";
@@ -36,7 +36,10 @@ export default function AboutRoute() {
<h3 className="text-muted-foreground uppercase text-sm font-display leading-[140%] tracking-tighter">
How it works
</h3>
- <Heading size="h1" className="font-display max-w-2xl">
+ <Heading
+ size="h1"
+ className="font-display text-[#212578] dark:text-white max-w-2xl"
+ >
Register and Track Your Progress
</Heading>
<p className="text-muted-foreground text-balance text-left font-medium tracking-tighter text-lg">
@@ -84,10 +87,10 @@ export default function AboutRoute() {
<Button
size="lg"
variant="secondary"
- leftIcon={<LuBookOpen />}
+ leftIcon={<LuCirclePlay />}
asChild
>
- <Link to={path.to.about}>See how it works</Link>
+ <Link to={path.to.login}>Sign up to take challenges</Link>
</Button>
</div>
</div>
diff --git a/apps/university/app/routes/challenge+/$id.tsx b/apps/university/app/routes/challenge+/$id.tsx
index 455e647147..5d58ca7687 100644
--- a/apps/university/app/routes/challenge+/$id.tsx
+++ b/apps/university/app/routes/challenge+/$id.tsx
@@ -174,9 +174,9 @@ export default function ChallengeRoute() {
const getAnswerStyles = (status: string | null) => {
switch (status) {
case "correct":
- return "bg-green-100 border-green-500 text-green-800";
+ return "bg-emerald-100 border-emerald-500 text-emerald-800 dark:bg-emerald-900 dark:border-emerald-500 dark:text-emerald-500";
case "incorrect":
- return "bg-red-100 border-red-500 text-red-800";
+ return "bg-red-100 border-red-500 text-red-800 dark:bg-red-900 dark:border-red-500 dark:text-red-500";
default:
return "hover:bg-accent";
}
diff --git a/apps/university/app/routes/course+/$sectionId.$courseId.tsx b/apps/university/app/routes/course+/$sectionId.$courseId.tsx
index 04e268a4e1..4f75b646dc 100644
--- a/apps/university/app/routes/course+/$sectionId.$courseId.tsx
+++ b/apps/university/app/routes/course+/$sectionId.$courseId.tsx
@@ -1,56 +1,29 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
import { Button, cn, Progress, VStack } from "@carbon/react";
-import { json, Link, useLoaderData, useParams } from "@remix-run/react";
+import { json, Link, useParams } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
-import { LuCircleCheck, LuCirclePlay, LuRotateCcw } from "react-icons/lu";
+import {
+ LuCircleCheck,
+ LuCirclePlay,
+ LuFlag,
+ LuRotateCcw,
+} from "react-icons/lu";
import { sections } from "~/config";
+import { useProgress } from "~/hooks";
import { path } from "~/utils/path";
import { formatDuration } from "~/utils/video";
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
- const { client, userId } = await requirePermissions(request, {});
const { courseId } = params;
if (!courseId) {
throw new Error("Course ID is required");
}
- const [lessonCompletions, challengeAttempts] = await Promise.all([
- client
- .from("lessonCompletion")
- .select("lessonId")
- .eq("userId", userId)
- .eq("courseId", courseId),
- client
- .from("challengeAttempt")
- .select("topicId, passed")
- .eq("userId", userId)
- .eq("courseId", courseId),
- ]);
-
- const completedLessons =
- lessonCompletions.data?.map((completion) => completion.lessonId) ?? [];
-
- const completedChallenges = Array.from(
- new Set(
- challengeAttempts.data
- ?.filter((completion) => completion.passed)
- .map((completion) => completion.topicId) ?? []
- )
- );
-
- const attemptsByTopic =
- challengeAttempts.data?.reduce<Record<string, number>>((acc, attempt) => {
- acc[attempt.topicId] = (acc[attempt.topicId] ?? 0) + 1;
- return acc;
- }, {}) ?? {};
-
- return json({ completedLessons, completedChallenges, attemptsByTopic });
+ return json({});
};
export default function CourseRoute() {
- const { completedLessons, completedChallenges, attemptsByTopic } =
- useLoaderData<typeof loader>();
+ const { lessonCompletions, challengeAttempts } = useProgress();
const { sectionId, courseId } = useParams();
const section = sections.find((section) => section.id === sectionId);
@@ -72,8 +45,29 @@ export default function CourseRoute() {
throw new Error("Course not found");
}
- const completionPercentage = Math.round(
- (completedChallenges.length / totalChallenges) * 100
+ // Filter data for current course
+ const completedLessons = lessonCompletions
+ .filter((completion) => completion.courseId === course.id)
+ .map((completion) => completion.lessonId);
+
+ const completedChallenges = Array.from(
+ new Set(
+ challengeAttempts
+ .filter((attempt) => attempt.courseId === course.id && attempt.passed)
+ .map((attempt) => attempt.topicId)
+ )
+ );
+
+ const attemptsByTopic = challengeAttempts
+ .filter((attempt) => attempt.courseId === course.id)
+ .reduce<Record<string, number>>((acc, attempt) => {
+ acc[attempt.topicId] = (acc[attempt.topicId] ?? 0) + 1;
+ return acc;
+ }, {});
+
+ const completionPercentage = Math.min(
+ Math.round((completedChallenges.length / totalChallenges) * 100),
+ 100
);
return (
@@ -96,13 +90,13 @@ export default function CourseRoute() {
<div className="flex flex-col gap-4">
<div className="flex items-start gap-4">
<div
- className="flex-shrink-0 size-12 text-2xl p-3 rounded-full"
+ className="flex-shrink-0 size-12 text-2xl p-3 rounded-lg"
style={{
backgroundColor: section?.background,
color: section?.foreground,
}}
>
- {section?.icon}
+ {course.icon}
</div>
<div className="flex flex-col">
<h1 className="uppercase text-[10px] font-display font-bold text-muted-foreground">
@@ -209,7 +203,9 @@ export default function CourseRoute() {
) : (
<Button
variant="secondary"
- leftIcon={<LuRotateCcw className="size-4" />}
+ leftIcon={
+ isChallengeAttempted ? <LuRotateCcw /> : <LuFlag />
+ }
asChild
>
<Link to={path.to.challenge(topic.id)}>
@@ -217,7 +213,8 @@ export default function CourseRoute() {
<span>
Retake Topic Challenge{" "}
<span className="text-xs text-muted-foreground italic">
- {challengeAttempts} attempt made
+ {challengeAttempts} attempt
+ {challengeAttempts === 1 ? "" : "s"} made
</span>
</span>
) : (
diff --git a/apps/university/app/routes/lesson+/$id.tsx b/apps/university/app/routes/lesson+/$id.tsx
index af55d9924f..ae65c38e3e 100644
--- a/apps/university/app/routes/lesson+/$id.tsx
+++ b/apps/university/app/routes/lesson+/$id.tsx
@@ -1,12 +1,7 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
+import { getCarbon } from "@carbon/auth";
+import { getOrRefreshAuthSession } from "@carbon/auth/session.server";
import { Button } from "@carbon/react";
-import {
- json,
- Link,
- useFetcher,
- useLoaderData,
- useParams,
-} from "@remix-run/react";
+import { json, Link, useFetcher, useParams } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import {
LuCheck,
@@ -17,6 +12,7 @@ import {
LuFlag,
} from "react-icons/lu";
import Share from "~/components/Share";
+import { useProgress } from "~/hooks";
import { path } from "~/utils/path";
import {
formatDuration,
@@ -26,7 +22,6 @@ import {
} from "~/utils/video";
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
- const { client, userId } = await requirePermissions(request, {});
const { id: lessonId } = params;
if (!lessonId) {
@@ -38,41 +33,10 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
throw new Error("Lesson not found");
}
- const { course, topic } = context;
-
- const [lessonCompletions, challengeAttempts] = await Promise.all([
- client
- .from("lessonCompletion")
- .select("lessonId")
- .eq("userId", userId)
- .eq("courseId", course.id),
- client
- .from("challengeAttempt")
- .select("topicId, passed")
- .eq("userId", userId)
- .eq("topicId", topic.id),
- ]);
-
- const completedLessons =
- lessonCompletions.data?.map((completion) => completion.lessonId) ?? [];
- const completedChallenges =
- challengeAttempts.data
- ?.filter((completion) => completion.passed)
- .map((completion) => completion.topicId) ?? [];
- const attemptsByTopic =
- challengeAttempts.data?.reduce<Record<string, number>>(
- (acc, completion) => {
- acc[completion.topicId] = (acc[completion.topicId] ?? 0) + 1;
- return acc;
- },
- {}
- ) ?? {};
-
- return json({ completedLessons, completedChallenges, attemptsByTopic });
+ return json({});
};
export const action = async ({ request, params }: ActionFunctionArgs) => {
- const { client, userId } = await requirePermissions(request, {});
const { id: lessonId } = params;
if (!lessonId) {
@@ -89,10 +53,21 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
{ status: 404 }
);
}
+
+ // Check if user is authenticated
+ const session = await getOrRefreshAuthSession(request);
+ if (!session) {
+ return json(
+ { success: false, message: "Authentication required" },
+ { status: 401 }
+ );
+ }
+
const { course } = context;
+ const client = getCarbon(session.accessToken);
const insert = await client.from("lessonCompletion").insert({
- userId,
+ userId: session.userId,
courseId: course.id,
lessonId,
});
@@ -108,8 +83,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
};
export default function LessonRoute() {
- const { completedLessons, completedChallenges, attemptsByTopic } =
- useLoaderData<typeof loader>();
+ const { lessonCompletions, challengeAttempts } = useProgress();
const { id } = useParams();
if (!id) {
@@ -126,10 +100,27 @@ export default function LessonRoute() {
const nextLesson = getNextLesson(id);
const previousLesson = getPreviousLesson(id);
const hasChallenge = topic.challenge && topic.challenge.length > 0;
+
+ // Filter data for current course/topic
+ const completedLessons = lessonCompletions
+ .filter((completion) => completion.courseId === course.id)
+ .map((completion) => completion.lessonId);
+
+ const completedChallenges = challengeAttempts
+ .filter((attempt) => attempt.courseId === course.id && attempt.passed)
+ .map((attempt) => attempt.topicId);
+
+ const attemptsByTopic = challengeAttempts
+ .filter((attempt) => attempt.courseId === course.id)
+ .reduce<Record<string, number>>((acc, attempt) => {
+ acc[attempt.topicId] = (acc[attempt.topicId] ?? 0) + 1;
+ return acc;
+ }, {});
+
const isChallengeCompleted =
hasChallenge && completedChallenges.includes(topic.id);
const isChallengeAttempted = hasChallenge && attemptsByTopic[topic.id];
- const challengeAttempts = attemptsByTopic[topic.id] ?? 0;
+ const challengeAttemptCount = attemptsByTopic[topic.id] ?? 0;
const fetcher = useFetcher<typeof action>();
@@ -209,14 +200,12 @@ export default function LessonRoute() {
<div className="flex flex-col gap-4">
<div className="flex items-start gap-4">
<div
- className="flex-shrink-0 size-12 text-2xl p-3 rounded-full border"
+ className="flex-shrink-0 size-12 text-2xl p-3 rounded-lg bg-black/20"
style={{
- backgroundColor: section?.background,
- borderColor: section?.foreground,
color: section?.foreground,
}}
>
- {section?.icon}
+ {course.icon}
</div>
<div className="flex flex-col">
<h1 className="uppercase text-[10px] font-display font-bold">
@@ -328,8 +317,8 @@ export default function LessonRoute() {
>
<Link to={path.to.challenge(topic.id)}>
{isChallengeAttempted
- ? `Retake Topic Challenge (${challengeAttempts} attempt${
- challengeAttempts === 1 ? "" : "s"
+ ? `Retake Topic Challenge (${challengeAttemptCount} attempt${
+ challengeAttemptCount === 1 ? "" : "s"
})`
: "Take Topic Challenge"}
</Link>
diff --git a/apps/university/app/services/theme.server.ts b/apps/university/app/services/theme.server.ts
index 04a5b534c9..b228b24c91 100644
--- a/apps/university/app/services/theme.server.ts
+++ b/apps/university/app/services/theme.server.ts
@@ -6,7 +6,7 @@ const themes = [
"neutral",
"red",
"rose",
- "green",
+ "emerald",
"blue",
"yellow",
"orange",