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>
57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
/**
|
|
* Platform API
|
|
* API functions for platform-level operations (businesses, users, etc.)
|
|
*/
|
|
|
|
import apiClient from './client';
|
|
|
|
export interface PlatformBusiness {
|
|
id: number;
|
|
name: string;
|
|
subdomain: string;
|
|
tier: string;
|
|
is_active: boolean;
|
|
created_at: string;
|
|
user_count: number;
|
|
}
|
|
|
|
export interface PlatformUser {
|
|
id: number;
|
|
email: string;
|
|
username: string;
|
|
name?: string;
|
|
role?: string;
|
|
is_active: boolean;
|
|
is_staff: boolean;
|
|
is_superuser: boolean;
|
|
business: number | null;
|
|
business_name?: string;
|
|
business_subdomain?: string;
|
|
date_joined: string;
|
|
last_login?: string;
|
|
}
|
|
|
|
/**
|
|
* Get all businesses (platform admin only)
|
|
*/
|
|
export const getBusinesses = async (): Promise<PlatformBusiness[]> => {
|
|
const response = await apiClient.get<PlatformBusiness[]>('/api/platform/businesses/');
|
|
return response.data;
|
|
};
|
|
|
|
/**
|
|
* Get all users (platform admin only)
|
|
*/
|
|
export const getUsers = async (): Promise<PlatformUser[]> => {
|
|
const response = await apiClient.get<PlatformUser[]>('/api/platform/users/');
|
|
return response.data;
|
|
};
|
|
|
|
/**
|
|
* Get users for a specific business
|
|
*/
|
|
export const getBusinessUsers = async (businessId: number): Promise<PlatformUser[]> => {
|
|
const response = await apiClient.get<PlatformUser[]>(`/api/platform/users/?business=${businessId}`);
|
|
return response.data;
|
|
};
|