Add DEMO feature to the project

This commit is contained in:
Urtzi Alfaro
2025-10-03 14:09:34 +02:00
parent 1243c2ca6d
commit dc8221bd2f
77 changed files with 6251 additions and 1074 deletions

View File

@@ -0,0 +1,83 @@
/**
* 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');
};