Compare commits
2 Commits
c1cb1f22db
...
451cbc3946
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
451cbc3946 | ||
|
|
2a3b0632a4 |
@ -47,7 +47,7 @@ Current request is compiling and may take a few moments.
|
|||||||
}, [compilationStatus]);
|
}, [compilationStatus]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'dev_stage') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
|
|
||||||
setBadgeStyles(prev => ({
|
setBadgeStyles(prev => ({
|
||||||
|
|||||||
@ -10,7 +10,7 @@ type Props = {
|
|||||||
isBorderless?: boolean
|
isBorderless?: boolean
|
||||||
isTransparent?: boolean
|
isTransparent?: boolean
|
||||||
hasTextareaHeight?: boolean
|
hasTextareaHeight?: boolean
|
||||||
children: ReactNode
|
children?: ReactNode
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
borderButtom?: boolean
|
borderButtom?: boolean
|
||||||
diversity?: boolean
|
diversity?: boolean
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React, { ReactNode } from 'react'
|
|||||||
import { containerMaxW } from '../config'
|
import { containerMaxW } from '../config'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: ReactNode
|
children?: ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SectionMain({ children }: Props) {
|
export default function SectionMain({ children }: Props) {
|
||||||
|
|||||||
@ -192,7 +192,7 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
|
|||||||
stepsEnabled={stepsEnabled}
|
stepsEnabled={stepsEnabled}
|
||||||
onExit={handleExit}
|
onExit={handleExit}
|
||||||
/>
|
/>
|
||||||
{(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'dev_stage') && <DevModeBadge />}
|
{(process.env.NODE_ENV === 'development') && <DevModeBadge />}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|||||||
@ -12,8 +12,12 @@ import Link from "next/link";
|
|||||||
|
|
||||||
import { hasPermission } from "../helpers/userPermissions";
|
import { hasPermission } from "../helpers/userPermissions";
|
||||||
import { fetchWidgets } from '../stores/roles/rolesSlice';
|
import { fetchWidgets } from '../stores/roles/rolesSlice';
|
||||||
|
import { fetch as fetchCourses } from '../stores/courses/coursesSlice';
|
||||||
import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator';
|
import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator';
|
||||||
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
|
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
|
||||||
|
import CardBox from '../components/CardBox';
|
||||||
|
import BaseButton from '../components/BaseButton';
|
||||||
|
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from '../stores/hooks';
|
import { useAppDispatch, useAppSelector } from '../stores/hooks';
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
@ -32,12 +36,15 @@ const Dashboard = () => {
|
|||||||
const [lessons, setLessons] = React.useState(loadingMessage);
|
const [lessons, setLessons] = React.useState(loadingMessage);
|
||||||
const [enrollments, setEnrollments] = React.useState(loadingMessage);
|
const [enrollments, setEnrollments] = React.useState(loadingMessage);
|
||||||
const [progress, setProgress] = React.useState(loadingMessage);
|
const [progress, setProgress] = React.useState(loadingMessage);
|
||||||
|
const [isMounted, setIsMounted] = React.useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const [widgetsRole, setWidgetsRole] = React.useState({
|
const [widgetsRole, setWidgetsRole] = React.useState({
|
||||||
role: { value: '', label: '' },
|
role: { value: '', label: '' },
|
||||||
});
|
});
|
||||||
const { currentUser } = useAppSelector((state) => state.auth);
|
const { currentUser } = useAppSelector((state) => state.auth);
|
||||||
|
const { courses: allCourses } = useAppSelector((state) => state.courses);
|
||||||
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
|
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
|
||||||
|
|
||||||
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
|
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
|
||||||
@ -75,6 +82,8 @@ const Dashboard = () => {
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
loadData().then();
|
loadData().then();
|
||||||
|
dispatch(fetchCourses({}));
|
||||||
|
setIsMounted(true);
|
||||||
setWidgetsRole({ role: { value: currentUser?.app_role?.id, label: currentUser?.app_role?.name } });
|
setWidgetsRole({ role: { value: currentUser?.app_role?.id, label: currentUser?.app_role?.name } });
|
||||||
}, [currentUser]);
|
}, [currentUser]);
|
||||||
|
|
||||||
@ -334,6 +343,37 @@ const Dashboard = () => {
|
|||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{isMounted && hasPermission(currentUser, 'READ_COURSES') && allCourses.length > 0 && (
|
||||||
|
<>
|
||||||
|
<SectionTitleLineWithButton
|
||||||
|
icon={icon.mdiBookOpenPageVariant}
|
||||||
|
title='Recent Courses'
|
||||||
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
|
<div className='grid grid-cols-1 gap-6 lg:grid-cols-3 mb-6'>
|
||||||
|
{allCourses.slice(0, 5).map((course) => (
|
||||||
|
<CardBox key={course.id}>
|
||||||
|
<div className='p-6'>
|
||||||
|
<h3 className='text-xl font-semibold mb-2'>{course.title}</h3>
|
||||||
|
<p className='text-gray-500 dark:text-gray-400'>{course.description}</p>
|
||||||
|
</div>
|
||||||
|
<div className='p-6 border-t border-gray-100 dark:border-dark-700'>
|
||||||
|
<BaseButton
|
||||||
|
href={`/courses/${course.id}`}
|
||||||
|
label='View Course'
|
||||||
|
color='info'
|
||||||
|
size='md'
|
||||||
|
className='w-full'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CardBox>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
1
frontend/tsconfig.tsbuildinfo
Normal file
1
frontend/tsconfig.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user