feat: Implement faculty management routes and UI components
- Added a new route for managing faculties with a grid display of faculties. - Created a detailed view for each faculty including metrics and recent activities. - Introduced a new loader for fetching faculty data and associated plans and subjects. - Enhanced the existing plans route to include a modal for plan details. - Updated the login and index pages with improved UI and styling. - Integrated a progress ring component to visualize the quality of plans. - Applied a new font style across the application for consistency.
This commit is contained in:
+24
-1
@@ -8,12 +8,25 @@ export const supabase = createClient(
|
||||
|
||||
export interface SupabaseAuthState {
|
||||
isAuthenticated: boolean
|
||||
user: any
|
||||
user: User | null
|
||||
claims: UserClaims | null
|
||||
login: (email: string, password: string) => Promise<void>
|
||||
logout: () => Promise<void>
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
type UserClaims = {
|
||||
claims_admin: boolean,
|
||||
clave: string,
|
||||
nombre: string,
|
||||
apellidos: string,
|
||||
title: string,
|
||||
avatar: string | null,
|
||||
carrera_id?: string,
|
||||
facultad_id?: string,
|
||||
role: 'lci' | 'vicerrectoria' | 'secretario_academico' | 'jefe_carrera' | 'planeacion',
|
||||
}
|
||||
|
||||
const SupabaseAuthContext = createContext<SupabaseAuthState | undefined>(
|
||||
undefined,
|
||||
)
|
||||
@@ -24,6 +37,7 @@ export function SupabaseAuthProvider({
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const [user, setUser] = useState<User | null>(null)
|
||||
const [claims, setClaims] = useState<UserClaims | null>(null)
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
|
||||
@@ -31,6 +45,10 @@ export function SupabaseAuthProvider({
|
||||
// Get initial session
|
||||
supabase.auth.getSession().then(({ data: { session } }) => {
|
||||
setUser(session?.user ?? null)
|
||||
setClaims({
|
||||
...(session?.user?.app_metadata as Partial<UserClaims> ?? {}),
|
||||
...(session?.user?.user_metadata as Partial<UserClaims> ?? {}),
|
||||
} as UserClaims | null)
|
||||
setIsAuthenticated(!!session?.user)
|
||||
setIsLoading(false)
|
||||
})
|
||||
@@ -40,6 +58,10 @@ export function SupabaseAuthProvider({
|
||||
data: { subscription },
|
||||
} = supabase.auth.onAuthStateChange((_event, session) => {
|
||||
setUser(session?.user ?? null)
|
||||
setClaims({
|
||||
...(session?.user?.app_metadata as Partial<UserClaims> ?? {}),
|
||||
...(session?.user?.user_metadata as Partial<UserClaims> ?? {}),
|
||||
} as UserClaims | null)
|
||||
setIsAuthenticated(!!session?.user)
|
||||
setIsLoading(false)
|
||||
})
|
||||
@@ -67,6 +89,7 @@ export function SupabaseAuthProvider({
|
||||
value={{
|
||||
isAuthenticated,
|
||||
user,
|
||||
claims,
|
||||
login,
|
||||
logout,
|
||||
isLoading,
|
||||
|
||||
Reference in New Issue
Block a user