Skip to content

Commit eb69c1b

Browse files
authored
Merge pull request #62 from teacoder-team/dev
Dev
2 parents de38ad7 + 20df386 commit eb69c1b

22 files changed

Lines changed: 157 additions & 154 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
install:
11-
name: 📦 Install dependencies
11+
name: Install dependencies
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout repository
@@ -23,7 +23,7 @@ jobs:
2323
run: bun install
2424

2525
build:
26-
name: 🏗️ Build Next.js
26+
name: Build Next.js
2727
runs-on: ubuntu-latest
2828
needs: install
2929
env:
@@ -45,7 +45,7 @@ jobs:
4545
run: bun run build
4646

4747
deploy:
48-
name: 🚀 Deploy to Dokploy
48+
name: Deploy to Dokploy
4949
runs-on: ubuntu-latest
5050
needs: build
5151
env:
@@ -63,7 +63,7 @@ jobs:
6363

6464
- name: Deploy to Dokploy
6565
run: |
66-
echo "🚀 Deploying frontend to Dokploy..."
66+
echo "Deploying to Dokploy..."
6767
curl -X POST "$DOKPLOY_URL/api/application.deploy" \
6868
-H "accept: application/json" \
6969
-H "Content-Type: application/json" \

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ RUN bun --bun run build
1616

1717
CMD bun --bun run start
1818

19-
EXPOSE 14701
19+
EXPOSE 14701

README.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

bun.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"clsx": "^2.1.1",
4747
"dotenv": "^16.4.7",
4848
"framer-motion": "^12.4.2",
49-
"geist": "^1.3.1",
5049
"input-otp": "^1.4.2",
5150
"js-cookie": "^3.0.5",
5251
"lucide-react": "^0.483.0",
@@ -72,6 +71,7 @@
7271
"@types/node": "^20",
7372
"@types/react": "19.2.7",
7473
"@types/react-dom": "19.2.3",
74+
"baseline-browser-mapping": "^2.9.19",
7575
"orval": "7.4.1",
7676
"postcss": "^8",
7777
"prettier": "^3.4.2",

src/api/requests/lesson.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { CreateLessonRequest, LessonResponse } from '../generated'
22
import { api, instance } from '../instance'
33

4-
export const getLesson = async (slug: string) =>
4+
export const getLesson = async (id: string) =>
55
await api
6-
.get<LessonResponse>(`/lessons/${slug}`)
6+
.get<LessonResponse>(`/lessons/${id}`)
77
.then(response => response.data)
88

99
export const getCompletedLessons = async (courseId: string) =>

src/app/layout.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { GeistSans } from 'geist/font/sans'
21
import type { Metadata } from 'next'
2+
import { Geist } from 'next/font/google'
33
import type { ReactNode } from 'react'
44

