feat: automatically detect language on server and translate UI (#530)
* feat: detect language on the server and translate page * translate auth pages * PR reviews
This commit is contained in:
@@ -9,6 +9,23 @@ async function getGenericData(orgSlug: string): Promise<{
|
||||
orgHasAvatarUrl: boolean;
|
||||
courseData: any;
|
||||
}> {
|
||||
const { data: publishedCourse } = await supabase
|
||||
.from('course')
|
||||
.select(
|
||||
`
|
||||
is_published,
|
||||
group:group_id!inner(
|
||||
organization!inner(
|
||||
siteName
|
||||
)
|
||||
)
|
||||
`
|
||||
)
|
||||
.eq('is_published', true)
|
||||
.eq('group.organization.siteName', orgSlug)
|
||||
.limit(1)
|
||||
.returns<{ is_published: boolean }>();
|
||||
|
||||
const { data } = await supabase
|
||||
.from('course')
|
||||
.select(
|
||||
@@ -23,14 +40,13 @@ async function getGenericData(orgSlug: string): Promise<{
|
||||
)
|
||||
`
|
||||
)
|
||||
.eq('group.organization.siteName', orgSlug);
|
||||
.eq('group.organization.siteName', orgSlug)
|
||||
.limit(1);
|
||||
|
||||
const result = data || [];
|
||||
|
||||
console.log('courseData', result);
|
||||
|
||||
return {
|
||||
isCoursePublished: result.some((c) => c.is_published === true),
|
||||
isCoursePublished: publishedCourse?.is_published === true,
|
||||
isCourseCreated: result.length > 0,
|
||||
orgHasAvatarUrl: !!get(result[0], 'group.organization.avatar_url', ''),
|
||||
courseData: result
|
||||
@@ -54,7 +70,8 @@ async function getIsLessonCreated(
|
||||
)
|
||||
`
|
||||
)
|
||||
.eq('course.group.organization.siteName', orgSlug);
|
||||
.eq('course.group.organization.siteName', orgSlug)
|
||||
.limit(1);
|
||||
console.log('lessonsData', data);
|
||||
|
||||
return {
|
||||
@@ -80,7 +97,8 @@ async function getIsExerciseCreated(orgSlug: string): Promise<boolean> {
|
||||
)
|
||||
`
|
||||
)
|
||||
.eq('lesson.course.group.organization.siteName', orgSlug);
|
||||
.eq('lesson.course.group.organization.siteName', orgSlug)
|
||||
.limit(1);
|
||||
|
||||
return Array.isArray(data) ? data?.length > 0 : false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user