and AI recommnedation fix
This commit is contained in:
dimitar committed 2025-12-12 01:32:52 +01:00
1 parent 670e6675cc
commit 8353a24f6b
17 files changed
+134 -138

No files matched your search

+2 -2
View File
@@ -246,7 +246,7 @@ export class DrizzleDatabase implements IDatabase {
}
// Fitness Profile operations
async createFitnessProfile(profileData: Omit<FitnessProfile, 'createdAt' | 'updatedAt'>): Promise<FitnessProfile> {
async createFitnessProfile(profileData: Omit<FitnessProfile, 'id' | 'createdAt' | 'updatedAt'>): Promise<FitnessProfile> {
const now = new Date()
const id = Math.random().toString(36).substr(2, 9)
const newProfile = {
@@ -257,7 +257,7 @@ export class DrizzleDatabase implements IDatabase {
}
await this.db.insert(fitnessProfiles).values(newProfile as any)
return { ...profileData, createdAt: now, updatedAt: now }
return { id, ...profileData, createdAt: now, updatedAt: now }
}
async getFitnessProfileByUserId(userId: string): Promise<FitnessProfile | null> {
+4 -78
View File
@@ -1,86 +1,12 @@
import { User as SharedUser, Client, FitnessProfile, Attendance, Recommendation, FitnessGoal } from "@fitai/shared";
// Database Entity Types
export interface User {
id: string;
email: string;
firstName: string;
lastName: string;
export interface User extends SharedUser {
password: string;
phone?: string;
role: "superAdmin" | "admin" | "trainer" | "client";
createdAt: Date;
updatedAt: Date;
}
export interface Client {
id: string;
userId: string;
membershipType: "basic" | "premium" | "vip";
membershipStatus: "active" | "inactive" | "expired";
joinDate: Date;
lastVisit?: Date;
}
export type { Client, FitnessProfile, Attendance, Recommendation, FitnessGoal };
export interface FitnessProfile {
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;
allergies?: string;
injuries?: string;
createdAt: Date;
updatedAt: Date;
}
export interface Attendance {
id: string;
userId: string;
checkInTime: Date;
checkOutTime?: Date;
type: "gym" | "class" | "personal_training";
notes?: string;
createdAt: Date;
}
export interface Recommendation {
id: string;
userId: string;
fitnessProfileId?: string;
type: "short_term" | "medium_term" | "long_term" | "ai_plan";
content: string;
activityPlan?: string;
dietPlan?: string;
status: "pending" | "approved" | "rejected" | "completed";
createdAt: Date;
approvedAt?: Date;
approvedBy?: string;
}
export interface FitnessGoal {
id: string;
userId: string;
fitnessProfileId?: string;
goalType: "weight_target" | "strength_milestone" | "endurance_target" | "flexibility_goal" | "habit_building" | "custom";
title: string;
description?: string;
targetValue?: number;
currentValue?: number;
unit?: string;
startDate: Date;
targetDate?: Date;
completedDate?: Date;
status: "active" | "completed" | "abandoned" | "paused";
progress: number;
priority: "low" | "medium" | "high";
notes?: string;
createdAt: Date;
updatedAt: Date;
}
// Database Interface - allows us to swap implementations
export interface IDatabase {