Skip to content

Commit dfdc8e0

Browse files
committed
feat: new lessons page with table and new nav options
1 parent 9e0e4e6 commit dfdc8e0

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

apps/admin/src/components/Header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ const bttf = localFont({ src: "../../public/fonts/BTTF.ttf" });
1212

1313
const topbarNavMenus: NavItem[] = [
1414
{
15-
name: "Home",
16-
href: "/",
15+
name: "Tracks",
16+
href: "/tracks",
1717
icon: "vector",
1818
},
1919
{
20-
name: "Create New Track",
21-
href: "/tracks/create",
20+
name: "Lessons",
21+
href: "/lessons",
2222
icon: "clarity_blocks",
2323
},
2424
{
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { useRouter } from "next/router";
2+
import React from "react";
3+
import {
4+
Button,
5+
Table,
6+
TableBody,
7+
TableCaption,
8+
TableCell,
9+
TableHead,
10+
TableHeader,
11+
TableRow,
12+
} from "ui";
13+
14+
import { api } from "@/utils/api";
15+
16+
function AdminLessonsPage() {
17+
const { data: lessons } = api.lessons.getAll.useQuery();
18+
19+
const router = useRouter();
20+
21+
const handleEditLessonBtnClick = async (lessonId: string) => {
22+
await router.push(`/lessons/${lessonId}/edit`);
23+
};
24+
25+
const handleCreateNewBtnClick = async () => {
26+
await router.push("lessons/create");
27+
};
28+
29+
return (
30+
<main className="container mx-auto py-16">
31+
<Button onClick={handleCreateNewBtnClick}>Create New Lesson</Button>
32+
<Table className="text-white">
33+
<TableCaption>Full list of availables lessons.</TableCaption>
34+
<TableHeader>
35+
<TableRow>
36+
<TableHead className="w-[100px]">Id</TableHead>
37+
<TableHead>Lesson Title</TableHead>
38+
<TableHead>Description</TableHead>
39+
<TableHead>Lesson Path</TableHead>
40+
<TableHead>Quiz filename</TableHead>
41+
<TableHead>Order N°</TableHead>
42+
<TableHead className="text-right">Actions</TableHead>
43+
</TableRow>
44+
</TableHeader>
45+
<TableBody>
46+
{lessons?.map((lesson) => (
47+
<TableRow key={lesson.id}>
48+
<TableCell className="font-medium">{lesson.id}</TableCell>
49+
<TableCell>{lesson.lessonTitle}</TableCell>
50+
<TableCell>{lesson.lessonDescription}</TableCell>
51+
<TableCell>{lesson.lessonPath}</TableCell>
52+
<TableCell>{lesson.quizFileName}</TableCell>
53+
<TableCell>{lesson.order}</TableCell>
54+
<TableCell className="text-right">
55+
<Button variant="default" onClick={async () => handleEditLessonBtnClick(lesson.id)}>
56+
Edit
57+
</Button>
58+
</TableCell>
59+
</TableRow>
60+
))}
61+
</TableBody>
62+
</Table>
63+
</main>
64+
);
65+
}
66+
67+
export default AdminLessonsPage;

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Use postgres/example user/password credentials
2+
version: "3.1"
3+
services:
4+
db:
5+
image: postgres
6+
ports:
7+
- 5432:5432
8+
environment:
9+
POSTGRES_USER: postgres
10+
POSTGRES_PASSWORD: postgres
11+
POSTGRES_DB: myapp-db
12+
restart: unless-stopped

0 commit comments

Comments
 (0)