feat(builder): implement phase 2 frontend form and phased builder in admin console
This commit is contained in:
parent
7d941687f6
commit
c2dd98316e
|
|
@ -9,6 +9,7 @@ import { AdminSidebar } from './components/layout/AdminSidebar';
|
|||
import { SyncOverview } from './components/sync/SyncOverview';
|
||||
import { ModulesTab } from './components/modules/ModulesTab';
|
||||
import { EditModuleModal } from './components/modules/EditModuleModal';
|
||||
import { ModuleBuilderTab } from './components/modules/ModuleBuilderTab';
|
||||
import { PlansTab } from './components/plans/PlansTab';
|
||||
import { CreatePlanModal } from './components/plans/CreatePlanModal';
|
||||
import { EditPriceModal } from './components/plans/EditPriceModal';
|
||||
|
|
@ -1019,6 +1020,7 @@ export default function App() {
|
|||
<h2 className="text-xl sm:text-2xl font-black text-slate-900 tracking-tight">
|
||||
{adminSubTab === 'overview' && 'System Overview & Audit Logs'}
|
||||
{adminSubTab === 'modules' && 'Curriculum Modules'}
|
||||
{adminSubTab === 'module_builder' && 'Clinical Module Builder'}
|
||||
{adminSubTab === 'plans' && 'Subscription Plans & Pricing'}
|
||||
{adminSubTab === 'coupons' && 'Promotions & Coupons'}
|
||||
{adminSubTab === 'customers' && 'Customer Directory'}
|
||||
|
|
@ -1031,6 +1033,7 @@ export default function App() {
|
|||
<p className="text-slate-500 text-xs font-semibold">
|
||||
{adminSubTab === 'overview' && 'Real-time telemetry, synchronized payment logs, and platform health metrics.'}
|
||||
{adminSubTab === 'modules' && 'Configure learning modules, categories, pricing, and availability states.'}
|
||||
{adminSubTab === 'module_builder' && 'Author and customize disease categories, clinical patterns, and treatment formulas.'}
|
||||
{adminSubTab === 'plans' && 'Manage localized pricing tiers, curriculum module bundles, and active pricing.'}
|
||||
{adminSubTab === 'coupons' && 'Manage discount codes, percentage cuts, module restrictions, and expiry dates.'}
|
||||
{adminSubTab === 'customers' && 'Inspect practitioner accounts, credentials, countries, and purchased plans.'}
|
||||
|
|
@ -1101,6 +1104,10 @@ export default function App() {
|
|||
/>
|
||||
)}
|
||||
|
||||
{adminSubTab === 'module_builder' && (
|
||||
<ModuleBuilderTab />
|
||||
)}
|
||||
|
||||
{adminSubTab === 'plans' && (
|
||||
<PlansTab
|
||||
plans={adminPlansList}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import {
|
||||
Sparkles, ChevronLeft, ChevronRight, LogOut,
|
||||
List, BookOpen, Tag, Ticket, Users, CheckCircle,
|
||||
Receipt, Shield, Database, FileText, X
|
||||
Receipt, Shield, Database, FileText, X, Layers
|
||||
} from 'lucide-react';
|
||||
import type { LoggedInUser, AdminTabType } from '../../types';
|
||||
|
||||
|
|
@ -64,6 +64,7 @@ export const AdminSidebar: React.FC<AdminSidebarProps> = ({
|
|||
const tabs: TabItem[] = [
|
||||
{ key: 'overview', label: 'Overview & Logs', icon: <List className="h-4 w-4 shrink-0" /> },
|
||||
{ key: 'modules', label: 'Modules', count: counts.modules, icon: <BookOpen className="h-4 w-4 shrink-0" /> },
|
||||
{ key: 'module_builder', label: 'Module Builder', icon: <Layers className="h-4 w-4 shrink-0" /> },
|
||||
{ key: 'plans', label: 'Plans & Pricing', count: counts.plans, icon: <Tag className="h-4 w-4 shrink-0" /> },
|
||||
{ key: 'coupons', label: 'Coupons', count: counts.coupons, icon: <Ticket className="h-4 w-4 shrink-0" /> },
|
||||
{ key: 'customers', label: 'Customers', count: counts.customers, icon: <Users className="h-4 w-4 shrink-0" /> },
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,155 @@
|
|||
import { api } from './api';
|
||||
|
||||
export interface BuilderCategorySummary {
|
||||
id?: string;
|
||||
module_code: string;
|
||||
category_code: string;
|
||||
name: string;
|
||||
overview?: string | null;
|
||||
sort_order: number;
|
||||
disease_count: number;
|
||||
}
|
||||
|
||||
export interface BuilderDiseaseSummary {
|
||||
id?: string;
|
||||
module_code: string;
|
||||
category_code: string;
|
||||
disease_code: string;
|
||||
name: string;
|
||||
overview?: string | null;
|
||||
sort_order: number;
|
||||
pattern_count: number;
|
||||
}
|
||||
|
||||
export interface PatternClinicalData {
|
||||
clinical_manifestations: string[];
|
||||
tongue: string;
|
||||
pulse: string;
|
||||
treatment_principle: string;
|
||||
acupuncture: {
|
||||
points: string;
|
||||
method: string;
|
||||
};
|
||||
explanation: string[];
|
||||
}
|
||||
|
||||
export interface BuilderPattern {
|
||||
id?: string;
|
||||
module_code: string;
|
||||
category_code: string;
|
||||
disease_code: string;
|
||||
pattern_code: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
clinical_data: PatternClinicalData;
|
||||
sort_order: number;
|
||||
}
|
||||
|
||||
export interface BuilderDiseaseDetail {
|
||||
id?: string;
|
||||
module_code: string;
|
||||
category_code: string;
|
||||
disease_code: string;
|
||||
name: string;
|
||||
overview?: string | null;
|
||||
sort_order: number;
|
||||
patterns: BuilderPattern[];
|
||||
}
|
||||
|
||||
export interface SaveFullDiseasePayload {
|
||||
category_code: string;
|
||||
disease_code: string;
|
||||
name: string;
|
||||
overview?: string | null;
|
||||
patterns: {
|
||||
category_code: string;
|
||||
disease_code: string;
|
||||
pattern_code: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
clinical_data: PatternClinicalData;
|
||||
sort_order: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
export const moduleBuilderService = {
|
||||
// Categories
|
||||
async getCategories(moduleCode: string): Promise<BuilderCategorySummary[]> {
|
||||
const res = await api.get(`/api/admin/module-builder/${moduleCode}/categories`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async saveCategory(
|
||||
moduleCode: string,
|
||||
data: { category_code: string; name: string; overview?: string; sort_order?: number }
|
||||
): Promise<BuilderCategorySummary> {
|
||||
const res = await api.post(`/api/admin/module-builder/${moduleCode}/categories`, data);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async deleteCategory(moduleCode: string, categoryCode: string): Promise<boolean> {
|
||||
const res = await api.delete(`/api/admin/module-builder/${moduleCode}/categories/${categoryCode}`);
|
||||
return res.data?.success ?? true;
|
||||
},
|
||||
|
||||
// Diseases
|
||||
async getDiseases(moduleCode: string, categoryCode: string): Promise<BuilderDiseaseSummary[]> {
|
||||
const res = await api.get(`/api/admin/module-builder/${moduleCode}/categories/${categoryCode}/diseases`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getDiseaseDetail(
|
||||
moduleCode: string,
|
||||
categoryCode: string,
|
||||
diseaseCode: string
|
||||
): Promise<BuilderDiseaseDetail> {
|
||||
const res = await api.get(
|
||||
`/api/admin/module-builder/${moduleCode}/categories/${categoryCode}/diseases/${diseaseCode}`
|
||||
);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async saveDisease(
|
||||
moduleCode: string,
|
||||
categoryCode: string,
|
||||
data: { disease_code: string; name: string; overview?: string; sort_order?: number }
|
||||
): Promise<BuilderDiseaseSummary> {
|
||||
const res = await api.post(
|
||||
`/api/admin/module-builder/${moduleCode}/categories/${categoryCode}/diseases`,
|
||||
data
|
||||
);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async deleteDisease(
|
||||
moduleCode: string,
|
||||
categoryCode: string,
|
||||
diseaseCode: string
|
||||
): Promise<boolean> {
|
||||
const res = await api.delete(
|
||||
`/api/admin/module-builder/${moduleCode}/categories/${categoryCode}/diseases/${diseaseCode}`
|
||||
);
|
||||
return res.data?.success ?? true;
|
||||
},
|
||||
|
||||
// Save Full Disease with Patterns
|
||||
async saveFullDisease(
|
||||
moduleCode: string,
|
||||
payload: SaveFullDiseasePayload
|
||||
): Promise<BuilderDiseaseDetail> {
|
||||
const res = await api.post(`/api/admin/module-builder/${moduleCode}/save-full`, payload);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
// Export JSON
|
||||
async exportModuleJson(moduleCode: string): Promise<any> {
|
||||
const res = await api.get(`/api/admin/module-builder/${moduleCode}/export-json`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
// Import JSON
|
||||
async importModuleJson(moduleCode: string, contents: any[]): Promise<any> {
|
||||
const res = await api.post(`/api/admin/module-builder/${moduleCode}/import-json`, { contents });
|
||||
return res.data;
|
||||
},
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
export type AdminTabType =
|
||||
| 'overview'
|
||||
| 'modules'
|
||||
| 'module_builder'
|
||||
| 'plans'
|
||||
| 'coupons'
|
||||
| 'customers'
|
||||
|
|
|
|||
Loading…
Reference in New Issue