Refactor code and update dependencies configuration
This commit includes reorganizing dependencies in 'package.json' for better readability. It also refactors code associated with user and personal account data along with animations for AvatarFallback and profile name display. Additionally, the 'next' package version has been updated to '14.2.0-canary.56'. Some changes have been made for minor corrections and enhancements in the scripts.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
import type { User } from '@supabase/supabase-js';
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
@@ -10,14 +8,13 @@ const queryKey = ['supabase:user'];
|
||||
|
||||
export function useUser(initialData?: User | null) {
|
||||
const client = useSupabase();
|
||||
const router = useRouter();
|
||||
|
||||
const queryFn = async () => {
|
||||
const response = await client.auth.getUser();
|
||||
|
||||
// this is most likely a session error or the user is not logged in
|
||||
if (response.error) {
|
||||
throw router.replace('/');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (response.data?.user) {
|
||||
@@ -32,6 +29,5 @@ export function useUser(initialData?: User | null) {
|
||||
queryKey,
|
||||
initialData,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnMount: false,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user