Skip to content

Commit 3dab7dd

Browse files
Merge pull request #162 from guillermoscript/161-chat-page
Refactor chat component translations and add localized titles to ExamPrepChat and FreeChat layouts
2 parents d78ec2a + 9219cf1 commit 3dab7dd

File tree

18 files changed

+258
-148
lines changed

18 files changed

+258
-148
lines changed

app/[locale]/dashboard/student/chat/[chatId]/exam-prep/error.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useEffect } from 'react'
44

5+
import { useScopedI18n } from '@/app/locales/client'
56
import GenericError from '@/components/GenericError'
67

78
export default function Error ({
@@ -11,6 +12,8 @@ export default function Error ({
1112
error: Error & { digest?: string }
1213
reset: () => void
1314
}) {
15+
const t = useScopedI18n('GenericError')
16+
1417
useEffect(() => {
1518
// Log the error to an error reporting service
1619
console.error(error)
@@ -19,7 +22,7 @@ export default function Error ({
1922
return (
2023
<GenericError
2124
retry={reset}
22-
title="Oh no! An error occurred loading the chat."
25+
title={t('title')}
2326
description={error.message}
2427
/>
2528
)

app/[locale]/dashboard/student/chat/[chatId]/exam-prep/layout.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AI, getUIStateFromAIState } from '@/actions/dashboard/AI/ExamPreparationActions'
2+
import { getScopedI18n } from '@/app/locales/server'
23
import BreadcrumbComponent from '@/components/dashboards/student/course/BreadcrumbComponent'
34
import { createClient } from '@/utils/supabase/server'
45

@@ -97,13 +98,15 @@ export default async function ExamnChatIdPageLayout ({
9798
})
9899
})
99100

101+
const t = await getScopedI18n('BreadcrumbComponent')
102+
100103
return (
101104
<>
102105
<BreadcrumbComponent
103106
links={[
104-
{ href: '/dashboard', label: 'Dashboard' },
105-
{ href: '/dashboard/student', label: 'Student' },
106-
{ href: '/dashboard/student/chat', label: 'Chat' },
107+
{ href: '/dashboard', label: t('dashboard') },
108+
{ href: '/dashboard/student', label: t('student') },
109+
{ href: '/dashboard/student/chat', label: t('chat') },
107110
{ href: `/dashboard/student/chat/${params.chatId}`, label: messagesData.data.title.slice(0, 40) + '...' }
108111
]}
109112
/>

app/[locale]/dashboard/student/chat/[chatId]/free-chat/error.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useEffect } from 'react'
44

5+
import { useScopedI18n } from '@/app/locales/client'
56
import GenericError from '@/components/GenericError'
67

78
export default function Error ({
@@ -11,6 +12,8 @@ export default function Error ({
1112
error: Error & { digest?: string }
1213
reset: () => void
1314
}) {
15+
const t = useScopedI18n('GenericError')
16+
1417
useEffect(() => {
1518
// Log the error to an error reporting service
1619
console.error(error)
@@ -19,7 +22,7 @@ export default function Error ({
1922
return (
2023
<GenericError
2124
retry={reset}
22-
title="Oh no! An error occurred loading the chat."
25+
title={t('title')}
2326
description={error.message}
2427
/>
2528
)

app/[locale]/dashboard/student/chat/[chatId]/free-chat/layout.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FreeChatAI, getUIStateFromFreeChatAIState } from '@/actions/dashboard/AI/FreeChatPreparation'
2+
import { getScopedI18n } from '@/app/locales/server'
23
import BreadcrumbComponent from '@/components/dashboards/student/course/BreadcrumbComponent'
34
import { createClient } from '@/utils/supabase/server'
45

@@ -97,13 +98,15 @@ export default async function ExamnChatIdPageLayout ({
9798
})
9899
})
99100

101+
const t = await getScopedI18n('BreadcrumbComponent')
102+
100103
return (
101104
<>
102105
<BreadcrumbComponent
103106
links={[
104-
{ href: '/dashboard', label: 'Dashboard' },
105-
{ href: '/dashboard/student', label: 'Student' },
106-
{ href: '/dashboard/student/chat', label: 'Chat' },
107+
{ href: '/dashboard', label: t('dashboard') },
108+
{ href: '/dashboard/student', label: t('student') },
109+
{ href: '/dashboard/student/chat', label: t('chat') },
107110
{ href: `/dashboard/student/chat/${params.chatId}`, label: messagesData.data.title.slice(0, 40) + '...' }
108111
]}
109112
/>

app/[locale]/dashboard/student/chat/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default async function CoursesLayout({
3838
return (
3939
<div className="lg:grid flex flex-col min-h-screen w-full lg:grid-cols-[280px_1fr] gap-6">
4040
<StudentChatSidebar userRole="student" />
41-
<div className="flex flex-col">{children}</div>
41+
<div className="flex flex-col gap-4">{children}</div>
4242
</div>
4343
)
4444
}

app/[locale]/dashboard/student/chat/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FreeChatAI } from '@/actions/dashboard/AI/FreeChatPreparation'
2+
import { getScopedI18n } from '@/app/locales/server'
23
import ExamLink from '@/components/dashboards/chat/ExamLink'
34
import FreeChat from '@/components/dashboards/chat/FreeChat'
45
import FreeChatSetup from '@/components/dashboards/chat/tour/FreeChatSetup'
@@ -8,18 +9,19 @@ export const dynamic = 'force-dynamic'
89
export const maxDuration = 30
910

1011
export default async function ChatPage() {
12+
const t = await getScopedI18n('BreadcrumbComponent')
13+
1114
return (
1215
<>
1316
<BreadcrumbComponent
1417
links={[
15-
{ href: '/dashboard', label: 'Dashboard' },
16-
{ href: '/dashboard/student', label: 'Student' },
17-
{ href: '/dashboard/student/chat', label: 'Chat' },
18+
{ href: '/dashboard', label: t('dashboard') },
19+
{ href: '/dashboard/student', label: t('student') },
20+
{ href: '/dashboard/student/chat', label: t('chat') },
1821
]}
1922
/>
2023
<div className="flex flex-col gap-4 w-full mb-8">
2124
<div className="flex flex-wrap gap-4 w-full items-center">
22-
<h1 className="text-2xl font-semibold">Select a chat or start a new one</h1>
2325
<FreeChatSetup />
2426
</div>
2527
<div className="flex flex-wrap gap-4 w-full">

app/[locale]/dashboard/student/error.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useEffect } from 'react'
44

5+
import { useScopedI18n } from '@/app/locales/client'
56
import GenericError from '@/components/GenericError'
67

78
export default function Error ({
@@ -11,6 +12,8 @@ export default function Error ({
1112
error: Error & { digest?: string }
1213
reset: () => void
1314
}) {
15+
const t = useScopedI18n('GenericError')
16+
1417
useEffect(() => {
1518
// Log the error to an error reporting service
1619
console.error(error)
@@ -19,7 +22,7 @@ export default function Error ({
1922
return (
2023
<GenericError
2124
retry={reset}
22-
title="Oh no! An error occurred"
25+
title={t('title')}
2326
description={error.message}
2427
/>
2528
)

app/locales/en/components.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
lesson: 'Lessons',
1818
exam: 'Exams',
1919
review: 'Reviews',
20+
chat: 'Chat',
2021
},
2122
RecentlyViewed: {
2223
title: 'Recently Viewed',
@@ -243,5 +244,46 @@ If you have doubts, try saying: "Could you give me a fake scenario to practice m
243244
SubscribeNow: {
244245
title: 'Subscribe Now!',
245246
description: 'To continue using the service, please be sure to subscribe to our early access program.',
247+
},
248+
FreeChatSetup: {
249+
freeChat: {
250+
title: 'Free Chat',
251+
description: 'This is where you can chat with the AI assistant. You can ask questions, get suggestions, and more.',
252+
},
253+
examPrep: {
254+
title: 'Exam Preparation',
255+
description: 'This part is where you can create and view all of your exam preparation messages. This is a different chat type from the free chat, focused on exam preparation.',
256+
},
257+
quizMe: {
258+
title: 'Quiz Me',
259+
description: 'This is where you can prepare for your exams, the AI will create Forms for you to fill out and get feedback on your answers.',
260+
},
261+
suggestions: {
262+
title: 'Suggestions',
263+
description: 'This is where you can get suggestions on what to do next. The AI will guide you on what to do next.',
264+
},
265+
editor: {
266+
title: 'Editor',
267+
description: 'This is where you can write code, markdown, or any other text. The AI will help you with your code, markdown, or text.',
268+
},
269+
title: 'Guided Tutorial',
270+
description: 'If you want to know more about the free chat, click the button above to start the tour.',
271+
},
272+
ExamLink: {
273+
title: 'Quiz Me',
274+
description: 'This is where you can prepare for your exams, the AI will create Forms for you to fill out and get feedback on your answers.',
275+
},
276+
EmptyChatState: {
277+
title: 'Ask me anything, I\'m here to help!',
278+
},
279+
SearchChats: {
280+
input: 'Type to search your chats',
281+
empty: 'No results found.',
282+
freeChat: 'Free Chat',
283+
examPrep: 'Exam Prep',
284+
},
285+
StudentCreateNewChat: {
286+
title: 'Untitled Chat',
287+
newChat: 'Nuevo chat',
246288
}
247289
} as const

app/locales/en/views.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,8 @@ export default {
215215
description: "You've been placed in a queue due to high traffic. We'll get you back to the site shortly.",
216216
waitTime: 'Estimated wait time',
217217
waitDescription: 'We use a queue system to ensure fair access for all users during peak times. Thank you for your patience!',
218+
},
219+
chatPage: {
220+
title: 'Select a chat or start a new one',
218221
}
219222
} as const

app/locales/es/components.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
lesson: 'Lecciones',
1818
exam: 'Exámenes',
1919
review: 'Reseñas',
20+
chat: 'Chat',
2021
},
2122
RecentlyViewed: {
2223
title: 'Visto recientemente',
@@ -239,5 +240,50 @@ Si tienes dudas, intenta diciendo: "Could you give me a fake scenario to practic
239240
SubscribeNow: {
240241
title: '¡Suscríbete ahora!',
241242
description: 'Para seguir utilizando el servicio, asegúrate de suscribirte a nuestro programa de acceso anticipado.',
243+
},
244+
FreeChatSetup: {
245+
freeChat: {
246+
title: 'Chat libre',
247+
description: 'Aquí es donde puedes chatear con el asistente de IA. Puedes hacer preguntas, obtener sugerencias y más.',
248+
},
249+
examPrep: {
250+
title: 'Preparación para el examen',
251+
description: 'Aquí es donde puedes prepararte para tus exámenes, la IA creará formularios para que los completes y obtengas comentarios sobre tus respuestas.',
252+
},
253+
quizMe: {
254+
title: 'Evaluame',
255+
description: 'Aquí es donde puedes hacer preguntas y obtener sugerencias sobre qué hacer a continuación. La IA te guiará sobre qué hacer a continuación.',
256+
},
257+
suggestions: {
258+
title: 'Sugerencias',
259+
description: 'Aquí es donde puedes obtener sugerencias sobre qué hacer a continuación. La IA te guiará sobre qué hacer a continuación.',
260+
},
261+
editor: {
262+
title: 'Editor',
263+
description: 'Aquí es donde puedes escribir código, markdown o cualquier otro texto. La IA te ayudará con tu código, markdown o texto.',
264+
},
265+
title: 'Tutorial guiado',
266+
description: 'Si deseas saber más sobre el chat libre, haz clic en el botón de arriba para comenzar el recorrido.',
267+
},
268+
ExamLink: {
269+
title: 'Exámenes',
270+
description: 'Aquí es donde puedes ver tus exámenes y comenzar a hacerlos. La IA te dará comentarios sobre tus respuestas.',
271+
},
272+
EmptyChatState: {
273+
title: 'Pregúntame cualquier cosa, ¡estoy aquí para ayudarte!',
274+
},
275+
GenericError: {
276+
tile: '¡Oh no! Ocurrió un error',
277+
description: 'Ocurrió un error al cargar la página. Por favor, intenta nuevamente. Si el problema persiste, contacta al soporte.',
278+
},
279+
SearchChats: {
280+
input: 'Escribe aquí para buscar tus chats...',
281+
empty: 'No se encontraron resultados',
282+
freeChat: 'Chat libre',
283+
examPrep: 'Preparación para el examen',
284+
},
285+
StudentCreateNewChat: {
286+
title: 'Chat sin titulo',
287+
newChat: 'Nuevo chat',
242288
}
243289
} as const

0 commit comments

Comments
 (0)