Move business logic out of App Router into module packages, add boundary validation scripts, and keep all routes as thin re-exports without changing URLs or API behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
3.2 KiB
JavaScript
68 lines
3.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/** Generate special sports-center routes (non-CRUD) */
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const APP = path.resolve(import.meta.dirname, "..", "app/sports-center");
|
|
|
|
const routes = [
|
|
["health", "HealthPage", "health"],
|
|
["capabilities", "CapabilitiesPage", "capabilities"],
|
|
["analytics", "AnalyticsPage", "analytics"],
|
|
["reports", "ReportsPage", "analytics"],
|
|
["notifications", "NotificationsPage", "analytics"],
|
|
["integrations/crm", "CrmIntegrationPage", "integrations"],
|
|
["integrations/accounting", "AccountingIntegrationPage", "integrations"],
|
|
["integrations/loyalty", "LoyaltyIntegrationPage", "integrations"],
|
|
["integrations/communication", "CommunicationIntegrationPage", "integrations"],
|
|
["integrations/ai", "AiInsightsPage", "integrations"],
|
|
["reception", "ReceptionCheckInPage", "reception"],
|
|
["reception/check-in", "ReceptionCheckInPage", "reception"],
|
|
["reception/qr-scanner", "QrScannerPage", "reception"],
|
|
["athlete", "AthleteHomePage", "athlete"],
|
|
["athlete/workout", "AthleteWorkoutPage", "athlete"],
|
|
["athlete/progress", "AthleteProgressPage", "athlete"],
|
|
["athlete/profile", "AthleteProfilePage", "athlete"],
|
|
["athlete/membership", "AthleteHomePage", "athlete"],
|
|
["athlete/qr", "QrScannerPage", "reception"],
|
|
["athlete/nutrition", "AthleteHomePage", "athlete"],
|
|
["athlete/bookings", "AthleteHomePage", "athlete"],
|
|
["athlete/achievements", "AthleteHomePage", "athlete"],
|
|
["athlete/attendance", "AthleteHomePage", "athlete"],
|
|
["athlete/measurements", "AthleteHomePage", "athlete"],
|
|
["coach", "OwnerDashboard", "dashboard"],
|
|
["coach/messages", "NotificationsPage", "analytics"],
|
|
["coach/schedule", "OwnerDashboard", "dashboard"],
|
|
["parent", "OwnerDashboard", "dashboard"],
|
|
["cashier", "OwnerDashboard", "dashboard"],
|
|
["support", "NotificationsPage", "analytics"],
|
|
["admin", "CapabilitiesPage", "capabilities"],
|
|
["calendar", "SessionsPage", "sessions"],
|
|
["classes", "SessionsPage", "sessions"],
|
|
["qr-access", "QrScannerPage", "reception"],
|
|
["exercise-library", "ExercisesPage", "exercises"],
|
|
["workout-programs", "TrainingProgramsPage", "trainingPrograms"],
|
|
["challenges", "CompetitionsPage", "competitions"],
|
|
["audit-logs", "HealthPage", "health"],
|
|
];
|
|
|
|
for (const [route, exportName, moduleFile] of routes) {
|
|
const dir = path.join(APP, route);
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(dir, "page.tsx"),
|
|
`"use client";\n\nexport { ${exportName} as default } from "@/modules/sports-center/features/${moduleFile}";\n`
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(dir, "loading.tsx"),
|
|
`import { LoadingState } from "@/components/ds";\n\nexport default function Loading() {\n return <LoadingState label="در حال بارگذاری…" />;\n}\n`
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(dir, "error.tsx"),
|
|
`"use client";\n\nimport { ErrorState } from "@/components/ds";\n\nexport default function Error({ error, reset }: { error: Error; reset: () => void }) {\n return <ErrorState message={error.message} onRetry={reset} />;\n}\n`
|
|
);
|
|
console.log("Special route:", route);
|
|
}
|
|
|
|
console.log(`Done. ${routes.length} special routes.`);
|