This commit is contained in:
Flatlogic Bot 2025-05-26 10:45:40 +00:00
parent 1809905936
commit b10bd04ea9
4 changed files with 17 additions and 7 deletions

5
.gitignore vendored
View File

@ -1,3 +1,8 @@
node_modules/
*/node_modules/
*/build/
**/node_modules/
**/build/
.DS_Store
.env

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{}

View File

@ -1,6 +1,6 @@
import * as icon from '@mdi/js';
import Head from 'next/head';
import React from 'react';
import React, { useEffect } from 'react';
import axios from 'axios';
import type { ReactElement } from 'react';
import LayoutAuthenticated from '../layouts/Authenticated';
@ -15,6 +15,7 @@ import { hasPermission } from '../helpers/userPermissions';
import { fetchWidgets } from '../stores/roles/rolesSlice';
import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator';
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
import { askGpt } from '../stores/openAiSlice';
import { useAppDispatch, useAppSelector } from '../stores/hooks';
const Dashboard = () => {
@ -38,12 +39,16 @@ const Dashboard = () => {
const [students, setStudents] = React.useState(loadingMessage);
const [roles, setRoles] = React.useState(loadingMessage);
const [permissions, setPermissions] = React.useState(loadingMessage);
const promptForGreeting = "Write a short ironic greeting for a dashboard page, in 3-5 words.";
const isAsking = useAppSelector((state) => state.openAi?.isAskingQuestion ?? false);
const gptResp = useAppSelector((state) => state.openAi?.gptResponse);
useEffect(() => { dispatch(askGpt(promptForGreeting)); }, [dispatch]);
const [widgetsRole, setWidgetsRole] = React.useState({
role: { value: '', label: '' },
});
const { currentUser } = useAppSelector((state) => state.auth);
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
const isFetchingQuery = useAppSelector((state) => state.openAi?.isFetchingQuery ?? false);
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
@ -122,7 +127,7 @@ const Dashboard = () => {
<SectionMain>
<SectionTitleLineWithButton
icon={icon.mdiChartTimelineVariant}
title={t('pages.dashboard.overview', { defaultValue: 'Overview' })}
title={isAsking ? '...' : (gptResp || t('pages.dashboard.overview', { defaultValue: 'Overview' }))}
main
>
{''}