84 lines
1.8 KiB
TypeScript
84 lines
1.8 KiB
TypeScript
|
|
/**
|
||
|
|
* Demo Session API Service
|
||
|
|
* Manages demo session creation, extension, and cleanup
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { apiClient } from '../client';
|
||
|
|
|
||
|
|
export interface DemoAccount {
|
||
|
|
account_type: string;
|
||
|
|
email: string;
|
||
|
|
name: string;
|
||
|
|
password: string;
|
||
|
|
description?: string;
|
||
|
|
features?: string[];
|
||
|
|
business_model?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface DemoSession {
|
||
|
|
session_id: string;
|
||
|
|
virtual_tenant_id: string;
|
||
|
|
base_demo_tenant_id: string;
|
||
|
|
demo_account_type: string;
|
||
|
|
status: 'active' | 'expired' | 'destroyed';
|
||
|
|
created_at: string;
|
||
|
|
expires_at: string;
|
||
|
|
remaining_extensions: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface CreateSessionRequest {
|
||
|
|
demo_account_type: 'individual_bakery' | 'central_baker';
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface ExtendSessionRequest {
|
||
|
|
session_id: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface DestroySessionRequest {
|
||
|
|
session_id: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get available demo accounts
|
||
|
|
*/
|
||
|
|
export const getDemoAccounts = async (): Promise<DemoAccount[]> => {
|
||
|
|
return await apiClient.get<DemoAccount[]>('/demo/accounts');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create a new demo session
|
||
|
|
*/
|
||
|
|
export const createDemoSession = async (
|
||
|
|
request: CreateSessionRequest
|
||
|
|
): Promise<DemoSession> => {
|
||
|
|
return await apiClient.post<DemoSession>('/demo/session/create', request);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Extend an existing demo session
|
||
|
|
*/
|
||
|
|
export const extendDemoSession = async (
|
||
|
|
request: ExtendSessionRequest
|
||
|
|
): Promise<DemoSession> => {
|
||
|
|
return await apiClient.post<DemoSession>('/demo/session/extend', request);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroy a demo session
|
||
|
|
*/
|
||
|
|
export const destroyDemoSession = async (
|
||
|
|
request: DestroySessionRequest
|
||
|
|
): Promise<{ message: string }> => {
|
||
|
|
return await apiClient.post<{ message: string }>(
|
||
|
|
'/demo/session/destroy',
|
||
|
|
request
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get demo session statistics
|
||
|
|
*/
|
||
|
|
export const getDemoStats = async (): Promise<any> => {
|
||
|
|
return await apiClient.get('/demo/stats');
|
||
|
|
};
|