Made more client components to make the rendering not so crazy

This commit is contained in:
2025-06-04 10:28:37 -05:00
parent ef24642128
commit e2f291e707
13 changed files with 697 additions and 197 deletions

View File

@@ -14,7 +14,7 @@ import {
getSignedUrl,
getUser,
updateProfile as updateProfileAction,
} from '@/lib/actions';
} from '@/lib/hooks';
import {
type User,
type Profile,
@@ -119,7 +119,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
};
}, [fetchUserData]);
const updateProfile = async (data: {
const updateProfile = useCallback(async (data: {
full_name?: string;
email?: string;
avatar_url?: string;
@@ -151,15 +151,12 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
console.error('Error updating profile:', error);
toast.error(error instanceof Error ? error.message : 'Failed to update profile');
return { success: false, error };
} finally {
setIsLoading(false);
}
};
}, []);
const refreshUserData = async () => {
console.log('Manual refresh triggered');
const refreshUserData = useCallback(async () => {
await fetchUserData();
};
}, [fetchUserData]);
const value = {
user,
@@ -171,7 +168,11 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
refreshUserData,
};
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
return (
<AuthContext.Provider value={value}>
{children}
</AuthContext.Provider>
);
}
export const useAuth = () => {