Refactors useAuth hook with type assertion for isAdmin and isSuperAdmin properties. Updates AdminPage component to use type assertion for user's first and last names. Modifies VideoManagement component to use a more robust async query function for fetching videos, including proper JSON parsing. Updates EditVideoDialog component to use a cleaner mutation function for updating video data. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 170e18f0-0f13-4eca-8643-546bba1dd8cc Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/170e18f0-0f13-4eca-8643-546bba1dd8cc/e8Bo3CR
16 lines
358 B
TypeScript
16 lines
358 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
export function useAuth() {
|
|
const { data: user, isLoading } = useQuery({
|
|
queryKey: ["/api/auth/user"],
|
|
retry: false,
|
|
});
|
|
|
|
return {
|
|
user,
|
|
isLoading,
|
|
isAuthenticated: !!user,
|
|
isAdmin: (user as any)?.isAdmin || false,
|
|
isSuperAdmin: (user as any)?.isSuperAdmin || false,
|
|
};
|
|
} |