55
import { Toaster } from '../components/shared/sonner'
66
import { APP_CONFIG, SEO } from '../constants'
77
import { YandexMetrikaScript } from '../lib/analytics/script-providers'
8+
import { cn } from '../lib/utils'
89
import {
910
AnalyticsProvider,
1011
BanChecker,
@@ -15,6 +16,11 @@ import {
1516

1617
import '@/src/styles/globals.css'
1718

19+
const font = Geist({
20+
subsets: ['cyrillic', 'latin'],
21+
variable: '--font-ibm-plex-sans'
22+
})
23+
1824
export const metadata: Metadata = {
1925
title: {
2026
absolute: SEO.name,
@@ -71,8 +77,8 @@ export const metadata: Metadata = {
7177

7278
export default function RootLayout({ children }: { children: ReactNode }) {
7379
return (
74-
<html className={GeistSans.variable} lang='ru' suppressHydrationWarning>
75-
<body className='flex h-full w-full flex-col font-sans'>
80+
<html lang='ru' suppressHydrationWarning>
81+
<body className={cn('flex h-full w-full flex-col', font.variable)}>
7682
<TanstackQueryProvider>
7783
<AnalyticsProvider>
7884
<FingerprintProvider>
Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,78 @@ import { LessonSidebar } from '@/src/components/lesson/lesson-sidebar'
1212
export const revalidate = 60
1313

1414
async function getUserProgress(courseId: string) {
15-
const cookie = await cookies()
16-
17-
const token = cookie.get('token')?.value
18-
19-
const { data: progressCount } = await api.get<number>(
20-
`/progress/${courseId}`,
21-
{
22-
headers: {
23-
'X-Session-Token': token ?? ''
24-
}
25-
}
26-
)
27-
28-
const { data: completedLessons } = await api.get<string[]>(
29-
`/lessons/${courseId}/progress`,
30-
{
31-
headers: {
32-
'X-Session-Token': token ?? ''
33-
}
34-
}
35-
)
15+
const cookieStore = await cookies()
16+
const token = cookieStore.get('token')?.value
17+
18+
const [{ data: progressCount }, { data: completedLessons }] =
19+
await Promise.all([
20+
api.get<number>(`/progress/${courseId}`, {
21+
headers: {
22+
'X-Session-Token': token ?? ''
23+
}
24+
}),
25+
api.get<string[]>(`/lessons/${courseId}/progress`, {
26+
headers: {
27+
'X-Session-Token': token ?? ''
28+
}
29+
})
30+
])
3631

3732
return { progressCount, completedLessons }
3833
}
3934

4035
export async function generateMetadata({
4136
params
4237
}: {
43-
params: Promise<{ slug: string }>
38+
params: { id: string }
4439
}): Promise<Metadata> {
45-
const { slug } = await params
40+
const { id } = await params
4641

47-
const lesson = await getLesson(slug).catch(() => {
48-
notFound()
49-
})
42+
try {
43+
const lesson = await getLesson(id)
44+
45+
if (!lesson)
46+
return {
47+
title: 'Урок не найден'
48+
}
5049

51-
return {
52-
title: lesson.title,
53-
description: lesson.description
50+
return {
51+
title: lesson.title,
52+
description: lesson.description ?? ''
53+
}
54+
} catch (error) {
55+
console.error('[generateMetadata] getLesson failed', {
56+
id,
57+
error
58+
})
59+
60+
return {
61+
title: 'Урок'
62+
}
5463
}
5564
}
5665

5766
export default async function LessonPage({
5867
params
5968
}: {
60-
params: Promise<{ slug: string }>
69+
params: Promise<{ id: string }>
6170
}) {
62-
const { slug } = await params
63-
64-
const lesson = await getLesson(slug).catch(error => {
65-
notFound()
71+
const { id } = await params
72+
73+
const lesson = await getLesson(id).catch(error => {
74+
console.error('[LessonPage] getLesson failed', {
75+
id,
76+
error
77+
})
78+
return null
6679
})
6780

68-
const lessons = await getCourseLessons(lesson.course.id)
81+
if (!lesson) notFound()
6982

70-
const { progressCount, completedLessons } = await getUserProgress(
71-
lesson.course.id
72-
)
83+
const [lessons, { progressCount, completedLessons }] = await Promise.all([
84+
getCourseLessons(lesson.course.id),
85+
getUserProgress(lesson.course.id)
86+
])
7387

7488
return (
7589
<div className='h-full'>

src/components/account/progress/courses-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function CoursesTab() {
7070
>
7171
<Link
7272
href={ROUTES.COURSES.LESSON(
73-
course.lastLesson?.slug
73+
course.lastLesson?.id
7474
)}
7575
>
7676
Продолжить обучение

src/components/course/course-sidebar.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ export function CourseSidebar({
5353
asChild
5454
>
5555
<Link
56-
href={ROUTES.COURSES.LESSON(
57-
nextLesson.slug
58-
)}
56+
href={ROUTES.COURSES.LESSON(nextLesson.id)}
5957
>
6058
{lastIndex + 1 === lessons.length
6159
? 'Смотреть курс'
@@ -78,9 +76,7 @@ export function CourseSidebar({
7876
asChild
7977
>
8078
<Link
81-
href={ROUTES.COURSES.LESSON(
82-
lessons[0].slug
83-
)}
79+
href={ROUTES.COURSES.LESSON(lessons[0].id)}
8480
>
8581
Начать просмотр
8682
</Link>

0 commit comments

Comments
 (0)