The admin functionality related code has been removed which includes various user and organization functionalities like delete, update, ban etc. This includes action logic, UI components and supportive utility functions. Notable deletions include the server action files, dialog components for actions like banning and deleting, and related utility functions. This massive cleanup is aimed at simplifying the codebase and the commit reflects adherence to project restructuring.
42 lines
817 B
TypeScript
42 lines
817 B
TypeScript
import { useCallback } from 'react';
|
|
|
|
import type { Session } from '@supabase/supabase-js';
|
|
|
|
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
|
|
|
import { useSupabase } from './use-supabase';
|
|
|
|
const queryKey = ['supabase:session'];
|
|
|
|
export function useUserSession(initialSession?: Session | null) {
|
|
const supabase = useSupabase();
|
|
|
|
const queryFn = async () => {
|
|
const { data, error } = await supabase.auth.getSession();
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return data.session;
|
|
};
|
|
|
|
return useSuspenseQuery({
|
|
queryKey,
|
|
queryFn,
|
|
initialData: initialSession,
|
|
});
|
|
}
|
|
|
|
export function useRevalidateUserSession() {
|
|
const client = useQueryClient();
|
|
|
|
return useCallback(
|
|
() =>
|
|
client.invalidateQueries({
|
|
queryKey,
|
|
}),
|
|
[client],
|
|
);
|
|
}
|