-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
197 lines (180 loc) · 5.72 KB
/
Copy pathApp.tsx
File metadata and controls
197 lines (180 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { useState } from "react";
import { TeacherDashboard } from "./components/TeacherDashboard";
import { TeacherList } from "./components/TeacherList";
import { Navigation } from "./components/Navigation";
import { AuthScreen } from "./components/AuthScreen";
import { ProfileScreen } from "./components/ProfileScreen";
import { GroupSelector } from "./components/GroupSelector";
import { AdminDashboard } from "./components/AdminDashboard";
import { LoadingScreen } from "./components/LoadingScreen";
import { ErrorScreen } from "./components/ErrorScreen";
import { DevToolsPanel } from "./components/DevToolsPanel";
import { BackendStatus } from "./components/BackendStatus";
import { useAppInitialization } from "./utils/useAppInitialization";
import { useAuthState } from "./utils/useAuthState";
import { handleDevReset } from "./utils/devReset";
import logoInstitucional from "figma:asset/ee70fd1003ccb4c67c2394418297db8dbbf0d634.png";
import {
isDevelopment,
type View,
type Teacher,
} from "./utils/types";
export default function App() {
const [activeView, setActiveView] =
useState<View>("dashboard");
const [showGroupSelector, setShowGroupSelector] =
useState(false);
const [resetInProgress, setResetInProgress] = useState(false);
const { dbInitialized, initError, isFirstInstall } =
useAppInitialization();
const {
authState,
currentTeacher,
setAuthState,
handleLogin,
handleLogout,
handleGroupSelect,
updateCurrentTeacher,
} = useAuthState();
const onDevReset = () =>
handleDevReset(setResetInProgress, () => {
setActiveView("dashboard");
setShowGroupSelector(false);
handleLogout();
});
const handleGroupSelectWrapper = async (group: string) => {
await handleGroupSelect(group);
setShowGroupSelector(false);
};
// Verificar roles
const isAdmin = currentTeacher?.role === "admin";
// Mostrar pantallas de carga/error
if (initError) {
return (
<ErrorScreen
error={initError}
isDevelopment={isDevelopment()}
onDevReset={onDevReset}
resetInProgress={resetInProgress}
/>
);
}
if (!dbInitialized) {
return (
<LoadingScreen
isFirstInstall={isFirstInstall}
isDevelopment={isDevelopment()}
onDevReset={onDevReset}
resetInProgress={resetInProgress}
/>
);
}
// Renderizar contenido principal
const renderContent = () => {
if (authState !== "authenticated" || !currentTeacher) {
return (
<AuthScreen
authState={authState}
onStateChange={setAuthState}
onLogin={handleLogin}
/>
);
}
if (showGroupSelector) {
return (
<GroupSelector
currentGroup={currentTeacher.selectedGroup}
onGroupSelect={handleGroupSelectWrapper}
onBack={() => setShowGroupSelector(false)}
teacherId={currentTeacher.id}
/>
);
}
switch (activeView) {
case "dashboard":
return (
<TeacherDashboard
teacher={currentTeacher}
onGroupSelect={() => setShowGroupSelector(true)}
/>
);
case "teachers":
return <TeacherList />;
case "profile":
return (
<ProfileScreen
teacher={currentTeacher}
onLogout={handleLogout}
onBack={() => setActiveView("dashboard")}
onTeacherUpdate={updateCurrentTeacher}
/>
);
case "admin":
if (isAdmin) {
return (
<AdminDashboard
teacher={currentTeacher}
onBack={() => setActiveView("dashboard")}
/>
);
} else {
setActiveView("dashboard");
return null;
}
default:
return (
<TeacherDashboard
teacher={currentTeacher}
onGroupSelect={() => setShowGroupSelector(true)}
/>
);
}
};
return (
<div className="min-h-screen bg-background relative">
{/* Logo institucional en esquina superior derecha */}
<div className="fixed top-4 right-4 z-50">
<img
src={logoInstitucional}
alt="Institución Educativa Nuevo Latir"
className="h-12 w-auto drop-shadow-sm"
/>
</div>
<main
className={authState === "authenticated" ? "pb-16" : ""}
>
{renderContent()}
</main>
{authState === "authenticated" && (
<Navigation
activeView={activeView}
onViewChange={setActiveView}
userRole={currentTeacher?.role || "teacher"}
/>
)}
{isDevelopment() && (
<DevToolsPanel
isFirstInstall={isFirstInstall}
currentTeacher={currentTeacher}
authState={authState}
onDevReset={onDevReset}
resetInProgress={resetInProgress}
/>
)}
<BackendStatus />
</div>
);
}
export type { Teacher };
// Nota de archivos obsoletos que se pueden eliminar después de confirmar que todo funciona:
// Los siguientes archivos ya no se usan en el sistema simplificado:
// - /components/QRGenerator.tsx (sistema QR eliminado)
// - /components/QRLandingPage.tsx (sistema QR eliminado)
// - /components/QRScanner.tsx (sistema QR eliminado)
// - /components/Dashboard.tsx (reemplazado por TeacherDashboard)
// - /components/MenuManagement.tsx (funcionalidad incorporada en AdminDashboard)
// - /components/ScheduleView.tsx (funcionalidad incorporada en AdminDashboard)
// - /components/Sidebar.tsx (no se usa en el diseño móvil)
// - /components/StaffSchedule.tsx (funcionalidad incorporada en AdminDashboard)
// - /utils/cameraUtils.ts (sistema de cámara QR eliminado)
// - /utils/scheduleUtils.ts (lógica incorporada en database.ts)