This commit includes: - Django backend with multi-tenancy (django-tenants) - React + TypeScript frontend with Vite - Platform administration API with role-based access control - Authentication system with token-based auth - Quick login dev tools for testing different user roles - CORS and CSRF configuration for local development - Docker development environment setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
42 lines
999 B
TypeScript
42 lines
999 B
TypeScript
/**
|
|
* Platform Hooks
|
|
* React Query hooks for platform-level operations
|
|
*/
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { getBusinesses, getUsers, getBusinessUsers } from '../api/platform';
|
|
|
|
/**
|
|
* Hook to get all businesses (platform admin only)
|
|
*/
|
|
export const useBusinesses = () => {
|
|
return useQuery({
|
|
queryKey: ['platform', 'businesses'],
|
|
queryFn: getBusinesses,
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Hook to get all users (platform admin only)
|
|
*/
|
|
export const usePlatformUsers = () => {
|
|
return useQuery({
|
|
queryKey: ['platform', 'users'],
|
|
queryFn: getUsers,
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Hook to get users for a specific business
|
|
*/
|
|
export const useBusinessUsers = (businessId: number | null) => {
|
|
return useQuery({
|
|
queryKey: ['platform', 'business-users', businessId],
|
|
queryFn: () => getBusinessUsers(businessId!),
|
|
enabled: !!businessId,
|
|
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
});
|
|
};
|