p 1 and 2 compeleted

This commit is contained in:
dimitar committed 2026-03-11 01:43:19 +01:00
1 parent 6adb541967
commit 3573709d99
28 files changed
+2533 -240

No files matched your search

+24
View File
@@ -128,6 +128,30 @@ export async function POST(req: Request) {
now,
);
// Auto-create client record for self-registered users (role is "client")
if (role === "client") {
const clientId = `cli_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
const clientStmt = db.prepare(`
INSERT INTO clients (id, user_id, membership_type, membership_status, join_date, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?)
`);
clientStmt.run(
clientId,
id,
"basic", // Default membership type
"active", // Default membership status
now,
now,
now,
);
log.info("Client record auto-created for self-registered user", {
userId: id,
clientId,
});
}
// If this is a client invited by a trainer, create trainer-client link
if (roleAssigned === "client" && inviterUserId && gymId) {
const inviterRow = db