basic stracture and auth
in memory db :)
This commit is contained in:
commit
3a554ba434
71 files changed
+28535
No files matched your search
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@fitai/shared",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^3.22.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './types'
|
||||
export * from './schemas'
|
||||
export * from './utils'
|
||||
@@ -0,0 +1,46 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const UserSchema = z.object({
|
||||
id: z.string(),
|
||||
email: z.string().email(),
|
||||
firstName: z.string().min(1),
|
||||
lastName: z.string().min(1),
|
||||
role: z.enum(['admin', 'trainer', 'client']),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
})
|
||||
|
||||
export const ClientSchema = z.object({
|
||||
id: z.string(),
|
||||
userId: z.string(),
|
||||
membershipType: z.enum(['basic', 'premium', 'vip']),
|
||||
membershipStatus: z.enum(['active', 'inactive', 'suspended']),
|
||||
joinDate: z.date(),
|
||||
lastVisit: z.date().optional(),
|
||||
emergencyContact: z.object({
|
||||
name: z.string(),
|
||||
phone: z.string(),
|
||||
relationship: z.string(),
|
||||
}),
|
||||
})
|
||||
|
||||
export const PaymentSchema = z.object({
|
||||
id: z.string(),
|
||||
clientId: z.string(),
|
||||
amount: z.number().positive(),
|
||||
currency: z.string(),
|
||||
status: z.enum(['pending', 'completed', 'failed', 'refunded']),
|
||||
paymentMethod: z.enum(['cash', 'card', 'bank_transfer']),
|
||||
dueDate: z.date(),
|
||||
paidAt: z.date().optional(),
|
||||
description: z.string(),
|
||||
})
|
||||
|
||||
export const AttendanceSchema = z.object({
|
||||
id: z.string(),
|
||||
clientId: z.string(),
|
||||
checkInTime: z.date(),
|
||||
checkOutTime: z.date().optional(),
|
||||
type: z.enum(['gym', 'class', 'personal_training']),
|
||||
notes: z.string().optional(),
|
||||
})
|
||||
@@ -0,0 +1,57 @@
|
||||
export interface User {
|
||||
id: string
|
||||
email: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
role: 'admin' | 'trainer' | 'client'
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
export interface Client {
|
||||
id: string
|
||||
userId: string
|
||||
user: User
|
||||
membershipType: 'basic' | 'premium' | 'vip'
|
||||
membershipStatus: 'active' | 'inactive' | 'suspended'
|
||||
joinDate: Date
|
||||
lastVisit?: Date
|
||||
emergencyContact: {
|
||||
name: string
|
||||
phone: string
|
||||
relationship: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface Payment {
|
||||
id: string
|
||||
clientId: string
|
||||
client: Client
|
||||
amount: number
|
||||
currency: string
|
||||
status: 'pending' | 'completed' | 'failed' | 'refunded'
|
||||
paymentMethod: 'cash' | 'card' | 'bank_transfer'
|
||||
dueDate: Date
|
||||
paidAt?: Date
|
||||
description: string
|
||||
}
|
||||
|
||||
export interface Attendance {
|
||||
id: string
|
||||
clientId: string
|
||||
client: Client
|
||||
checkInTime: Date
|
||||
checkOutTime?: Date
|
||||
type: 'gym' | 'class' | 'personal_training'
|
||||
notes?: string
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
id: string
|
||||
userId: string
|
||||
title: string
|
||||
message: string
|
||||
type: 'payment_reminder' | 'attendance' | 'promotion' | 'system'
|
||||
read: boolean
|
||||
createdAt: Date
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
export const formatDate = (date: Date): string => {
|
||||
return new Intl.DateTimeFormat('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
}).format(date)
|
||||
}
|
||||
|
||||
export const formatCurrency = (
|
||||
amount: number,
|
||||
currency: string = 'USD'
|
||||
): string => {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency,
|
||||
}).format(amount)
|
||||
}
|
||||
|
||||
export const calculateDaysBetween = (startDate: Date, endDate: Date): number => {
|
||||
const timeDiff = endDate.getTime() - startDate.getTime()
|
||||
return Math.ceil(timeDiff / (1000 * 3600 * 24))
|
||||
}
|
||||
|
||||
export const generateId = (): string => {
|
||||
return Math.random().toString(36).substr(2, 9)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"module": "commonjs",
|
||||
"lib": ["es2020"],
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Reference in new issue
Block a user