fitaiProto/packages/shared/src/constants/index.ts

177 lines
4.5 KiB
TypeScript

/**
* 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];
export const MEMBERSHIP_FEATURES = {
basic: {
recommendationsPerMonth: 1,
hydrationTracking: false,
nutritionTracking: false,
advancedStatistics: false,
},
premium: {
recommendationsPerMonth: -1,
hydrationTracking: true,
nutritionTracking: true,
advancedStatistics: true,
},
vip: {
recommendationsPerMonth: -1,
hydrationTracking: true,
nutritionTracking: true,
advancedStatistics: true,
},
} as const;
export type MembershipFeatures = (typeof MEMBERSHIP_FEATURES)[MembershipType];
export function getMembershipFeatures(
membershipType: MembershipType,
): MembershipFeatures {
return MEMBERSHIP_FEATURES[membershipType];
}
// 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",
};