phase 1-6 implemented

This commit is contained in:
dimitar committed 2026-03-10 04:14:03 +01:00
1 parent 22c274bb83
commit 2c4927478a
73 files changed
+9702 -2354

No files matched your search

+147
View File
@@ -0,0 +1,147 @@
/**
* Shared constants and enums used across the FitAI application
* Single source of truth for all enum values
*/
// User Roles
export const USER_ROLES = ["superAdmin", "admin", "trainer", "client"] as const;
export type UserRole = (typeof USER_ROLES)[number];
// Export UserRole for easier imports
export type { UserRole as UserRoleType };
// Gym Status
export const GYM_STATUSES = ["active", "inactive"] as const;
export type GymStatus = (typeof GYM_STATUSES)[number];
// Membership Types
export const MEMBERSHIP_TYPES = ["basic", "premium", "vip"] as const;
export type MembershipType = (typeof MEMBERSHIP_TYPES)[number];
// Membership Statuses
export const MEMBERSHIP_STATUSES = ["active", "inactive", "suspended"] as const;
export type MembershipStatus = (typeof MEMBERSHIP_STATUSES)[number];
// Payment Statuses
export const PAYMENT_STATUSES = [
"pending",
"completed",
"failed",
"refunded",
] as const;
export type PaymentStatus = (typeof PAYMENT_STATUSES)[number];
// Payment Methods
export const PAYMENT_METHODS = ["cash", "card", "bank_transfer"] as const;
export type PaymentMethod = (typeof PAYMENT_METHODS)[number];
// Attendance Types
export const ATTENDANCE_TYPES = ["gym", "class", "personal_training"] as const;
export type AttendanceType = (typeof ATTENDANCE_TYPES)[number];
// Notification Types
export const NOTIFICATION_TYPES = [
"payment_reminder",
"attendance",
"promotion",
"system",
] as const;
export type NotificationType = (typeof NOTIFICATION_TYPES)[number];
// Genders
export const GENDERS = [
"male",
"female",
"other",
"prefer_not_to_say",
] as const;
export type Gender = (typeof GENDERS)[number];
// Activity Levels
export const ACTIVITY_LEVELS = [
"sedentary",
"lightly_active",
"moderately_active",
"very_active",
"extremely_active",
] as const;
export type ActivityLevel = (typeof ACTIVITY_LEVELS)[number];
// Goal Types
export const GOAL_TYPES = [
"weight_target",
"strength_milestone",
"endurance_target",
"flexibility_goal",
"habit_building",
"custom",
] as const;
export type GoalType = (typeof GOAL_TYPES)[number];
// Goal Statuses
export const GOAL_STATUSES = [
"active",
"completed",
"abandoned",
"paused",
] as const;
export type GoalStatus = (typeof GOAL_STATUSES)[number];
// Priority Levels
export const PRIORITY_LEVELS = ["low", "medium", "high"] as const;
export type PriorityLevel = (typeof PRIORITY_LEVELS)[number];
// Recommendation Statuses
export const RECOMMENDATION_STATUSES = [
"pending",
"approved",
"rejected",
] as const;
export type RecommendationStatus = (typeof RECOMMENDATION_STATUSES)[number];
// Helper functions to check enum values
export function isValidUserRole(role: string): role is UserRole {
return USER_ROLES.includes(role as UserRole);
}
export function isValidMembershipStatus(
status: string,
): status is MembershipStatus {
return MEMBERSHIP_STATUSES.includes(status as MembershipStatus);
}
export function isValidPaymentStatus(status: string): status is PaymentStatus {
return PAYMENT_STATUSES.includes(status as PaymentStatus);
}
export function isValidGoalStatus(status: string): status is GoalStatus {
return GOAL_STATUSES.includes(status as GoalStatus);
}
// Display labels for UI
export const USER_ROLE_LABELS: Record<UserRole, string> = {
superAdmin: "Super Admin",
admin: "Admin",
trainer: "Trainer",
client: "Client",
};
export const MEMBERSHIP_STATUS_LABELS: Record<MembershipStatus, string> = {
active: "Active",
inactive: "Inactive",
suspended: "Suspended",
};
export const PAYMENT_STATUS_LABELS: Record<PaymentStatus, string> = {
pending: "Pending",
completed: "Completed",
failed: "Failed",
refunded: "Refunded",
};
export const GOAL_STATUS_LABELS: Record<GoalStatus, string> = {
active: "Active",
completed: "Completed",
abandoned: "Abandoned",
paused: "Paused",
};
+4 -3
View File
@@ -1,3 +1,4 @@
export * from './types'
export * from './schemas'
export * from './utils'
export * from "./types";
export * from "./schemas";
export * from "./utils";
export * from "./constants";
+44 -39
View File
@@ -1,3 +1,20 @@
import type {
UserRole,
MembershipType,
MembershipStatus,
Gender,
ActivityLevel,
GoalType,
GoalStatus,
PriorityLevel,
AttendanceType,
PaymentStatus,
PaymentMethod,
NotificationType,
GymStatus,
RecommendationStatus,
} from "../constants";
export interface User {
id: string;
email: string;
@@ -5,7 +22,7 @@ export interface User {
lastName: string;
password?: string;
phone?: string;
role: "superAdmin" | "admin" | "trainer" | "client";
role: UserRole;
gymId?: string;
imageUrl?: string;
createdAt: Date;
@@ -16,8 +33,8 @@ export interface Client {
id: string;
userId: string;
user?: User;
membershipType: "basic" | "premium" | "vip";
membershipStatus: "active" | "inactive" | "suspended" | "expired";
membershipType: MembershipType;
membershipStatus: MembershipStatus;
joinDate: Date;
lastVisit?: Date;
emergencyContact?: {
@@ -30,20 +47,13 @@ export interface Client {
export interface FitnessProfile {
id: string;
userId: string;
height: string;
weight: string;
age: string;
gender: "male" | "female" | "other";
activityLevel:
| "sedentary"
| "lightly_active"
| "moderately_active"
| "very_active"
| "extremely_active";
fitnessGoals: string[];
exerciseHabits: string;
dietHabits: string;
medicalConditions: string;
height?: number; // in cm (fixed from string to number)
weight?: number; // in kg (fixed from string to number)
age?: number; // (fixed from string to number)
gender?: Gender;
activityLevel?: ActivityLevel;
fitnessGoals?: string[];
medicalConditions?: string;
allergies?: string;
injuries?: string;
createdAt: Date;
@@ -57,7 +67,7 @@ export interface Attendance {
client?: Client;
checkInTime: Date;
checkOutTime?: Date;
type: "gym" | "class" | "personal_training";
type: AttendanceType;
notes?: string;
createdAt?: Date;
}
@@ -65,28 +75,23 @@ export interface Attendance {
export interface Recommendation {
id: string;
userId: string;
fitnessProfileId?: string;
type: "short_term" | "medium_term" | "long_term" | "ai_plan";
fitnessProfileId: string;
recommendationText: string;
activityPlan?: string;
dietPlan?: string;
status: "pending" | "approved" | "rejected" | "completed";
createdAt: Date;
activityPlan: string;
dietPlan: string;
status: RecommendationStatus;
generatedAt: Date;
approvedAt?: Date;
approvedBy?: string;
createdAt: Date;
updatedAt: Date;
}
export interface FitnessGoal {
id: string;
userId: string;
fitnessProfileId?: string;
goalType:
| "weight_target"
| "strength_milestone"
| "endurance_target"
| "flexibility_goal"
| "habit_building"
| "custom";
goalType: GoalType;
title: string;
description?: string;
targetValue?: number;
@@ -95,9 +100,9 @@ export interface FitnessGoal {
startDate: Date;
targetDate?: Date;
completedDate?: Date;
status: "active" | "completed" | "abandoned" | "paused";
status: GoalStatus;
progress: number;
priority: "low" | "medium" | "high";
priority: PriorityLevel;
notes?: string;
createdAt: Date;
updatedAt: Date;
@@ -106,11 +111,11 @@ export interface FitnessGoal {
export interface Payment {
id: string;
clientId: string;
client: Client;
client?: Client; // Made optional (was required)
amount: number;
currency: string;
status: "pending" | "completed" | "failed" | "refunded";
paymentMethod: "cash" | "card" | "bank_transfer";
status: PaymentStatus;
paymentMethod: PaymentMethod;
dueDate: Date;
paidAt?: Date;
description: string;
@@ -121,7 +126,7 @@ export interface Notification {
userId: string;
title: string;
message: string;
type: "payment_reminder" | "attendance" | "promotion" | "system";
type: NotificationType;
read: boolean;
createdAt: Date;
}
@@ -130,7 +135,7 @@ export interface Gym {
id: string;
name: string;
location?: string;
status: "active" | "inactive";
status: GymStatus;
adminUserId: string;
}
@@ -138,7 +143,7 @@ export interface Invitation {
id: string;
inviterUserId: string;
inviteeEmail: string;
roleAssigned: "trainer" | "client" | "admin";
roleAssigned: UserRole;
gymId: string;
token: string;
status: "sent" | "accepted" | "expired";