crud
admin crud ops implemented partialy
This commit is contained in:
parent
c357de515f
commit
9d2bfda0ca
Binary file not shown.
3
apps/admin/next-env.d.ts
vendored
3
apps/admin/next-env.d.ts
vendored
@ -1,5 +1,6 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
import "./.next/dev/types/routes.d.ts";
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||||
|
|||||||
4240
apps/admin/package-lock.json
generated
4240
apps/admin/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,38 +12,39 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fitai/shared": "file:../../packages/shared",
|
"@fitai/shared": "file:../../packages/shared",
|
||||||
"@hookform/resolvers": "^3.3.0",
|
"@hookform/resolvers": "^5.2.2",
|
||||||
"@tanstack/react-query": "^5.0.0",
|
"@tailwindcss/postcss": "^4.1.17",
|
||||||
"@types/bcryptjs": "^2.4.6",
|
"@tanstack/react-query": "^5.90.7",
|
||||||
"@types/sqlite3": "^3.1.11",
|
"@types/bcryptjs": "^3.0.0",
|
||||||
"ag-charts-community": "^9.0.0",
|
"@types/sqlite3": "^5.1.0",
|
||||||
"ag-charts-react": "^9.0.0",
|
"ag-charts-community": "^12.3.1",
|
||||||
"ag-grid-community": "^32.0.0",
|
"ag-charts-react": "^12.3.1",
|
||||||
"ag-grid-react": "^32.0.0",
|
"ag-grid-community": "^34.3.1",
|
||||||
"autoprefixer": "^10.4.0",
|
"ag-grid-react": "^34.3.1",
|
||||||
"axios": "^1.6.0",
|
"autoprefixer": "^10.4.21",
|
||||||
"bcryptjs": "^2.4.3",
|
"axios": "^1.13.2",
|
||||||
"lucide-react": "^0.294.0",
|
"bcryptjs": "^3.0.3",
|
||||||
"next": "^14.0.0",
|
"lucide-react": "^0.553.0",
|
||||||
"postcss": "^8.4.0",
|
"next": "^16.0.1",
|
||||||
"react": "^18.0.0",
|
"postcss": "^8.5.6",
|
||||||
"react-dom": "^18.0.0",
|
"react": "^19.2.0",
|
||||||
"react-hook-form": "^7.47.0",
|
"react-dom": "^19.2.0",
|
||||||
"recharts": "^2.8.0",
|
"react-hook-form": "^7.66.0",
|
||||||
|
"recharts": "^3.3.0",
|
||||||
"sqlite": "^5.1.1",
|
"sqlite": "^5.1.1",
|
||||||
"sqlite3": "^5.1.7",
|
"sqlite3": "^5.1.7",
|
||||||
"tailwindcss": "^3.3.0",
|
"tailwindcss": "^4.1.17",
|
||||||
"zod": "^3.22.0"
|
"zod": "^4.1.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^6.1.0",
|
"@testing-library/jest-dom": "^6.9.1",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@types/node": "^20.0.0",
|
"@types/node": "^24.10.0",
|
||||||
"@types/react": "18.3.26",
|
"@types/react": "19.2.2",
|
||||||
"@types/react-dom": "^18.0.0",
|
"@types/react-dom": "^19.2.2",
|
||||||
"eslint": "^8.45.0",
|
"eslint": "^9.39.1",
|
||||||
"eslint-config-next": "^14.0.0",
|
"eslint-config-next": "^16.0.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^30.2.0",
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: {
|
plugins: {
|
||||||
tailwindcss: {},
|
"@tailwindcss/postcss": {},
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|||||||
@ -1,32 +1,162 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server'
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { getDatabase } from '../../../lib/database/index'
|
import { getDatabase } from "../../../lib/database/index";
|
||||||
|
import bcrypt from "bcryptjs";
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const db = await getDatabase()
|
const db = await getDatabase();
|
||||||
const { searchParams } = new URL(request.url)
|
const { searchParams } = new URL(request.url);
|
||||||
const role = searchParams.get('role')
|
const role = searchParams.get("role");
|
||||||
|
|
||||||
let users = await db.getAllUsers()
|
let users = await db.getAllUsers();
|
||||||
|
|
||||||
if (role) {
|
if (role) {
|
||||||
users = users.filter(user => user.role === role)
|
users = users.filter((user) => user.role === role);
|
||||||
}
|
}
|
||||||
|
|
||||||
const usersWithClients = await Promise.all(
|
const usersWithClients = await Promise.all(
|
||||||
users.map(async (user) => {
|
users.map(async (user) => {
|
||||||
const { password: _, ...userWithoutPassword } = user
|
const { password: _, ...userWithoutPassword } = user;
|
||||||
const client = await db.getClientByUserId(user.id)
|
const client = await db.getClientByUserId(user.id);
|
||||||
return { ...userWithoutPassword, client }
|
return { ...userWithoutPassword, client };
|
||||||
})
|
}),
|
||||||
)
|
);
|
||||||
|
|
||||||
return NextResponse.json({ users: usersWithClients })
|
return NextResponse.json({ users: usersWithClients });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Get users error:', error)
|
console.error("Get users error:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Internal server error' },
|
{ error: "Internal server error" },
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function POST(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const db = await getDatabase();
|
||||||
|
const body = await request.json();
|
||||||
|
const { email, password, firstName, lastName, role, phone } = body;
|
||||||
|
|
||||||
|
if (!email || !password || !firstName || !lastName || !role) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Missing required fields" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if user already exists
|
||||||
|
const existingUser = await db.getUserByEmail(email);
|
||||||
|
if (existingUser) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "User with this email already exists" },
|
||||||
|
{ status: 409 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hash password
|
||||||
|
const hashedPassword = await bcrypt.hash(password, 12);
|
||||||
|
|
||||||
|
// Create user
|
||||||
|
const userId = await db.createUser({
|
||||||
|
email,
|
||||||
|
password: hashedPassword,
|
||||||
|
firstName,
|
||||||
|
lastName,
|
||||||
|
role,
|
||||||
|
phone,
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({ userId }, { status: 201 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Create user error:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Internal server error" },
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function PUT(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const db = await getDatabase();
|
||||||
|
const body = await request.json();
|
||||||
|
const { id, email, firstName, lastName, role, phone } = body;
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "User ID is required" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get existing user
|
||||||
|
const existingUser = await db.getUserById(id);
|
||||||
|
if (!existingUser) {
|
||||||
|
return NextResponse.json({ error: "User not found" }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if email is being changed and if it's already taken
|
||||||
|
if (email && email !== existingUser.email) {
|
||||||
|
const userWithEmail = await db.getUserByEmail(email);
|
||||||
|
if (userWithEmail) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Email already in use" },
|
||||||
|
{ status: 409 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update user
|
||||||
|
await db.updateUser(id, {
|
||||||
|
email: email || existingUser.email,
|
||||||
|
firstName: firstName || existingUser.firstName,
|
||||||
|
lastName: lastName || existingUser.lastName,
|
||||||
|
role: role || existingUser.role,
|
||||||
|
phone: phone !== undefined ? phone : existingUser.phone,
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Update user error:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Internal server error" },
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function DELETE(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const db = await getDatabase();
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const id = searchParams.get("id");
|
||||||
|
const body = await request.json().catch(() => ({}));
|
||||||
|
const { ids } = body;
|
||||||
|
|
||||||
|
if (ids && Array.isArray(ids)) {
|
||||||
|
// Bulk delete
|
||||||
|
await Promise.all(ids.map((userId: string) => db.deleteUser(userId)));
|
||||||
|
return NextResponse.json({ success: true, deleted: ids.length });
|
||||||
|
} else if (id) {
|
||||||
|
// Single delete
|
||||||
|
const user = await db.getUserById(id);
|
||||||
|
if (!user) {
|
||||||
|
return NextResponse.json({ error: "User not found" }, { status: 404 });
|
||||||
|
}
|
||||||
|
await db.deleteUser(id);
|
||||||
|
return NextResponse.json({ success: true });
|
||||||
|
} else {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "User ID or IDs array required" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Delete user error:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Internal server error" },
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import Link from 'next/link'
|
import Link from "next/link";
|
||||||
import { UserManagement } from '@/components/users/UserManagement'
|
import { UserManagement } from "@/components/users/UserManagement";
|
||||||
import { AnalyticsDashboard } from '@/components/analytics/AnalyticsDashboard'
|
import { AnalyticsDashboard } from "@/components/analytics/AnalyticsDashboard";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
@ -13,13 +13,13 @@ export default function Home() {
|
|||||||
FitAI Admin Dashboard
|
FitAI Admin Dashboard
|
||||||
</h1>
|
</h1>
|
||||||
<nav className="flex gap-4">
|
<nav className="flex gap-4">
|
||||||
<Link
|
<Link
|
||||||
href="/users"
|
href="/users"
|
||||||
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
||||||
>
|
>
|
||||||
User Management
|
User Management
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href="/analytics"
|
href="/analytics"
|
||||||
className="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors"
|
className="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors"
|
||||||
>
|
>
|
||||||
@ -27,11 +27,13 @@ export default function Home() {
|
|||||||
</Link>
|
</Link>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
|
||||||
<div className="bg-white rounded-lg shadow p-6">
|
<div className="bg-white rounded-lg shadow p-6">
|
||||||
<h2 className="text-xl font-semibold mb-4">Client Management</h2>
|
<h2 className="text-xl font-semibold mb-4">Client Management</h2>
|
||||||
<p className="text-gray-600">Manage fitness clients and their profiles</p>
|
<p className="text-gray-600">
|
||||||
|
Manage fitness clients and their profiles
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white rounded-lg shadow p-6">
|
<div className="bg-white rounded-lg shadow p-6">
|
||||||
<h2 className="text-xl font-semibold mb-4">Payment Tracking</h2>
|
<h2 className="text-xl font-semibold mb-4">Payment Tracking</h2>
|
||||||
@ -45,20 +47,22 @@ export default function Home() {
|
|||||||
|
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||||
<div className="bg-white rounded-lg shadow p-6">
|
<div className="bg-white rounded-lg shadow p-6">
|
||||||
<h2 className="text-2xl font-semibold mb-6">Recent User Activity</h2>
|
<h2 className="text-2xl font-semibold mb-6">
|
||||||
<div className="h-96">
|
Recent User Activity
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
<UserManagement />
|
<UserManagement />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-lg shadow p-6">
|
<div className="bg-white rounded-lg shadow p-6">
|
||||||
<h2 className="text-2xl font-semibold mb-6">Quick Analytics</h2>
|
<h2 className="text-2xl font-semibold mb-6">Quick Analytics</h2>
|
||||||
<div className="h-96">
|
<div>
|
||||||
<AnalyticsDashboard />
|
<AnalyticsDashboard />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,88 +1,102 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import React, { useMemo } from 'react'
|
import React, { useMemo } from "react";
|
||||||
import { AgChartsReact } from 'ag-charts-react'
|
import { AgCharts } from "ag-charts-react";
|
||||||
import { AgChartOptions } from 'ag-charts-community'
|
import { AgChartOptions } from "ag-charts-community";
|
||||||
|
|
||||||
interface PieData {
|
interface PieData {
|
||||||
label: string
|
label: string;
|
||||||
value: number
|
value: number;
|
||||||
color?: string
|
color?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MembershipDistributionChartProps {
|
interface MembershipDistributionChartProps {
|
||||||
data: PieData[]
|
data: PieData[];
|
||||||
title?: string
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MembershipDistributionChart({ data, title = 'Membership Distribution' }: MembershipDistributionChartProps) {
|
export function MembershipDistributionChart({
|
||||||
const chartOptions: AgChartOptions = useMemo(() => ({
|
data,
|
||||||
title: {
|
title = "Membership Distribution",
|
||||||
text: title,
|
}: MembershipDistributionChartProps) {
|
||||||
fontSize: 18,
|
const chartOptions: AgChartOptions = useMemo(
|
||||||
fontWeight: 'bold',
|
() => ({
|
||||||
},
|
title: {
|
||||||
data,
|
text: title,
|
||||||
series: [
|
fontSize: 18,
|
||||||
{
|
fontWeight: "bold",
|
||||||
type: 'pie',
|
},
|
||||||
calloutLabelKey: 'label',
|
data,
|
||||||
angleKey: 'value',
|
series: [
|
||||||
sectorLabelKey: 'label',
|
{
|
||||||
fills: data.map(item => item.color || '#3b82f6'),
|
type: "pie",
|
||||||
strokes: ['#ffffff'],
|
calloutLabelKey: "label",
|
||||||
strokeWidth: 2,
|
angleKey: "value",
|
||||||
calloutLabel: {
|
sectorLabelKey: "label",
|
||||||
enabled: true,
|
fills: data.map((item) => item.color || "#3b82f6"),
|
||||||
fontSize: 12,
|
strokes: ["#ffffff"],
|
||||||
fontWeight: 'bold',
|
strokeWidth: 2,
|
||||||
},
|
calloutLabel: {
|
||||||
sectorLabel: {
|
enabled: true,
|
||||||
enabled: true,
|
fontSize: 12,
|
||||||
fontSize: 14,
|
fontWeight: "bold",
|
||||||
fontWeight: 'bold',
|
|
||||||
color: '#ffffff',
|
|
||||||
formatter: (params: any) => {
|
|
||||||
const percentage = ((params.datum.value / data.reduce((sum, item) => sum + item.value, 0)) * 100).toFixed(1)
|
|
||||||
return `${params.datum.label}: ${percentage}%`
|
|
||||||
},
|
},
|
||||||
},
|
sectorLabel: {
|
||||||
highlightStyle: {
|
enabled: true,
|
||||||
item: {
|
fontSize: 14,
|
||||||
fillOpacity: 0.8,
|
fontWeight: "bold",
|
||||||
stroke: '#000000',
|
color: "#ffffff",
|
||||||
strokeWidth: 2,
|
formatter: (params: any) => {
|
||||||
|
const percentage = (
|
||||||
|
(params.datum.value /
|
||||||
|
data.reduce((sum, item) => sum + item.value, 0)) *
|
||||||
|
100
|
||||||
|
).toFixed(1);
|
||||||
|
return `${params.datum.label}: ${percentage}%`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
highlightStyle: {
|
||||||
tooltip: {
|
item: {
|
||||||
enabled: true,
|
fillOpacity: 0.8,
|
||||||
renderer: (params: any) => {
|
stroke: "#000000",
|
||||||
const percentage = ((params.datum.value / data.reduce((sum, item) => sum + item.value, 0)) * 100).toFixed(1)
|
strokeWidth: 2,
|
||||||
return `<div class="bg-white p-2 rounded shadow-lg border">
|
},
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
enabled: true,
|
||||||
|
renderer: (params: any) => {
|
||||||
|
const percentage = (
|
||||||
|
(params.datum.value /
|
||||||
|
data.reduce((sum, item) => sum + item.value, 0)) *
|
||||||
|
100
|
||||||
|
).toFixed(1);
|
||||||
|
return `<div class="bg-white p-2 rounded shadow-lg border">
|
||||||
<div class="font-bold">${params.datum.label}</div>
|
<div class="font-bold">${params.datum.label}</div>
|
||||||
<div class="text-sm">Count: ${params.datum.value}</div>
|
<div class="text-sm">Count: ${params.datum.value}</div>
|
||||||
<div class="text-sm">Percentage: ${percentage}%</div>
|
<div class="text-sm">Percentage: ${percentage}%</div>
|
||||||
</div>`
|
</div>`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
legend: {
|
||||||
|
enabled: true,
|
||||||
|
position: "right",
|
||||||
|
fontSize: 12,
|
||||||
|
marker: {
|
||||||
|
shape: "square",
|
||||||
|
size: 12,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
padding: {
|
||||||
legend: {
|
top: 20,
|
||||||
enabled: true,
|
right: 20,
|
||||||
position: 'right',
|
bottom: 20,
|
||||||
fontSize: 12,
|
left: 20,
|
||||||
marker: {
|
|
||||||
shape: 'square',
|
|
||||||
size: 12,
|
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
padding: {
|
[data, title],
|
||||||
top: 20,
|
);
|
||||||
right: 20,
|
|
||||||
bottom: 20,
|
|
||||||
left: 20,
|
|
||||||
},
|
|
||||||
}), [data, title])
|
|
||||||
|
|
||||||
return <AgChartsReact options={chartOptions} />
|
return <AgCharts options={chartOptions} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,99 +1,105 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import React, { useMemo } from 'react'
|
import React, { useMemo } from "react";
|
||||||
import { AgChartsReact } from 'ag-charts-react'
|
import { AgCharts } from "ag-charts-react";
|
||||||
import { AgChartOptions } from 'ag-charts-community'
|
import { AgChartOptions } from "ag-charts-community";
|
||||||
|
|
||||||
interface BarData {
|
interface BarData {
|
||||||
category: string
|
category: string;
|
||||||
value: number
|
value: number;
|
||||||
color?: string
|
color?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RevenueChartProps {
|
interface RevenueChartProps {
|
||||||
data: BarData[]
|
data: BarData[];
|
||||||
title?: string
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RevenueChart({ data, title = 'Monthly Revenue' }: RevenueChartProps) {
|
export function RevenueChart({
|
||||||
const chartOptions: AgChartOptions = useMemo(() => ({
|
data,
|
||||||
title: {
|
title = "Monthly Revenue",
|
||||||
text: title,
|
}: RevenueChartProps) {
|
||||||
fontSize: 18,
|
const chartOptions: AgChartOptions = useMemo(
|
||||||
fontWeight: 'bold',
|
() => ({
|
||||||
},
|
title: {
|
||||||
data,
|
text: title,
|
||||||
series: [
|
fontSize: 18,
|
||||||
{
|
fontWeight: "bold",
|
||||||
type: 'bar',
|
},
|
||||||
xKey: 'category',
|
data,
|
||||||
yKey: 'value',
|
series: [
|
||||||
fills: data.map(item => item.color || '#10b981'),
|
{
|
||||||
strokes: ['#ffffff'],
|
type: "bar",
|
||||||
strokeWidth: 2,
|
xKey: "category",
|
||||||
cornerRadius: 4,
|
yKey: "value",
|
||||||
highlightStyle: {
|
fills: data.map((item) => item.color || "#10b981"),
|
||||||
item: {
|
strokes: ["#ffffff"],
|
||||||
fill: '#059669',
|
strokeWidth: 2,
|
||||||
stroke: '#ffffff',
|
cornerRadius: 4,
|
||||||
strokeWidth: 2,
|
highlightStyle: {
|
||||||
|
item: {
|
||||||
|
fill: "#059669",
|
||||||
|
stroke: "#ffffff",
|
||||||
|
strokeWidth: 2,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
label: {
|
||||||
label: {
|
enabled: true,
|
||||||
enabled: true,
|
position: "top",
|
||||||
position: 'top',
|
fontSize: 12,
|
||||||
fontSize: 12,
|
fontWeight: "bold",
|
||||||
fontWeight: 'bold',
|
color: "#374151",
|
||||||
color: '#374151',
|
formatter: (params: any) => `$${params.value.toLocaleString()}`,
|
||||||
formatter: (params: any) => `$${params.value.toLocaleString()}`,
|
},
|
||||||
},
|
tooltip: {
|
||||||
tooltip: {
|
enabled: true,
|
||||||
enabled: true,
|
renderer: (params: any) => {
|
||||||
renderer: (params: any) => {
|
return `<div class="bg-white p-2 rounded shadow-lg border">
|
||||||
return `<div class="bg-white p-2 rounded shadow-lg border">
|
|
||||||
<div class="font-bold">${params.datum.category}</div>
|
<div class="font-bold">${params.datum.category}</div>
|
||||||
<div class="text-sm">Revenue: $${params.datum.value.toLocaleString()}</div>
|
<div class="text-sm">Revenue: $${params.datum.value.toLocaleString()}</div>
|
||||||
</div>`
|
</div>`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
axes: [
|
||||||
|
{
|
||||||
|
type: "category",
|
||||||
|
position: "bottom",
|
||||||
|
title: {
|
||||||
|
text: "Month",
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
fontSize: 12,
|
||||||
|
rotation: 45,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "number",
|
||||||
|
position: "left",
|
||||||
|
title: {
|
||||||
|
text: "Revenue ($)",
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
fontSize: 12,
|
||||||
|
formatter: (params: any) => `$${params.value.toLocaleString()}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
legend: {
|
||||||
|
enabled: false,
|
||||||
},
|
},
|
||||||
],
|
padding: {
|
||||||
axes: [
|
top: 20,
|
||||||
{
|
right: 20,
|
||||||
type: 'category',
|
bottom: 60,
|
||||||
position: 'bottom',
|
left: 80,
|
||||||
title: {
|
|
||||||
text: 'Month',
|
|
||||||
fontSize: 14,
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
fontSize: 12,
|
|
||||||
rotation: 45,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
}),
|
||||||
type: 'number',
|
[data, title],
|
||||||
position: 'left',
|
);
|
||||||
title: {
|
|
||||||
text: 'Revenue ($)',
|
|
||||||
fontSize: 14,
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
fontSize: 12,
|
|
||||||
formatter: (params: any) => `$${params.value.toLocaleString()}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
legend: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
padding: {
|
|
||||||
top: 20,
|
|
||||||
right: 20,
|
|
||||||
bottom: 60,
|
|
||||||
left: 80,
|
|
||||||
},
|
|
||||||
}), [data, title])
|
|
||||||
|
|
||||||
return <AgChartsReact options={chartOptions} />
|
return <AgCharts options={chartOptions} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,78 +1,84 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import React, { useMemo } from 'react'
|
import React, { useMemo } from "react";
|
||||||
import { AgChartsReact } from 'ag-charts-react'
|
import { AgCharts } from "ag-charts-react";
|
||||||
import { AgChartOptions } from 'ag-charts-community'
|
import { AgChartOptions } from "ag-charts-community";
|
||||||
|
|
||||||
interface ChartData {
|
interface ChartData {
|
||||||
label: string
|
label: string;
|
||||||
value: number
|
value: number;
|
||||||
color?: string
|
color?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserGrowthChartProps {
|
interface UserGrowthChartProps {
|
||||||
data: ChartData[]
|
data: ChartData[];
|
||||||
title?: string
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UserGrowthChart({ data, title = 'User Growth' }: UserGrowthChartProps) {
|
export function UserGrowthChart({
|
||||||
const chartOptions: AgChartOptions = useMemo(() => ({
|
data,
|
||||||
title: {
|
title = "User Growth",
|
||||||
text: title,
|
}: UserGrowthChartProps) {
|
||||||
fontSize: 18,
|
const chartOptions: AgChartOptions = useMemo(
|
||||||
fontWeight: 'bold',
|
() => ({
|
||||||
},
|
title: {
|
||||||
data,
|
text: title,
|
||||||
series: [
|
fontSize: 18,
|
||||||
{
|
fontWeight: "bold",
|
||||||
type: 'line',
|
},
|
||||||
xKey: 'label',
|
data,
|
||||||
yKey: 'value',
|
series: [
|
||||||
stroke: '#3b82f6',
|
{
|
||||||
strokeWidth: 3,
|
type: "line",
|
||||||
marker: {
|
xKey: "label",
|
||||||
size: 6,
|
yKey: "value",
|
||||||
fill: '#3b82f6',
|
stroke: "#3b82f6",
|
||||||
stroke: '#ffffff',
|
strokeWidth: 3,
|
||||||
strokeWidth: 2,
|
marker: {
|
||||||
},
|
size: 6,
|
||||||
highlightStyle: {
|
fill: "#3b82f6",
|
||||||
item: {
|
stroke: "#ffffff",
|
||||||
fill: '#1d4ed8',
|
|
||||||
stroke: '#ffffff',
|
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
},
|
},
|
||||||
|
highlightStyle: {
|
||||||
|
item: {
|
||||||
|
fill: "#1d4ed8",
|
||||||
|
stroke: "#ffffff",
|
||||||
|
strokeWidth: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
axes: [
|
||||||
axes: [
|
{
|
||||||
{
|
type: "category",
|
||||||
type: 'category',
|
position: "bottom",
|
||||||
position: 'bottom',
|
title: {
|
||||||
title: {
|
text: "Time Period",
|
||||||
text: 'Time Period',
|
fontSize: 14,
|
||||||
fontSize: 14,
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
type: "number",
|
||||||
type: 'number',
|
position: "left",
|
||||||
position: 'left',
|
title: {
|
||||||
title: {
|
text: "Number of Users",
|
||||||
text: 'Number of Users',
|
fontSize: 14,
|
||||||
fontSize: 14,
|
},
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
legend: {
|
||||||
|
enabled: false,
|
||||||
},
|
},
|
||||||
],
|
padding: {
|
||||||
legend: {
|
top: 20,
|
||||||
enabled: false,
|
right: 20,
|
||||||
},
|
bottom: 20,
|
||||||
padding: {
|
left: 20,
|
||||||
top: 20,
|
},
|
||||||
right: 20,
|
}),
|
||||||
bottom: 20,
|
[data, title],
|
||||||
left: 20,
|
);
|
||||||
},
|
|
||||||
}), [data, title])
|
|
||||||
|
|
||||||
return <AgChartsReact options={chartOptions} />
|
return <AgCharts options={chartOptions} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,167 +1,248 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import React, { useState, useMemo } from 'react'
|
import React, { useState, useMemo } from "react";
|
||||||
import { AgGridReact } from 'ag-grid-react'
|
import { AgGridReact } from "ag-grid-react";
|
||||||
import { ColDef } from 'ag-grid-community'
|
import { ColDef, ModuleRegistry, AllCommunityModule } from "ag-grid-community";
|
||||||
import 'ag-grid-community/styles/ag-grid.css'
|
import "ag-grid-community/styles/ag-grid.css";
|
||||||
import 'ag-grid-community/styles/ag-theme-alpine.css'
|
import "ag-grid-community/styles/ag-theme-alpine.css";
|
||||||
import { formatDate } from '@/lib/utils'
|
import { formatDate } from "@/lib/utils";
|
||||||
|
|
||||||
|
ModuleRegistry.registerModules([AllCommunityModule]);
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
id: string
|
id: string;
|
||||||
email: string
|
email: string;
|
||||||
firstName: string
|
firstName: string;
|
||||||
lastName: string
|
lastName: string;
|
||||||
role: string
|
role: string;
|
||||||
phone?: string
|
phone?: string;
|
||||||
createdAt: Date
|
createdAt: Date;
|
||||||
client?: {
|
client?: {
|
||||||
id: string
|
id: string;
|
||||||
membershipType: string
|
membershipType: string;
|
||||||
membershipStatus: string
|
membershipStatus: string;
|
||||||
joinDate: Date
|
joinDate: Date;
|
||||||
lastVisit?: Date
|
lastVisit?: Date;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserGridProps {
|
interface UserGridProps {
|
||||||
users: User[]
|
users: User[];
|
||||||
onUserSelect?: (user: User) => void
|
onUserSelect?: (user: User) => void;
|
||||||
loading?: boolean
|
onEditUser?: (user: User) => void;
|
||||||
|
onDeleteUser?: (user: User) => void;
|
||||||
|
onBulkDelete?: (users: User[]) => void;
|
||||||
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UserGrid({ users, onUserSelect, loading = false }: UserGridProps) {
|
export function UserGrid({
|
||||||
const [selectedUser, setSelectedUser] = useState<User | null>(null)
|
users,
|
||||||
|
onUserSelect,
|
||||||
|
onEditUser,
|
||||||
|
onDeleteUser,
|
||||||
|
onBulkDelete,
|
||||||
|
loading = false,
|
||||||
|
}: UserGridProps) {
|
||||||
|
const [selectedUsers, setSelectedUsers] = useState<User[]>([]);
|
||||||
|
const [searchQuery, setSearchQuery] = useState<string>("");
|
||||||
|
|
||||||
const columnDefs: ColDef<User>[] = useMemo(() => [
|
const columnDefs: ColDef<User>[] = useMemo(
|
||||||
{
|
() => [
|
||||||
headerName: 'Name',
|
{
|
||||||
valueGetter: (params) => `${params.data?.firstName} ${params.data?.lastName}`,
|
headerName: "Name",
|
||||||
filter: 'agTextColumnFilter',
|
valueGetter: (params) =>
|
||||||
sortable: true,
|
`${params.data?.firstName} ${params.data?.lastName}`,
|
||||||
minWidth: 150,
|
filter: "agTextColumnFilter",
|
||||||
},
|
sortable: true,
|
||||||
{
|
minWidth: 150,
|
||||||
headerName: 'Email',
|
|
||||||
field: 'email',
|
|
||||||
filter: 'agTextColumnFilter',
|
|
||||||
sortable: true,
|
|
||||||
minWidth: 200,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headerName: 'Role',
|
|
||||||
field: 'role',
|
|
||||||
filter: 'agSetColumnFilter',
|
|
||||||
sortable: true,
|
|
||||||
cellRenderer: (params: any) => {
|
|
||||||
const roleColors = {
|
|
||||||
admin: 'bg-purple-100 text-purple-800',
|
|
||||||
trainer: 'bg-blue-100 text-blue-800',
|
|
||||||
client: 'bg-green-100 text-green-800',
|
|
||||||
}
|
|
||||||
const colorClass = roleColors[params.value as keyof typeof roleColors] || 'bg-gray-100 text-gray-800'
|
|
||||||
return `<span class="px-2 py-1 rounded text-xs font-medium ${colorClass}">${params.value}</span>`
|
|
||||||
},
|
},
|
||||||
minWidth: 120,
|
{
|
||||||
},
|
headerName: "Email",
|
||||||
{
|
field: "email",
|
||||||
headerName: 'Phone',
|
filter: "agTextColumnFilter",
|
||||||
field: 'phone',
|
sortable: true,
|
||||||
filter: 'agTextColumnFilter',
|
minWidth: 200,
|
||||||
sortable: true,
|
|
||||||
minWidth: 130,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headerName: 'Membership',
|
|
||||||
valueGetter: (params) => params.data?.client?.membershipType || 'N/A',
|
|
||||||
filter: 'agSetColumnFilter',
|
|
||||||
sortable: true,
|
|
||||||
cellRenderer: (params: any) => {
|
|
||||||
if (!params.value || params.value === 'N/A') return 'N/A'
|
|
||||||
|
|
||||||
const membershipColors = {
|
|
||||||
vip: 'bg-yellow-100 text-yellow-800',
|
|
||||||
premium: 'bg-blue-100 text-blue-800',
|
|
||||||
basic: 'bg-gray-100 text-gray-800',
|
|
||||||
}
|
|
||||||
const colorClass = membershipColors[params.value as keyof typeof membershipColors] || 'bg-gray-100 text-gray-800'
|
|
||||||
return `<span class="px-2 py-1 rounded text-xs font-medium ${colorClass}">${params.value}</span>`
|
|
||||||
},
|
},
|
||||||
minWidth: 120,
|
{
|
||||||
},
|
headerName: "Role",
|
||||||
{
|
field: "role",
|
||||||
headerName: 'Status',
|
filter: "agTextColumnFilter",
|
||||||
valueGetter: (params) => params.data?.client?.membershipStatus || 'N/A',
|
sortable: true,
|
||||||
filter: 'agSetColumnFilter',
|
cellRenderer: (params: any) => {
|
||||||
sortable: true,
|
const roleColors = {
|
||||||
cellRenderer: (params: any) => {
|
admin: "bg-purple-100 text-purple-800",
|
||||||
if (!params.value || params.value === 'N/A') return 'N/A'
|
trainer: "bg-blue-100 text-blue-800",
|
||||||
|
client: "bg-green-100 text-green-800",
|
||||||
const statusColors = {
|
};
|
||||||
active: 'bg-green-100 text-green-800',
|
const colorClass =
|
||||||
inactive: 'bg-red-100 text-red-800',
|
roleColors[params.value as keyof typeof roleColors] ||
|
||||||
suspended: 'bg-yellow-100 text-yellow-800',
|
"bg-gray-100 text-gray-800";
|
||||||
}
|
return `<span class="px-2 py-1 rounded text-xs font-medium ${colorClass}">${params.value}</span>`;
|
||||||
const colorClass = statusColors[params.value as keyof typeof statusColors] || 'bg-gray-100 text-gray-800'
|
},
|
||||||
return `<span class="px-2 py-1 rounded text-xs font-medium ${colorClass}">${params.value}</span>`
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
minWidth: 120,
|
{
|
||||||
},
|
headerName: "Phone",
|
||||||
{
|
field: "phone",
|
||||||
headerName: 'Join Date',
|
filter: "agTextColumnFilter",
|
||||||
valueGetter: (params) => params.data?.client?.joinDate || params.data?.createdAt,
|
sortable: true,
|
||||||
filter: 'agDateColumnFilter',
|
minWidth: 130,
|
||||||
sortable: true,
|
},
|
||||||
valueFormatter: (params: any) => formatDate(new Date(params.value)),
|
{
|
||||||
minWidth: 120,
|
headerName: "Membership",
|
||||||
},
|
valueGetter: (params) => params.data?.client?.membershipType || "N/A",
|
||||||
{
|
filter: "agTextColumnFilter",
|
||||||
headerName: 'Last Visit',
|
sortable: true,
|
||||||
valueGetter: (params) => params.data?.client?.lastVisit,
|
cellRenderer: (params: any) => {
|
||||||
filter: 'agDateColumnFilter',
|
if (!params.value || params.value === "N/A") return "N/A";
|
||||||
sortable: true,
|
|
||||||
valueFormatter: (params: any) => params.value ? formatDate(new Date(params.value)) : 'Never',
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
], [])
|
|
||||||
|
|
||||||
const defaultColDef: ColDef = useMemo(() => ({
|
const membershipColors = {
|
||||||
flex: 1,
|
vip: "bg-yellow-100 text-yellow-800",
|
||||||
resizable: true,
|
premium: "bg-blue-100 text-blue-800",
|
||||||
floatingFilter: true,
|
basic: "bg-gray-100 text-gray-800",
|
||||||
suppressMenu: true,
|
};
|
||||||
}), [])
|
const colorClass =
|
||||||
|
membershipColors[params.value as keyof typeof membershipColors] ||
|
||||||
|
"bg-gray-100 text-gray-800";
|
||||||
|
return `<span class="px-2 py-1 rounded text-xs font-medium ${colorClass}">${params.value}</span>`;
|
||||||
|
},
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headerName: "Status",
|
||||||
|
valueGetter: (params) => params.data?.client?.membershipStatus || "N/A",
|
||||||
|
filter: "agTextColumnFilter",
|
||||||
|
sortable: true,
|
||||||
|
cellRenderer: (params: any) => {
|
||||||
|
if (!params.value || params.value === "N/A") return "N/A";
|
||||||
|
|
||||||
const onSelectionChanged = () => {
|
const statusColors = {
|
||||||
const selectedNodes = gridRef.current?.api.getSelectedNodes()
|
active: "bg-green-100 text-green-800",
|
||||||
if (selectedNodes?.length > 0) {
|
inactive: "bg-red-100 text-red-800",
|
||||||
const user = selectedNodes[0].data
|
suspended: "bg-yellow-100 text-yellow-800",
|
||||||
setSelectedUser(user)
|
};
|
||||||
onUserSelect?.(user)
|
const colorClass =
|
||||||
}
|
statusColors[params.value as keyof typeof statusColors] ||
|
||||||
}
|
"bg-gray-100 text-gray-800";
|
||||||
|
return `<span class="px-2 py-1 rounded text-xs font-medium ${colorClass}">${params.value}</span>`;
|
||||||
|
},
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headerName: "Join Date",
|
||||||
|
valueGetter: (params) =>
|
||||||
|
params.data?.client?.joinDate || params.data?.createdAt,
|
||||||
|
filter: "agDateColumnFilter",
|
||||||
|
sortable: true,
|
||||||
|
valueFormatter: (params: any) => formatDate(new Date(params.value)),
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headerName: "Last Visit",
|
||||||
|
valueGetter: (params) => params.data?.client?.lastVisit,
|
||||||
|
filter: "agDateColumnFilter",
|
||||||
|
sortable: true,
|
||||||
|
valueFormatter: (params: any) =>
|
||||||
|
params.value ? formatDate(new Date(params.value)) : "Never",
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
const gridRef = React.useRef<AgGridReact<User>>(null)
|
const defaultColDef: ColDef = useMemo(
|
||||||
|
() => ({
|
||||||
|
flex: 1,
|
||||||
|
resizable: true,
|
||||||
|
floatingFilter: true,
|
||||||
|
suppressMenu: true,
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const gridRef = React.useRef<AgGridReact<User>>(null);
|
||||||
|
|
||||||
const gridOptions = {
|
const gridOptions = {
|
||||||
|
theme: "legacy",
|
||||||
columnDefs,
|
columnDefs,
|
||||||
defaultColDef,
|
defaultColDef,
|
||||||
rowData: users,
|
rowData: users,
|
||||||
rowSelection: 'single',
|
rowSelection: "multiple",
|
||||||
onSelectionChanged,
|
onSelectionChanged: () => {
|
||||||
enableRangeSelection: true,
|
const selectedNodes = gridRef.current?.api.getSelectedNodes();
|
||||||
enableCellTextSelection: true,
|
const selectedData = selectedNodes?.map((node) => node.data) || [];
|
||||||
|
setSelectedUsers(selectedData);
|
||||||
|
if (selectedData.length === 1 && onUserSelect) {
|
||||||
|
onUserSelect(selectedData[0]);
|
||||||
|
}
|
||||||
|
},
|
||||||
suppressRowClickSelection: false,
|
suppressRowClickSelection: false,
|
||||||
animateRows: true,
|
animateRows: true,
|
||||||
loading: loading,
|
loading: loading,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
paginationPageSize: 20,
|
paginationPageSize: 20,
|
||||||
paginationPageSizeSelector: [10, 20, 50, 100],
|
paginationPageSizeSelector: [10, 20, 50, 100],
|
||||||
}
|
quickFilterText: searchQuery,
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEdit = () => {
|
||||||
|
if (selectedUsers.length === 1 && onEditUser) {
|
||||||
|
onEditUser(selectedUsers[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
if (selectedUsers.length === 1 && onDeleteUser) {
|
||||||
|
onDeleteUser(selectedUsers[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBulkDelete = () => {
|
||||||
|
if (selectedUsers.length > 0 && onBulkDelete) {
|
||||||
|
onBulkDelete(selectedUsers);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ag-theme-alpine" style={{ height: '600px', width: '100%' }}>
|
<div>
|
||||||
<AgGridReact<User> {...gridOptions} ref={gridRef} />
|
<div className="flex justify-between items-center mb-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search users..."
|
||||||
|
className="border border-gray-300 rounded px-4 py-2"
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
/>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button
|
||||||
|
className="bg-green-500 text-white px-4 py-2 rounded disabled:opacity-50"
|
||||||
|
onClick={handleEdit}
|
||||||
|
disabled={selectedUsers.length !== 1}
|
||||||
|
>
|
||||||
|
Edit User
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="bg-red-500 text-white px-4 py-2 rounded disabled:opacity-50"
|
||||||
|
onClick={handleDelete}
|
||||||
|
disabled={selectedUsers.length !== 1}
|
||||||
|
>
|
||||||
|
Delete User
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="bg-yellow-500 text-white px-4 py-2 rounded disabled:opacity-50"
|
||||||
|
onClick={handleBulkDelete}
|
||||||
|
disabled={selectedUsers.length === 0}
|
||||||
|
>
|
||||||
|
Bulk Delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="ag-theme-alpine"
|
||||||
|
style={{ height: "600px", width: "100%" }}
|
||||||
|
>
|
||||||
|
<AgGridReact<User> {...gridOptions} ref={gridRef} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,85 +1,182 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from "react";
|
||||||
import { UserGrid } from '@/components/users/UserGrid'
|
import { UserGrid } from "@/components/users/UserGrid";
|
||||||
import { Button } from '@/components/ui/Button'
|
import { Button } from "@/components/ui/Button";
|
||||||
import { Card, CardHeader, CardContent } from '@/components/ui/Card'
|
import { Card, CardHeader, CardContent } from "@/components/ui/Card";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
id: string
|
id: string;
|
||||||
email: string
|
email: string;
|
||||||
firstName: string
|
firstName: string;
|
||||||
lastName: string
|
lastName: string;
|
||||||
role: string
|
role: string;
|
||||||
phone?: string
|
phone?: string;
|
||||||
createdAt: Date
|
createdAt: Date;
|
||||||
client?: {
|
client?: {
|
||||||
id: string
|
id: string;
|
||||||
membershipType: string
|
membershipType: string;
|
||||||
membershipStatus: string
|
membershipStatus: string;
|
||||||
joinDate: Date
|
joinDate: Date;
|
||||||
lastVisit?: Date
|
lastVisit?: Date;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UserManagement() {
|
export function UserManagement() {
|
||||||
const [users, setUsers] = useState<User[]>([])
|
const [users, setUsers] = useState<User[]>([]);
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true);
|
||||||
const [filter, setFilter] = useState<string>('all')
|
const [filter, setFilter] = useState<string>("all");
|
||||||
const [selectedUser, setSelectedUser] = useState<User | null>(null)
|
const [selectedUser, setSelectedUser] = useState<User | null>(null);
|
||||||
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
|
const [editForm, setEditForm] = useState<{
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
email: string;
|
||||||
|
role: string;
|
||||||
|
phone: string;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchUsers()
|
fetchUsers();
|
||||||
}, [filter])
|
}, [filter]);
|
||||||
|
|
||||||
const fetchUsers = async () => {
|
const fetchUsers = async () => {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const url = filter === 'all'
|
const url = filter === "all" ? "/api/users" : `/api/users?role=${filter}`;
|
||||||
? '/api/users'
|
|
||||||
: `/api/users?role=${filter}`
|
|
||||||
|
|
||||||
const response = await fetch(url)
|
|
||||||
const data = await response.json()
|
|
||||||
setUsers(data.users || [])
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch users:', error)
|
|
||||||
} finally {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleUserSelect = (user: User) => {
|
const response = await fetch(url);
|
||||||
setSelectedUser(user)
|
const data = await response.json();
|
||||||
}
|
setUsers(data.users || []);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch users:", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUserSelect = (user: User | null) => {
|
||||||
|
setSelectedUser(user);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEditUser = (user: User) => {
|
||||||
|
setSelectedUser(user);
|
||||||
|
setEditForm({
|
||||||
|
firstName: user.firstName,
|
||||||
|
lastName: user.lastName,
|
||||||
|
email: user.email,
|
||||||
|
role: user.role,
|
||||||
|
phone: user.phone || "",
|
||||||
|
});
|
||||||
|
setIsEditing(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteUser = (user: User) => {
|
||||||
|
setSelectedUser(user);
|
||||||
|
setIsDeleting(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBulkDelete = async (users: User[]) => {
|
||||||
|
if (users.length === 0) return;
|
||||||
|
|
||||||
|
if (!confirm(`Are you sure you want to delete ${users.length} users?`))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/users", {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ ids: users.map((u) => u.id) }),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
fetchUsers();
|
||||||
|
} else {
|
||||||
|
alert("Error deleting users");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleExport = () => {
|
const handleExport = () => {
|
||||||
const csvContent = [
|
const csvContent = [
|
||||||
['Name', 'Email', 'Role', 'Phone', 'Membership', 'Status', 'Join Date', 'Last Visit'],
|
[
|
||||||
...users.map(user => [
|
"Name",
|
||||||
|
"Email",
|
||||||
|
"Role",
|
||||||
|
"Phone",
|
||||||
|
"Membership",
|
||||||
|
"Status",
|
||||||
|
"Join Date",
|
||||||
|
"Last Visit",
|
||||||
|
],
|
||||||
|
...users.map((user) => [
|
||||||
`${user.firstName} ${user.lastName}`,
|
`${user.firstName} ${user.lastName}`,
|
||||||
user.email,
|
user.email,
|
||||||
user.role,
|
user.role,
|
||||||
user.phone || '',
|
user.phone || "",
|
||||||
user.client?.membershipType || '',
|
user.client?.membershipType || "",
|
||||||
user.client?.membershipStatus || '',
|
user.client?.membershipStatus || "",
|
||||||
user.client?.joinDate || user.createdAt,
|
user.client?.joinDate || user.createdAt,
|
||||||
user.client?.lastVisit || ''
|
user.client?.lastVisit || "",
|
||||||
])
|
]),
|
||||||
].map(row => row.join(',')).join('\n')
|
]
|
||||||
|
.map((row) => row.join(","))
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
const blob = new Blob([csvContent], { type: 'text/csv' })
|
const blob = new Blob([csvContent], { type: "text/csv" });
|
||||||
const url = window.URL.createObjectURL(blob)
|
const url = window.URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a')
|
const a = document.createElement("a");
|
||||||
a.href = url
|
a.href = url;
|
||||||
a.download = `users_${new Date().toISOString().split('T')[0]}.csv`
|
a.download = `users_${new Date().toISOString().split("T")[0]}.csv`;
|
||||||
a.click()
|
a.click();
|
||||||
window.URL.revokeObjectURL(url)
|
window.URL.revokeObjectURL(url);
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleRefresh = () => {
|
const handleRefresh = () => {
|
||||||
fetchUsers()
|
fetchUsers();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const handleSaveEdit = async () => {
|
||||||
|
if (!editForm || !selectedUser) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/users", {
|
||||||
|
method: "PUT",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ id: selectedUser.id, ...editForm }),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
setIsEditing(false);
|
||||||
|
setEditForm(null);
|
||||||
|
fetchUsers();
|
||||||
|
} else {
|
||||||
|
alert("Error updating user");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteConfirm = async () => {
|
||||||
|
if (!selectedUser) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/users?id=${selectedUser.id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
setIsDeleting(false);
|
||||||
|
setSelectedUser(null);
|
||||||
|
fetchUsers();
|
||||||
|
} else {
|
||||||
|
alert("Error deleting user");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@ -87,26 +184,40 @@ export function UserManagement() {
|
|||||||
<h2 className="text-2xl font-bold">User Management</h2>
|
<h2 className="text-2xl font-bold">User Management</h2>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant={filter === 'all' ? 'primary' : 'secondary'}
|
variant={filter === "all" ? "primary" : "secondary"}
|
||||||
onClick={() => setFilter('all')}
|
onClick={() => setFilter("all")}
|
||||||
>
|
>
|
||||||
All Users
|
All Users
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={filter === 'client' ? 'primary' : 'secondary'}
|
variant="secondary"
|
||||||
onClick={() => setFilter('client')}
|
onClick={handleEditUser}
|
||||||
|
disabled={!selectedUser}
|
||||||
|
>
|
||||||
|
Edit User
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={handleDeleteUser}
|
||||||
|
disabled={!selectedUser}
|
||||||
|
>
|
||||||
|
Delete User
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant={filter === "client" ? "primary" : "secondary"}
|
||||||
|
onClick={() => setFilter("client")}
|
||||||
>
|
>
|
||||||
Clients
|
Clients
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={filter === 'trainer' ? 'primary' : 'secondary'}
|
variant={filter === "trainer" ? "primary" : "secondary"}
|
||||||
onClick={() => setFilter('trainer')}
|
onClick={() => setFilter("trainer")}
|
||||||
>
|
>
|
||||||
Trainers
|
Trainers
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={filter === 'admin' ? 'primary' : 'secondary'}
|
variant={filter === "admin" ? "primary" : "secondary"}
|
||||||
onClick={() => setFilter('admin')}
|
onClick={() => setFilter("admin")}
|
||||||
>
|
>
|
||||||
Admins
|
Admins
|
||||||
</Button>
|
</Button>
|
||||||
@ -134,14 +245,142 @@ export function UserManagement() {
|
|||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="p-0">
|
<CardContent className="p-0">
|
||||||
<UserGrid
|
<UserGrid
|
||||||
users={users}
|
users={users}
|
||||||
onUserSelect={handleUserSelect}
|
onUserSelect={(user) => handleUserSelect(user)}
|
||||||
|
onEditUser={handleEditUser}
|
||||||
|
onDeleteUser={handleDeleteUser}
|
||||||
|
onBulkDelete={handleBulkDelete}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
{isEditing && editForm && (
|
||||||
|
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
||||||
|
<div className="bg-white p-6 rounded-lg shadow-lg max-w-md w-full">
|
||||||
|
<h3 className="text-lg font-semibold mb-4">Edit User</h3>
|
||||||
|
<form
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
handleSaveEdit();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium mb-1">
|
||||||
|
First Name
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={editForm.firstName}
|
||||||
|
onChange={(e) =>
|
||||||
|
setEditForm({ ...editForm, firstName: e.target.value })
|
||||||
|
}
|
||||||
|
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium mb-1">
|
||||||
|
Last Name
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={editForm.lastName}
|
||||||
|
onChange={(e) =>
|
||||||
|
setEditForm({ ...editForm, lastName: e.target.value })
|
||||||
|
}
|
||||||
|
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium mb-1">Email</label>
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
value={editForm.email}
|
||||||
|
onChange={(e) =>
|
||||||
|
setEditForm({ ...editForm, email: e.target.value })
|
||||||
|
}
|
||||||
|
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium mb-1">Role</label>
|
||||||
|
<select
|
||||||
|
value={editForm.role}
|
||||||
|
onChange={(e) =>
|
||||||
|
setEditForm({ ...editForm, role: e.target.value })
|
||||||
|
}
|
||||||
|
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<option value="client">Client</option>
|
||||||
|
<option value="trainer">Trainer</option>
|
||||||
|
<option value="admin">Admin</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div className="mb-4">
|
||||||
|
<label className="block text-sm font-medium mb-1">Phone</label>
|
||||||
|
<input
|
||||||
|
type="tel"
|
||||||
|
value={editForm.phone}
|
||||||
|
onChange={(e) =>
|
||||||
|
setEditForm({ ...editForm, phone: e.target.value })
|
||||||
|
}
|
||||||
|
className="w-full border border-gray-300 rounded px-3 py-2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
setIsEditing(false);
|
||||||
|
setEditForm(null);
|
||||||
|
}}
|
||||||
|
className="px-4 py-2 bg-gray-300 text-gray-700 rounded hover:bg-gray-400"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isDeleting && selectedUser && (
|
||||||
|
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
||||||
|
<div className="bg-white p-6 rounded-lg shadow-lg max-w-md w-full">
|
||||||
|
<h3 className="text-lg font-semibold mb-4">Delete User</h3>
|
||||||
|
<p className="mb-4">
|
||||||
|
Are you sure you want to delete {selectedUser.firstName}{" "}
|
||||||
|
{selectedUser.lastName}? This action cannot be undone.
|
||||||
|
</p>
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => setIsDeleting(false)}
|
||||||
|
className="px-4 py-2 bg-gray-300 text-gray-700 rounded hover:bg-gray-400"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleDeleteConfirm}
|
||||||
|
className="px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{selectedUser && (
|
{selectedUser && (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
@ -152,22 +391,55 @@ export function UserManagement() {
|
|||||||
<div>
|
<div>
|
||||||
<h4 className="font-medium mb-2">Basic Information</h4>
|
<h4 className="font-medium mb-2">Basic Information</h4>
|
||||||
<div className="space-y-1 text-sm">
|
<div className="space-y-1 text-sm">
|
||||||
<p><span className="font-medium">Name:</span> {selectedUser.firstName} {selectedUser.lastName}</p>
|
<p>
|
||||||
<p><span className="font-medium">Email:</span> {selectedUser.email}</p>
|
<span className="font-medium">Name:</span>{" "}
|
||||||
<p><span className="font-medium">Phone:</span> {selectedUser.phone || 'N/A'}</p>
|
{selectedUser.firstName} {selectedUser.lastName}
|
||||||
<p><span className="font-medium">Role:</span> {selectedUser.role}</p>
|
</p>
|
||||||
<p><span className="font-medium">Joined:</span> {selectedUser.createdAt.toLocaleDateString()}</p>
|
<p>
|
||||||
|
<span className="font-medium">Email:</span>{" "}
|
||||||
|
{selectedUser.email}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="font-medium">Phone:</span>{" "}
|
||||||
|
{selectedUser.phone || "N/A"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="font-medium">Role:</span>{" "}
|
||||||
|
{selectedUser.role}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="font-medium">Joined:</span>{" "}
|
||||||
|
{new Date(selectedUser.createdAt).toLocaleDateString()}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{selectedUser.client && (
|
{selectedUser.client && (
|
||||||
<div>
|
<div>
|
||||||
<h4 className="font-medium mb-2">Client Information</h4>
|
<h4 className="font-medium mb-2">Client Information</h4>
|
||||||
<div className="space-y-1 text-sm">
|
<div className="space-y-1 text-sm">
|
||||||
<p><span className="font-medium">Membership:</span> {selectedUser.client.membershipType}</p>
|
<p>
|
||||||
<p><span className="font-medium">Status:</span> {selectedUser.client.membershipStatus}</p>
|
<span className="font-medium">Membership:</span>{" "}
|
||||||
<p><span className="font-medium">Member Since:</span> {selectedUser.client.joinDate.toLocaleDateString()}</p>
|
{selectedUser.client.membershipType}
|
||||||
<p><span className="font-medium">Last Visit:</span> {selectedUser.client.lastVisit?.toLocaleDateString() || 'Never'}</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="font-medium">Status:</span>{" "}
|
||||||
|
{selectedUser.client.membershipStatus}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="font-medium">Member Since:</span>{" "}
|
||||||
|
{new Date(
|
||||||
|
selectedUser.client.joinDate,
|
||||||
|
).toLocaleDateString()}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span className="font-medium">Last Visit:</span>{" "}
|
||||||
|
{selectedUser.client.lastVisit
|
||||||
|
? new Date(
|
||||||
|
selectedUser.client.lastVisit,
|
||||||
|
).toLocaleDateString()
|
||||||
|
: "Never"}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -176,5 +448,5 @@ export function UserManagement() {
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "preserve",
|
"jsx": "react-jsx",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
894
apps/mobile/package-lock.json
generated
894
apps/mobile/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,16 +14,16 @@
|
|||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/vector-icons": "^15.0.3",
|
"@expo/vector-icons": "^15.0.0",
|
||||||
"@hookform/resolvers": "^3.3.0",
|
"@hookform/resolvers": "^3.3.0",
|
||||||
"@tanstack/react-query": "^5.0.0",
|
"@tanstack/react-query": "^5.0.0",
|
||||||
"ajv": "^8.12.0",
|
"ajv": "^8.12.0",
|
||||||
"ajv-keywords": "^5.1.0",
|
"ajv-keywords": "^5.1.0",
|
||||||
"axios": "^1.6.0",
|
"axios": "^1.6.0",
|
||||||
"expo": "~54.0.0",
|
"expo": "~54.0.23",
|
||||||
"expo-camera": "~17.0.9",
|
"expo-camera": "~17.0.0",
|
||||||
"expo-linking": "~8.0.8",
|
"expo-linking": "~8.0.0",
|
||||||
"expo-notifications": "~0.32.12",
|
"expo-notifications": "~0.32.0",
|
||||||
"expo-router": "~6.0.14",
|
"expo-router": "~6.0.14",
|
||||||
"expo-secure-store": "~15.0.7",
|
"expo-secure-store": "~15.0.7",
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
@ -44,6 +44,6 @@
|
|||||||
"jest": "^29.2.1",
|
"jest": "^29.2.1",
|
||||||
"@testing-library/react-native": "^12.4.0",
|
"@testing-library/react-native": "^12.4.0",
|
||||||
"react-test-renderer": "19.1.0",
|
"react-test-renderer": "19.1.0",
|
||||||
"babel-preset-expo": "~54.0.0"
|
"babel-preset-expo": "~54.0.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
885
package-lock.json
generated
885
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -21,12 +21,12 @@
|
|||||||
"typecheck:mobile": "cd apps/mobile && npx tsc --noEmit"
|
"typecheck:mobile": "cd apps/mobile && npx tsc --noEmit"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
||||||
"@typescript-eslint/parser": "^6.0.0",
|
"@typescript-eslint/parser": "^8.46.3",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^9.2.1",
|
||||||
"eslint": "^8.45.0",
|
"eslint": "^9.39.1",
|
||||||
"prettier": "^3.0.0",
|
"prettier": "^3.6.2",
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0",
|
"node": ">=18.0.0",
|
||||||
|
|||||||
1667
packages/database/package-lock.json
generated
Normal file
1667
packages/database/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,12 +11,12 @@
|
|||||||
"db:studio": "drizzle-kit studio"
|
"db:studio": "drizzle-kit studio"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"drizzle-orm": "^0.29.0",
|
"drizzle-orm": "^0.44.7",
|
||||||
"better-sqlite3": "^9.0.0",
|
"better-sqlite3": "^12.4.1",
|
||||||
"@types/better-sqlite3": "^7.6.0"
|
"@types/better-sqlite3": "^7.6.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.9.3",
|
||||||
"drizzle-kit": "^0.20.0"
|
"drizzle-kit": "^0.31.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
41
packages/shared/package-lock.json
generated
Normal file
41
packages/shared/package-lock.json
generated
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "@fitai/shared",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "@fitai/shared",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"zod": "^4.1.12"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^5.9.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "5.9.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||||
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zod": {
|
||||||
|
"version": "4.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
|
||||||
|
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,9 +9,9 @@
|
|||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"zod": "^3.22.0"
|
"zod": "^4.1.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user