Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02c9681aca | ||
|
|
912981e3f3 | ||
|
|
963404434a | ||
|
|
7f22a39886 | ||
|
|
0776517fb7 | ||
|
|
064dafad57 | ||
|
|
5d6166df1b | ||
|
|
aba9b1395b | ||
|
|
c3a41d2b32 | ||
|
|
254a30ff93 |
No files matched your search
Binary file not shown.
@@ -0,0 +1,142 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { auth } from "@clerk/nextjs/server";
|
||||||
|
import { getDatabase } from "@/lib/database";
|
||||||
|
import { ensureUserSynced } from "@/lib/sync-user";
|
||||||
|
import { successResponse } from "@/lib/api/responses";
|
||||||
|
import { db as rawDb, sql } from "@fitai/database";
|
||||||
|
|
||||||
|
interface UserGrowthPoint {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MembershipDistributionPoint {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RevenuePoint {
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnalyticsData {
|
||||||
|
userGrowth: UserGrowthPoint[];
|
||||||
|
membershipDistribution: MembershipDistributionPoint[];
|
||||||
|
revenue: RevenuePoint[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest) {
|
||||||
|
try {
|
||||||
|
const { userId } = await auth();
|
||||||
|
if (!userId) {
|
||||||
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const database = await getDatabase();
|
||||||
|
const user = await ensureUserSynced(userId, database);
|
||||||
|
|
||||||
|
if (!user || (user.role !== "admin" && user.role !== "superAdmin")) {
|
||||||
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const months = parseInt(url.searchParams.get("months") || "6");
|
||||||
|
|
||||||
|
const allUsers = await database.getAllUsers();
|
||||||
|
const allClients = await database.getAllClients();
|
||||||
|
|
||||||
|
const paymentsRaw = await rawDb.all(
|
||||||
|
sql`SELECT * FROM payments WHERE status = 'completed' AND paid_at IS NOT NULL`,
|
||||||
|
);
|
||||||
|
const payments: any[] = paymentsRaw || [];
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const userGrowth: UserGrowthPoint[] = [];
|
||||||
|
|
||||||
|
for (let i = months - 1; i >= 0; i--) {
|
||||||
|
const date = new Date(now.getFullYear(), now.getMonth() - i, 1);
|
||||||
|
const monthLabel = date.toLocaleDateString("en-US", { month: "short" });
|
||||||
|
|
||||||
|
const usersCreatedByMonth = allUsers.filter((u: any) => {
|
||||||
|
const createdAt = new Date(u.createdAt);
|
||||||
|
return (
|
||||||
|
createdAt.getFullYear() === date.getFullYear() &&
|
||||||
|
createdAt.getMonth() === date.getMonth()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
userGrowth.push({
|
||||||
|
label: monthLabel,
|
||||||
|
value: usersCreatedByMonth.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let runningTotal = 0;
|
||||||
|
for (const point of userGrowth) {
|
||||||
|
runningTotal += point.value;
|
||||||
|
point.value = runningTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
const membershipCounts: Record<string, number> = {
|
||||||
|
basic: 0,
|
||||||
|
premium: 0,
|
||||||
|
vip: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const client of allClients) {
|
||||||
|
const membershipType = (client as any).membershipType || "basic";
|
||||||
|
if (membershipCounts[membershipType] !== undefined) {
|
||||||
|
membershipCounts[membershipType]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const membershipDistribution: MembershipDistributionPoint[] = [
|
||||||
|
{ label: "Basic", value: membershipCounts.basic, color: "#6b7280" },
|
||||||
|
{ label: "Premium", value: membershipCounts.premium, color: "#3b82f6" },
|
||||||
|
{ label: "VIP", value: membershipCounts.vip, color: "#f59e0b" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const revenue: RevenuePoint[] = [];
|
||||||
|
|
||||||
|
for (let i = months - 1; i >= 0; i--) {
|
||||||
|
const date = new Date(now.getFullYear(), now.getMonth() - i, 1);
|
||||||
|
const monthLabel = date.toLocaleDateString("en-US", { month: "short" });
|
||||||
|
const nextMonthDate = new Date(
|
||||||
|
now.getFullYear(),
|
||||||
|
now.getMonth() - i + 1,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
|
const monthlyRevenue = payments
|
||||||
|
.filter((p: any) => {
|
||||||
|
const paidAt = p.paid_at ? new Date(p.paid_at) : null;
|
||||||
|
if (!paidAt) return false;
|
||||||
|
return paidAt >= date && paidAt < nextMonthDate;
|
||||||
|
})
|
||||||
|
.reduce((sum: number, p: any) => sum + (p.amount || 0), 0);
|
||||||
|
|
||||||
|
revenue.push({
|
||||||
|
label: monthLabel,
|
||||||
|
value: monthlyRevenue,
|
||||||
|
color: "#10b981",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const analyticsData: AnalyticsData = {
|
||||||
|
userGrowth,
|
||||||
|
membershipDistribution,
|
||||||
|
revenue,
|
||||||
|
};
|
||||||
|
|
||||||
|
return successResponse({ analytics: analyticsData });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Analytics error:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Internal server error" },
|
||||||
|
{ status: 500 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import { auth } from "@clerk/nextjs/server";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getDatabase } from "@/lib/database";
|
import { getDatabase } from "@/lib/database";
|
||||||
import { ensureUserSynced } from "@/lib/sync-user";
|
import { ensureUserSynced } from "@/lib/sync-user";
|
||||||
|
import { successResponse } from "@/lib/api/responses";
|
||||||
|
|
||||||
export async function GET(req: Request) {
|
export async function GET(req: Request) {
|
||||||
try {
|
try {
|
||||||
@@ -51,7 +52,7 @@ export async function GET(req: Request) {
|
|||||||
revenueGrowth: 0,
|
revenueGrowth: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
return NextResponse.json(stats);
|
return successResponse({ stats });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Dashboard stats error:", error);
|
console.error("Dashboard stats error:", error);
|
||||||
return new NextResponse("Internal Server Error", { status: 500 });
|
return new NextResponse("Internal Server Error", { status: 500 });
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
} from "@clerk/nextjs";
|
} from "@clerk/nextjs";
|
||||||
import { Sidebar } from "@/components/ui/Sidebar";
|
import { Sidebar } from "@/components/ui/Sidebar";
|
||||||
import { Toaster } from "sonner";
|
import { Toaster } from "sonner";
|
||||||
|
import { QueryProvider } from "@/components/providers/QueryProvider";
|
||||||
|
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
const inter = Inter({ subsets: ["latin"] });
|
||||||
|
|
||||||
@@ -25,15 +26,17 @@ export default function RootLayout({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<ClerkProvider>
|
<ClerkProvider>
|
||||||
<html lang="en">
|
<QueryProvider>
|
||||||
<body className={inter.className}>
|
<html lang="en">
|
||||||
<div className="flex min-h-screen bg-slate-50">
|
<body className={inter.className}>
|
||||||
<Sidebar />
|
<div className="flex min-h-screen bg-slate-50">
|
||||||
<main className="flex-1 ml-20 p-8">{children}</main>
|
<Sidebar />
|
||||||
</div>
|
<main className="flex-1 ml-20 p-8">{children}</main>
|
||||||
<Toaster richColors position="top-right" />
|
</div>
|
||||||
</body>
|
<Toaster richColors position="top-right" />
|
||||||
</html>
|
</body>
|
||||||
|
</html>
|
||||||
|
</QueryProvider>
|
||||||
</ClerkProvider>
|
</ClerkProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+56
-67
@@ -1,99 +1,88 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { Users, CreditCard, CalendarCheck, TrendingUp } from "lucide-react";
|
import { Users, CreditCard, CalendarCheck, TrendingUp } from "lucide-react";
|
||||||
import { StatsCard } from "@/components/ui/StatsCard";
|
import { StatsCard } from "@/components/ui/StatsCard";
|
||||||
|
import { StatsCardSkeleton } from "@/components/ui/skeleton";
|
||||||
import { UserManagement } from "@/components/users/UserManagement";
|
import { UserManagement } from "@/components/users/UserManagement";
|
||||||
import { AnalyticsDashboard } from "@/components/analytics/AnalyticsDashboard";
|
import { AnalyticsDashboard } from "@/components/analytics/AnalyticsDashboard";
|
||||||
import axios from "axios";
|
import { useDashboardStats } from "@/hooks/use-api";
|
||||||
|
|
||||||
interface DashboardStats {
|
|
||||||
totalUsers: number;
|
|
||||||
activeClients: number;
|
|
||||||
totalRevenue: number;
|
|
||||||
revenueGrowth: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [stats, setStats] = useState<DashboardStats>({
|
const { data: stats, isLoading } = useDashboardStats();
|
||||||
totalUsers: 0,
|
|
||||||
activeClients: 0,
|
|
||||||
totalRevenue: 0,
|
|
||||||
revenueGrowth: 0,
|
|
||||||
});
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchStats = async () => {
|
|
||||||
try {
|
|
||||||
const response = await axios.get("/api/admin/stats");
|
|
||||||
setStats(response.data);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to fetch dashboard stats:", error);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchStats();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const formatCurrency = (value: number) => {
|
const formatCurrency = (value: number) => {
|
||||||
return new Intl.NumberFormat("en-US", {
|
return new Intl.NumberFormat("en-US", {
|
||||||
style: "currency",
|
style: "currency",
|
||||||
currency: "USD",
|
currency: "USD",
|
||||||
}).format(value);
|
}).format(value || 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-3xl font-bold text-slate-900">Dashboard</h2>
|
<h2 className="text-3xl font-bold text-slate-900">Dashboard</h2>
|
||||||
<p className="text-slate-500 mt-2">Welcome back, here's what's happening today.</p>
|
<p className="text-slate-500 mt-2">
|
||||||
|
Welcome back, here's what's happening today.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||||
<StatsCard
|
{isLoading ? (
|
||||||
title="Total Users"
|
<>
|
||||||
value={loading ? "..." : stats.totalUsers}
|
<StatsCardSkeleton />
|
||||||
change="+12%" // Placeholder for now as we don't track historical growth yet
|
<StatsCardSkeleton />
|
||||||
trend="up"
|
<StatsCardSkeleton />
|
||||||
icon={Users}
|
<StatsCardSkeleton />
|
||||||
color="blue"
|
</>
|
||||||
/>
|
) : (
|
||||||
<StatsCard
|
<>
|
||||||
title="Active Clients"
|
<StatsCard
|
||||||
value={loading ? "..." : stats.activeClients}
|
title="Total Users"
|
||||||
change="+5%"
|
value={stats?.totalUsers ?? 0}
|
||||||
trend="up"
|
change="+12%"
|
||||||
icon={CalendarCheck}
|
trend="up"
|
||||||
color="green"
|
icon={Users}
|
||||||
/>
|
color="blue"
|
||||||
<StatsCard
|
/>
|
||||||
title="Revenue"
|
<StatsCard
|
||||||
value={loading ? "..." : formatCurrency(stats.totalRevenue)}
|
title="Active Clients"
|
||||||
change={`${stats.revenueGrowth > 0 ? "+" : ""}${stats.revenueGrowth}%`}
|
value={stats?.activeClients ?? 0}
|
||||||
trend={stats.revenueGrowth >= 0 ? "up" : "down"}
|
change="+5%"
|
||||||
icon={CreditCard}
|
trend="up"
|
||||||
color="purple"
|
icon={CalendarCheck}
|
||||||
/>
|
color="green"
|
||||||
<StatsCard
|
/>
|
||||||
title="Growth"
|
<StatsCard
|
||||||
value="24%" // Placeholder
|
title="Revenue"
|
||||||
change="-2%"
|
value={formatCurrency(stats?.totalRevenue ?? 0)}
|
||||||
trend="down"
|
change={`${(stats?.revenueGrowth ?? 0) > 0 ? "+" : ""}${stats?.revenueGrowth ?? 0}%`}
|
||||||
icon={TrendingUp}
|
trend={(stats?.revenueGrowth ?? 0) >= 0 ? "up" : "down"}
|
||||||
color="orange"
|
icon={CreditCard}
|
||||||
/>
|
color="purple"
|
||||||
|
/>
|
||||||
|
<StatsCard
|
||||||
|
title="Growth"
|
||||||
|
value="24%"
|
||||||
|
change="-2%"
|
||||||
|
trend="down"
|
||||||
|
icon={TrendingUp}
|
||||||
|
color="orange"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-8">
|
<div className="flex flex-col gap-8">
|
||||||
<div className="bg-white rounded-xl shadow-sm border border-slate-100 p-6">
|
<div className="bg-white rounded-xl shadow-sm border border-slate-100 p-6">
|
||||||
<h3 className="text-xl font-bold text-slate-900 mb-6">Recent Activity</h3>
|
<h3 className="text-xl font-bold text-slate-900 mb-6">
|
||||||
|
Recent Activity
|
||||||
|
</h3>
|
||||||
<UserManagement />
|
<UserManagement />
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white rounded-xl shadow-sm border border-slate-100 p-6">
|
<div className="bg-white rounded-xl shadow-sm border border-slate-100 p-6">
|
||||||
<h3 className="text-xl font-bold text-slate-900 mb-6">Quick Analytics</h3>
|
<h3 className="text-xl font-bold text-slate-900 mb-6">
|
||||||
|
Quick Analytics
|
||||||
|
</h3>
|
||||||
<AnalyticsDashboard />
|
<AnalyticsDashboard />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,86 +1,40 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
import { useUser } from "@clerk/nextjs";
|
import { useUser } from "@clerk/nextjs";
|
||||||
import log from "@/lib/logger";
|
import log from "@/lib/logger";
|
||||||
import { toast } from "@/lib/toast";
|
import { toast } from "@/lib/toast";
|
||||||
|
import {
|
||||||
interface User {
|
useUsers,
|
||||||
id: string;
|
useRecommendations,
|
||||||
firstName: string;
|
useGenerateRecommendations,
|
||||||
lastName: string;
|
useApproveRecommendation,
|
||||||
email: string;
|
useUpdateRecommendation,
|
||||||
}
|
type Recommendation,
|
||||||
|
} from "@/hooks/use-api";
|
||||||
interface Recommendation {
|
|
||||||
id: string;
|
|
||||||
userId: string;
|
|
||||||
content: string;
|
|
||||||
recommendationText: string;
|
|
||||||
activityPlan: string;
|
|
||||||
dietPlan: string;
|
|
||||||
status: string;
|
|
||||||
createdAt: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function RecommendationsPage() {
|
export default function RecommendationsPage() {
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const [users, setUsers] = useState<User[]>([]);
|
|
||||||
const [pendingRecommendations, setPendingRecommendations] = useState<
|
|
||||||
Recommendation[]
|
|
||||||
>([]);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const [generating, setGenerating] = useState<string | null>(null);
|
|
||||||
const [useExternalModel, setUseExternalModel] = useState(false);
|
const [useExternalModel, setUseExternalModel] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
const { data: users = [], isLoading: usersLoading } = useUsers();
|
||||||
fetchData();
|
const { data: allRecommendations = [], isLoading: recsLoading } =
|
||||||
}, []);
|
useRecommendations();
|
||||||
|
const pendingRecommendations = allRecommendations.filter(
|
||||||
|
(r) => r.status === "pending",
|
||||||
|
);
|
||||||
|
|
||||||
const fetchData = async () => {
|
const generateRec = useGenerateRecommendations();
|
||||||
try {
|
const approveRec = useApproveRecommendation();
|
||||||
// Fetch users - API returns { success: true, data: { users: [...] }, meta: {...} }
|
const updateRec = useUpdateRecommendation();
|
||||||
const usersRes = await fetch("/api/users");
|
|
||||||
const usersResult = await usersRes.json();
|
|
||||||
const usersArray = usersResult.data?.users || usersResult.users || [];
|
|
||||||
setUsers(usersArray);
|
|
||||||
|
|
||||||
// Fetch pending recommendations - API returns { success: true, data: { recommendations: [...] }, meta: {...} }
|
|
||||||
const recsRes = await fetch("/api/recommendations");
|
|
||||||
const recsResult = await recsRes.json();
|
|
||||||
const allRecs =
|
|
||||||
recsResult.data?.recommendations || recsResult.recommendations || [];
|
|
||||||
setPendingRecommendations(
|
|
||||||
allRecs.filter((r: Recommendation) => r.status === "pending"),
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
log.error("Failed to fetch data", error);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleGenerate = async (userId: string) => {
|
const handleGenerate = async (userId: string) => {
|
||||||
setGenerating(userId);
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/recommendations/generate", {
|
await generateRec.mutateAsync(userId);
|
||||||
method: "POST",
|
toast.success("Recommendation generated successfully!");
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({ userId, useExternalModel }),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
const error = await res.json();
|
|
||||||
toast.error(`Error: ${error.error}`);
|
|
||||||
} else {
|
|
||||||
toast.success("Recommendation generated successfully!");
|
|
||||||
fetchData(); // Refresh data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Failed to generate recommendation", error);
|
log.error("Failed to generate recommendation", error);
|
||||||
toast.error("Failed to generate recommendation.");
|
toast.error("Failed to generate recommendation.");
|
||||||
} finally {
|
|
||||||
setGenerating(null);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,25 +43,11 @@ export default function RecommendationsPage() {
|
|||||||
status: "approved" | "rejected",
|
status: "approved" | "rejected",
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/recommendations/approve", {
|
await approveRec.mutateAsync({
|
||||||
method: "POST",
|
recommendationId,
|
||||||
headers: { "Content-Type": "application/json" },
|
approved: status === "approved",
|
||||||
body: JSON.stringify({
|
|
||||||
recommendationId,
|
|
||||||
status,
|
|
||||||
approvedBy: user?.id || "admin",
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
toast.success("Recommendation status updated");
|
||||||
if (!res.ok) {
|
|
||||||
const errorData = await res.json();
|
|
||||||
toast.error(
|
|
||||||
`Failed to update status: ${errorData.error || "Unknown error"}`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
toast.success("Recommendation status updated");
|
|
||||||
fetchData(); // Refresh data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Failed to approve recommendation", error);
|
log.error("Failed to approve recommendation", error);
|
||||||
toast.error("Error processing request");
|
toast.error("Error processing request");
|
||||||
@@ -124,38 +64,24 @@ export default function RecommendationsPage() {
|
|||||||
newActivityPlan === null ||
|
newActivityPlan === null ||
|
||||||
newDietPlan === null
|
newDietPlan === null
|
||||||
) {
|
) {
|
||||||
// User cancelled one of the prompts
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/recommendations", {
|
await updateRec.mutateAsync({
|
||||||
method: "PUT",
|
id: rec.id,
|
||||||
headers: { "Content-Type": "application/json" },
|
content: newContent,
|
||||||
body: JSON.stringify({
|
activityPlan: newActivityPlan,
|
||||||
id: rec.id,
|
dietPlan: newDietPlan,
|
||||||
content: newContent,
|
|
||||||
activityPlan: newActivityPlan,
|
|
||||||
dietPlan: newDietPlan,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
toast.success("Recommendation updated successfully!");
|
||||||
if (!res.ok) {
|
|
||||||
const errorData = await res.json();
|
|
||||||
toast.error(
|
|
||||||
`Failed to update recommendation: ${errorData.error || "Unknown error"}`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
toast.success("Recommendation updated successfully!");
|
|
||||||
fetchData(); // Refresh data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Failed to update recommendation", error);
|
log.error("Failed to update recommendation", error);
|
||||||
toast.error("Failed to update recommendation.");
|
toast.error("Failed to update recommendation.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (usersLoading || recsLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-screen">
|
<div className="flex items-center justify-center h-screen">
|
||||||
<div className="text-xl">Loading...</div>
|
<div className="text-xl">Loading...</div>
|
||||||
@@ -215,10 +141,10 @@ export default function RecommendationsPage() {
|
|||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => handleGenerate(user.id)}
|
onClick={() => handleGenerate(user.id)}
|
||||||
disabled={generating === user.id}
|
disabled={generateRec.isPending}
|
||||||
className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 disabled:opacity-50"
|
className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{generating === user.id ? "Generating..." : "Generate"}
|
{generateRec.isPending ? "Generating..." : "Generate"}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,75 +1,34 @@
|
|||||||
'use client'
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
import { UserGrowthChart } from "@/components/charts/UserGrowthChart";
|
||||||
import { UserGrowthChart } from '@/components/charts/UserGrowthChart'
|
import { MembershipDistributionChart } from "@/components/charts/MembershipDistributionChart";
|
||||||
import { MembershipDistributionChart } from '@/components/charts/MembershipDistributionChart'
|
import { RevenueChart } from "@/components/charts/RevenueChart";
|
||||||
import { RevenueChart } from '@/components/charts/RevenueChart'
|
import { Card, CardHeader, CardContent } from "@/components/ui/card";
|
||||||
import { Card, CardHeader, CardContent } from '@/components/ui/card'
|
import { useAnalytics } from "@/hooks/use-api";
|
||||||
|
|
||||||
interface ChartData {
|
|
||||||
label: string
|
|
||||||
value: number
|
|
||||||
color?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AnalyticsDashboard() {
|
export function AnalyticsDashboard() {
|
||||||
const [userGrowthData, setUserGrowthData] = useState<ChartData[]>([])
|
const { data: analytics, isLoading } = useAnalytics(6);
|
||||||
const [membershipData, setMembershipData] = useState<ChartData[]>([])
|
|
||||||
const [revenueData, setRevenueData] = useState<ChartData[]>([])
|
|
||||||
const [loading, setLoading] = useState(true)
|
|
||||||
|
|
||||||
useEffect(() => {
|
const userGrowthData = analytics?.userGrowth ?? [];
|
||||||
fetchAnalyticsData()
|
const membershipData = analytics?.membershipDistribution ?? [];
|
||||||
}, [])
|
const revenueData = analytics?.revenue ?? [];
|
||||||
|
|
||||||
const fetchAnalyticsData = async () => {
|
const totalUsers =
|
||||||
setLoading(true)
|
userGrowthData.length > 0
|
||||||
try {
|
? userGrowthData[userGrowthData.length - 1].value
|
||||||
// Mock data for demonstration - replace with real API calls
|
: 0;
|
||||||
const mockUserGrowth = [
|
const totalRevenue = revenueData.reduce((sum, item) => sum + item.value, 0);
|
||||||
{ label: 'Jan', value: 45 },
|
const activeMembers = membershipData.reduce(
|
||||||
{ label: 'Feb', value: 52 },
|
(sum, item) => sum + item.value,
|
||||||
{ label: 'Mar', value: 61 },
|
0,
|
||||||
{ label: 'Apr', value: 58 },
|
);
|
||||||
{ label: 'May', value: 67 },
|
|
||||||
{ label: 'Jun', value: 74 },
|
|
||||||
]
|
|
||||||
|
|
||||||
const mockMembershipData = [
|
if (isLoading) {
|
||||||
{ label: 'Basic', value: 45, color: '#6b7280' },
|
|
||||||
{ label: 'Premium', value: 28, color: '#3b82f6' },
|
|
||||||
{ label: 'VIP', value: 12, color: '#f59e0b' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const mockRevenueData = [
|
|
||||||
{ label: 'Jan', value: 12500, color: '#10b981' },
|
|
||||||
{ label: 'Feb', value: 14200, color: '#10b981' },
|
|
||||||
{ label: 'Mar', value: 16800, color: '#10b981' },
|
|
||||||
{ label: 'Apr', value: 15900, color: '#10b981' },
|
|
||||||
{ label: 'May', value: 18200, color: '#10b981' },
|
|
||||||
{ label: 'Jun', value: 19400, color: '#10b981' },
|
|
||||||
]
|
|
||||||
|
|
||||||
setUserGrowthData(mockUserGrowth)
|
|
||||||
setMembershipData(mockMembershipData)
|
|
||||||
setRevenueData(mockRevenueData)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to fetch analytics data:', error)
|
|
||||||
} finally {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalUsers = userGrowthData.length > 0 ? userGrowthData[userGrowthData.length - 1].value : 0
|
|
||||||
const totalRevenue = revenueData.reduce((sum, item) => sum + item.value, 0)
|
|
||||||
const activeMembers = membershipData.reduce((sum, item) => sum + item.value, 0)
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center h-64">
|
<div className="flex justify-center items-center h-64">
|
||||||
<div className="text-lg">Loading analytics...</div>
|
<div className="text-lg">Loading analytics...</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -81,7 +40,9 @@ export function AnalyticsDashboard() {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="text-3xl font-bold text-blue-600">{totalUsers}</div>
|
<div className="text-3xl font-bold text-blue-600">
|
||||||
|
{totalUsers}
|
||||||
|
</div>
|
||||||
<div className="text-gray-600">Total Users</div>
|
<div className="text-gray-600">Total Users</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -90,7 +51,9 @@ export function AnalyticsDashboard() {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="text-3xl font-bold text-green-600">${totalRevenue.toLocaleString()}</div>
|
<div className="text-3xl font-bold text-green-600">
|
||||||
|
${totalRevenue.toLocaleString()}
|
||||||
|
</div>
|
||||||
<div className="text-gray-600">Total Revenue</div>
|
<div className="text-gray-600">Total Revenue</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -99,7 +62,9 @@ export function AnalyticsDashboard() {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="text-3xl font-bold text-purple-600">{activeMembers}</div>
|
<div className="text-3xl font-bold text-purple-600">
|
||||||
|
{activeMembers}
|
||||||
|
</div>
|
||||||
<div className="text-gray-600">Active Members</div>
|
<div className="text-gray-600">Active Members</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -133,14 +98,14 @@ export function AnalyticsDashboard() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<RevenueChart
|
<RevenueChart
|
||||||
data={revenueData.map(item => ({
|
data={revenueData.map((item) => ({
|
||||||
category: item.label,
|
category: item.label,
|
||||||
value: item.value,
|
value: item.value,
|
||||||
color: item.color
|
color: item.color,
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
|
import { useState, type ReactNode } from "react";
|
||||||
|
|
||||||
|
interface QueryProviderProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function QueryProvider({ children }: QueryProviderProps) {
|
||||||
|
const [queryClient] = useState(
|
||||||
|
() =>
|
||||||
|
new QueryClient({
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
staleTime: 60 * 1000,
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,40 +13,18 @@ import {
|
|||||||
Brain,
|
Brain,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { UserButton, useUser } from "@clerk/nextjs";
|
import { UserButton, useUser } from "@clerk/nextjs";
|
||||||
|
import { usePendingRecommendationsCount } from "@/hooks/use-api";
|
||||||
interface Recommendation {
|
|
||||||
id: string;
|
|
||||||
status: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Sidebar() {
|
export function Sidebar() {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const [pendingCount, setPendingCount] = useState(0);
|
const { data: pendingCount = 0 } = usePendingRecommendationsCount();
|
||||||
const [mounted, setMounted] = useState(false);
|
const [mounted, setMounted] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMounted(true);
|
setMounted(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchPending = async () => {
|
|
||||||
try {
|
|
||||||
const res = await fetch("/api/recommendations");
|
|
||||||
if (res.ok) {
|
|
||||||
const data = await res.json();
|
|
||||||
const pending = (data.recommendations || []).filter(
|
|
||||||
(r: Recommendation) => r.status === "pending",
|
|
||||||
);
|
|
||||||
setPendingCount(pending.length);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Failed to fetch pending recommendations", e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fetchPending();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ icon: LayoutDashboard, label: "Dashboard", href: "/" },
|
{ icon: LayoutDashboard, label: "Dashboard", href: "/" },
|
||||||
{ icon: Users, label: "Users", href: "/users" },
|
{ icon: Users, label: "Users", href: "/users" },
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
interface SkeletonProps {
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Skeleton({ className }: SkeletonProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"animate-pulse rounded-md bg-slate-200 dark:bg-slate-700",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function StatsCardSkeleton() {
|
||||||
|
return (
|
||||||
|
<div className="bg-white rounded-xl shadow-sm border border-slate-100 p-6">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<Skeleton className="h-12 w-12 rounded-full" />
|
||||||
|
<div className="flex-1 space-y-2">
|
||||||
|
<Skeleton className="h-4 w-20" />
|
||||||
|
<Skeleton className="h-8 w-16" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TableSkeleton({ rows = 5 }: { rows?: number }) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-3">
|
||||||
|
{Array.from({ length: rows }).map((_, i) => (
|
||||||
|
<div key={i} className="flex gap-4">
|
||||||
|
<Skeleton className="h-12 flex-1" />
|
||||||
|
<Skeleton className="h-12 w-32" />
|
||||||
|
<Skeleton className="h-12 w-24" />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CardSkeleton() {
|
||||||
|
return (
|
||||||
|
<div className="bg-white rounded-xl shadow-sm border border-slate-100 p-6 space-y-4">
|
||||||
|
<Skeleton className="h-6 w-40" />
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-4 w-full" />
|
||||||
|
<Skeleton className="h-4 w-3/4" />
|
||||||
|
<Skeleton className="h-4 w-5/6" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -9,9 +9,10 @@ import { formatDate } from "@/lib/utils";
|
|||||||
|
|
||||||
ModuleRegistry.registerModules([AllCommunityModule]);
|
ModuleRegistry.registerModules([AllCommunityModule]);
|
||||||
|
|
||||||
function getTimeAgo(date: Date): string {
|
function getTimeAgo(date: Date | string): string {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const diffMs = now.getTime() - date.getTime();
|
const d = typeof date === "string" ? new Date(date) : date;
|
||||||
|
const diffMs = now.getTime() - d.getTime();
|
||||||
const diffMins = Math.floor(diffMs / 60000);
|
const diffMins = Math.floor(diffMs / 60000);
|
||||||
const diffHours = Math.floor(diffMins / 60);
|
const diffHours = Math.floor(diffMins / 60);
|
||||||
const diffDays = Math.floor(diffHours / 24);
|
const diffDays = Math.floor(diffHours / 24);
|
||||||
@@ -22,7 +23,7 @@ function getTimeAgo(date: Date): string {
|
|||||||
return `${diffDays}d ago`;
|
return `${diffDays}d ago`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface User {
|
export interface User {
|
||||||
id: string;
|
id: string;
|
||||||
email: string;
|
email: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
@@ -31,15 +32,18 @@ interface User {
|
|||||||
phone?: string;
|
phone?: string;
|
||||||
gymId?: string;
|
gymId?: string;
|
||||||
gymName?: string | null;
|
gymName?: string | null;
|
||||||
createdAt: Date;
|
createdAt?: string | Date;
|
||||||
isCheckedIn?: boolean;
|
isCheckedIn?: boolean;
|
||||||
checkInTime?: Date;
|
checkInTime?: string | Date;
|
||||||
|
lastCheckInTime?: string | Date;
|
||||||
|
checkInsThisWeek?: number;
|
||||||
|
checkInsThisMonth?: number;
|
||||||
client?: {
|
client?: {
|
||||||
id: string;
|
id: string;
|
||||||
membershipType: string;
|
membershipType: string;
|
||||||
membershipStatus: string;
|
membershipStatus: string;
|
||||||
joinDate: Date;
|
joinDate: string | Date;
|
||||||
lastVisit?: Date;
|
lastVisit?: string | Date;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState } from "react";
|
||||||
import { UserGrid } from "@/components/users/UserGrid";
|
import { UserGrid, type User } from "@/components/users/UserGrid";
|
||||||
// import { Button } from "@/components/ui/button";
|
|
||||||
import { Card, CardHeader, CardContent } from "@/components/ui/card";
|
import { Card, CardHeader, CardContent } from "@/components/ui/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useUser } from "@clerk/nextjs";
|
import { useUser } from "@clerk/nextjs";
|
||||||
import { getGymIdFromUser } from "@/lib/error-helpers";
|
|
||||||
import log from "@/lib/logger";
|
import log from "@/lib/logger";
|
||||||
import { toast } from "@/lib/toast";
|
import { toast } from "@/lib/toast";
|
||||||
import { CreateUserModal } from "./CreateUserModal";
|
import { CreateUserModal } from "./CreateUserModal";
|
||||||
|
import {
|
||||||
interface User {
|
useUsers,
|
||||||
id: string;
|
useGyms,
|
||||||
email: string;
|
useUpdateUser,
|
||||||
firstName: string;
|
useDeleteUser,
|
||||||
lastName: string;
|
useSendInvitation,
|
||||||
role: string;
|
} from "@/hooks/use-api";
|
||||||
phone?: string;
|
|
||||||
gymId?: string;
|
|
||||||
createdAt: Date;
|
|
||||||
isCheckedIn?: boolean;
|
|
||||||
checkInTime?: Date;
|
|
||||||
lastCheckInTime?: Date;
|
|
||||||
checkInsThisWeek?: number;
|
|
||||||
checkInsThisMonth?: number;
|
|
||||||
client?: {
|
|
||||||
id: string;
|
|
||||||
membershipType: string;
|
|
||||||
membershipStatus: string;
|
|
||||||
joinDate: Date;
|
|
||||||
lastVisit?: Date;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function UserManagement() {
|
export function UserManagement() {
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const [users, setUsers] = useState<User[]>([]);
|
|
||||||
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 [isEditing, setIsEditing] = useState(false);
|
||||||
@@ -52,68 +32,17 @@ export function UserManagement() {
|
|||||||
gymId: string;
|
gymId: string;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
// Active gyms for dropdown
|
const {
|
||||||
const [gyms, setGyms] = useState<Array<{ id: string; name: string }>>([]);
|
data: users = [],
|
||||||
|
isLoading,
|
||||||
// Load gyms when modal opens or refreshes
|
refetch,
|
||||||
useEffect(() => {
|
} = useUsers({
|
||||||
if (isEditing) {
|
role: filter !== "all" ? filter : undefined,
|
||||||
(async () => {
|
});
|
||||||
try {
|
const { data: gyms = [] } = useGyms();
|
||||||
const res = await fetch("/api/gyms");
|
const updateUser = useUpdateUser();
|
||||||
const data = await res.json();
|
const deleteUser = useDeleteUser();
|
||||||
if (Array.isArray(data)) {
|
const sendInvitation = useSendInvitation();
|
||||||
// map down to id and name to avoid extra payload use here
|
|
||||||
setGyms(data.map((g: any) => ({ id: g.id, name: g.name })));
|
|
||||||
} else {
|
|
||||||
setGyms([]);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
setGyms([]);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
}, [isEditing]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetchUsers();
|
|
||||||
}, [filter]);
|
|
||||||
|
|
||||||
const fetchUsers = async () => {
|
|
||||||
setLoading(true);
|
|
||||||
try {
|
|
||||||
const ts = Date.now();
|
|
||||||
const url =
|
|
||||||
filter === "all"
|
|
||||||
? `/api/users?ts=${ts}`
|
|
||||||
: `/api/users?role=${filter}&ts=${ts}`;
|
|
||||||
|
|
||||||
log.debug("Fetching users", { url });
|
|
||||||
const response = await fetch(url, { cache: "no-store" });
|
|
||||||
log.debug("Users fetch response", {
|
|
||||||
ok: response.ok,
|
|
||||||
status: response.status,
|
|
||||||
});
|
|
||||||
const responseData = await response.json();
|
|
||||||
const data = responseData.data || responseData; // Handle both old and new API response formats
|
|
||||||
log.debug("Received users data", {
|
|
||||||
count: Array.isArray(data.users) ? data.users.length : 0,
|
|
||||||
sample:
|
|
||||||
data.users && data.users[0]
|
|
||||||
? {
|
|
||||||
id: data.users[0].id,
|
|
||||||
gymId: data.users[0].gymId,
|
|
||||||
role: data.users[0].role,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
});
|
|
||||||
setUsers(data.users || []);
|
|
||||||
} catch (error) {
|
|
||||||
log.error("Failed to fetch users", error);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUserSelect = (user: User | null) => {
|
const handleUserSelect = (user: User | null) => {
|
||||||
setSelectedUser(user);
|
setSelectedUser(user);
|
||||||
@@ -144,17 +73,12 @@ export function UserManagement() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/users", {
|
const deletePromises = users.map((u) =>
|
||||||
method: "DELETE",
|
fetch(`/api/users?id=${u.id}`, { method: "DELETE" }),
|
||||||
headers: { "Content-Type": "application/json" },
|
);
|
||||||
body: JSON.stringify({ ids: users.map((u) => u.id) }),
|
await Promise.all(deletePromises);
|
||||||
});
|
refetch();
|
||||||
if (response.ok) {
|
toast.success("Users deleted successfully");
|
||||||
fetchUsers();
|
|
||||||
toast.success("Users deleted successfully");
|
|
||||||
} else {
|
|
||||||
toast.error("Error deleting users");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Failed to delete users", error);
|
log.error("Failed to delete users", error);
|
||||||
}
|
}
|
||||||
@@ -196,7 +120,7 @@ export function UserManagement() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRefresh = () => {
|
const handleRefresh = () => {
|
||||||
fetchUsers();
|
refetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveEdit = async () => {
|
const handleSaveEdit = async () => {
|
||||||
@@ -204,7 +128,6 @@ export function UserManagement() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (selectedUser) {
|
if (selectedUser) {
|
||||||
// Update existing user
|
|
||||||
const payload = {
|
const payload = {
|
||||||
id: selectedUser.id,
|
id: selectedUser.id,
|
||||||
email: editForm.email,
|
email: editForm.email,
|
||||||
@@ -214,80 +137,21 @@ export function UserManagement() {
|
|||||||
phone: editForm.phone,
|
phone: editForm.phone,
|
||||||
gymId: editForm.gymId === "" ? null : editForm.gymId,
|
gymId: editForm.gymId === "" ? null : editForm.gymId,
|
||||||
};
|
};
|
||||||
log.debug("Updating user", payload);
|
|
||||||
const response = await fetch("/api/users", {
|
|
||||||
method: "PUT",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
});
|
|
||||||
log.debug("User update response", {
|
|
||||||
ok: response.ok,
|
|
||||||
status: response.status,
|
|
||||||
});
|
|
||||||
if (response.ok) {
|
|
||||||
// Optimistically update local state so grid reflects changes immediately
|
|
||||||
setUsers((prev) =>
|
|
||||||
prev.map((u) =>
|
|
||||||
u.id === selectedUser.id
|
|
||||||
? {
|
|
||||||
...u,
|
|
||||||
email: editForm.email,
|
|
||||||
firstName: editForm.firstName,
|
|
||||||
lastName: editForm.lastName,
|
|
||||||
role: editForm.role,
|
|
||||||
phone: editForm.phone || undefined,
|
|
||||||
gymId: editForm.gymId === "" ? undefined : editForm.gymId,
|
|
||||||
}
|
|
||||||
: u,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
setSelectedUser((prev) =>
|
|
||||||
prev
|
|
||||||
? {
|
|
||||||
...prev,
|
|
||||||
email: editForm.email,
|
|
||||||
firstName: editForm.firstName,
|
|
||||||
lastName: editForm.lastName,
|
|
||||||
role: editForm.role,
|
|
||||||
phone: editForm.phone || undefined,
|
|
||||||
gymId: editForm.gymId === "" ? undefined : editForm.gymId,
|
|
||||||
}
|
|
||||||
: prev,
|
|
||||||
);
|
|
||||||
setIsEditing(false);
|
|
||||||
setEditForm(null);
|
|
||||||
// Still re-fetch from server to ensure consistency
|
|
||||||
log.debug("Re-fetching users after successful edit");
|
|
||||||
fetchUsers();
|
|
||||||
toast.success("User updated successfully");
|
|
||||||
} else {
|
|
||||||
const errText = await response.text().catch(() => "");
|
|
||||||
log.error("User update failed", new Error(errText), {
|
|
||||||
status: response.status,
|
|
||||||
});
|
|
||||||
toast.error("Error updating user");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Create (Invite) new user
|
|
||||||
const response = await fetch("/api/invitations", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({
|
|
||||||
inviteeEmail: editForm.email,
|
|
||||||
roleAssigned: editForm.role,
|
|
||||||
gymId: editForm.gymId || undefined,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.ok) {
|
await updateUser.mutateAsync(payload);
|
||||||
setIsEditing(false);
|
setIsEditing(false);
|
||||||
setEditForm(null);
|
setEditForm(null);
|
||||||
fetchUsers();
|
refetch();
|
||||||
toast.success("Invitation sent successfully!");
|
toast.success("User updated successfully");
|
||||||
} else {
|
} else {
|
||||||
const errorData = await response.json();
|
await sendInvitation.mutateAsync({
|
||||||
toast.error(`Error sending invitation: ${errorData.error}`);
|
email: editForm.email,
|
||||||
}
|
role: editForm.role,
|
||||||
|
});
|
||||||
|
setIsEditing(false);
|
||||||
|
setEditForm(null);
|
||||||
|
refetch();
|
||||||
|
toast.success("Invitation sent successfully!");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -299,17 +163,11 @@ export function UserManagement() {
|
|||||||
if (!selectedUser) return;
|
if (!selectedUser) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/users?id=${selectedUser.id}`, {
|
await deleteUser.mutateAsync(selectedUser.id);
|
||||||
method: "DELETE",
|
setIsDeleting(false);
|
||||||
});
|
setSelectedUser(null);
|
||||||
if (response.ok) {
|
refetch();
|
||||||
setIsDeleting(false);
|
toast.success("User deleted successfully");
|
||||||
setSelectedUser(null);
|
|
||||||
fetchUsers();
|
|
||||||
toast.success("User deleted successfully");
|
|
||||||
} else {
|
|
||||||
toast.error("Error deleting user");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Failed to delete user", error);
|
log.error("Failed to delete user", error);
|
||||||
}
|
}
|
||||||
@@ -397,7 +255,7 @@ export function UserManagement() {
|
|||||||
onEditUser={handleEditUser}
|
onEditUser={handleEditUser}
|
||||||
onDeleteUser={handleDeleteUser}
|
onDeleteUser={handleDeleteUser}
|
||||||
onBulkDelete={handleBulkDelete}
|
onBulkDelete={handleBulkDelete}
|
||||||
loading={loading}
|
loading={isLoading}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -591,7 +449,9 @@ export function UserManagement() {
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="font-medium">Joined:</span>{" "}
|
<span className="font-medium">Joined:</span>{" "}
|
||||||
{new Date(selectedUser.createdAt).toLocaleDateString()}
|
{selectedUser.createdAt
|
||||||
|
? new Date(selectedUser.createdAt).toLocaleDateString()
|
||||||
|
: "N/A"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -653,7 +513,7 @@ export function UserManagement() {
|
|||||||
<CreateUserModal
|
<CreateUserModal
|
||||||
open={createModalOpen}
|
open={createModalOpen}
|
||||||
onOpenChange={setCreateModalOpen}
|
onOpenChange={setCreateModalOpen}
|
||||||
onSuccess={() => fetchUsers()}
|
onSuccess={() => refetch()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,380 @@
|
|||||||
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
export interface DashboardStats {
|
||||||
|
totalUsers: number;
|
||||||
|
activeClients: number;
|
||||||
|
totalRevenue: number;
|
||||||
|
revenueGrowth: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
role: string;
|
||||||
|
phone?: string;
|
||||||
|
gymId?: string;
|
||||||
|
gymName?: string | null;
|
||||||
|
createdAt?: string;
|
||||||
|
isCheckedIn?: boolean;
|
||||||
|
checkInTime?: string;
|
||||||
|
lastCheckInTime?: string;
|
||||||
|
checkInsThisWeek?: number;
|
||||||
|
checkInsThisMonth?: number;
|
||||||
|
client?: {
|
||||||
|
id: string;
|
||||||
|
membershipType: string;
|
||||||
|
membershipStatus: string;
|
||||||
|
joinDate: string;
|
||||||
|
lastVisit?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Recommendation {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
type: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
content?: string;
|
||||||
|
recommendationText?: string;
|
||||||
|
activityPlan?: string;
|
||||||
|
dietPlan?: string;
|
||||||
|
status: "pending" | "approved" | "rejected";
|
||||||
|
createdAt: string;
|
||||||
|
user?: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Gym {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
address?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AttendanceRecord {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
checkIn: string;
|
||||||
|
checkOut?: string;
|
||||||
|
date: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchApi<T>(url: string, options?: RequestInit): Promise<T> {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...options?.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const error = await response
|
||||||
|
.json()
|
||||||
|
.catch(() => ({ error: "Request failed" }));
|
||||||
|
throw new Error(error.error || `HTTP ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDashboardStats(gymId?: string) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["dashboard-stats", gymId],
|
||||||
|
queryFn: () => {
|
||||||
|
const url = gymId
|
||||||
|
? `/api/admin/stats?gymId=${gymId}`
|
||||||
|
: "/api/admin/stats";
|
||||||
|
return fetchApi<{ data: { stats: DashboardStats } }>(url).then(
|
||||||
|
(res) => res.data?.stats,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUsers(filters?: {
|
||||||
|
role?: string;
|
||||||
|
gymId?: string;
|
||||||
|
search?: string;
|
||||||
|
}) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (filters?.role) params.set("role", filters.role);
|
||||||
|
if (filters?.gymId) params.set("gymId", filters.gymId);
|
||||||
|
if (filters?.search) params.set("search", filters.search);
|
||||||
|
|
||||||
|
const queryString = params.toString();
|
||||||
|
const url = queryString ? `/api/users?${queryString}` : "/api/users";
|
||||||
|
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["users", filters],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { users: User[] } }>(url).then(
|
||||||
|
(res) => res.data?.users ?? [],
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUser(userId: string) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["user", userId],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { user: User } }>(`/api/users?id=${userId}`).then(
|
||||||
|
(res) => res.data?.user,
|
||||||
|
),
|
||||||
|
enabled: !!userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRecommendations(filters?: {
|
||||||
|
userId?: string;
|
||||||
|
status?: string;
|
||||||
|
}) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (filters?.userId) params.set("userId", filters.userId);
|
||||||
|
if (filters?.status) params.set("status", filters.status);
|
||||||
|
|
||||||
|
const queryString = params.toString();
|
||||||
|
const url = queryString
|
||||||
|
? `/api/recommendations?${queryString}`
|
||||||
|
: "/api/recommendations";
|
||||||
|
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["recommendations", filters],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { recommendations: Recommendation[] } }>(url).then(
|
||||||
|
(res) => res.data?.recommendations ?? [],
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePendingRecommendationsCount() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["pending-recommendations-count"],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { recommendations: Recommendation[] } }>(
|
||||||
|
"/api/recommendations",
|
||||||
|
).then(
|
||||||
|
(res) =>
|
||||||
|
(res.data?.recommendations ?? []).filter(
|
||||||
|
(r) => r.status === "pending",
|
||||||
|
).length,
|
||||||
|
),
|
||||||
|
refetchInterval: 30000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGyms() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["gyms"],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { gyms: Gym[] } }>("/api/gyms").then(
|
||||||
|
(res) => res.data?.gyms ?? [],
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAttendance(filters?: { userId?: string; date?: string }) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (filters?.userId) params.set("userId", filters.userId);
|
||||||
|
if (filters?.date) params.set("date", filters.date);
|
||||||
|
|
||||||
|
const queryString = params.toString();
|
||||||
|
const url = queryString
|
||||||
|
? `/api/admin/attendance?${queryString}`
|
||||||
|
: "/api/admin/attendance";
|
||||||
|
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["attendance", filters],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { records: AttendanceRecord[] } }>(url).then(
|
||||||
|
(res) => res.data?.records ?? [],
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreateUser() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: {
|
||||||
|
email: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
role: string;
|
||||||
|
phone?: string;
|
||||||
|
gymId?: string;
|
||||||
|
}) =>
|
||||||
|
fetchApi<{ data: { userId: string } }>("/api/users/create", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
}).then((res) => res.data),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["dashboard-stats"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateUser() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: { id: string; [key: string]: unknown }) =>
|
||||||
|
fetchApi<{ data: { success: boolean } }>(`/api/users?id=${data.id}`, {
|
||||||
|
method: "PUT",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
}),
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user", variables.id] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDeleteUser() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (userId: string) =>
|
||||||
|
fetchApi<{ data: { success: boolean } }>(`/api/users?id=${userId}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["dashboard-stats"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGenerateRecommendations() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (userId?: string) =>
|
||||||
|
fetchApi<{
|
||||||
|
data: { success: boolean; recommendations?: Recommendation[] };
|
||||||
|
}>("/api/recommendations/generate", {
|
||||||
|
method: "POST",
|
||||||
|
body: userId ? JSON.stringify({ userId }) : undefined,
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["recommendations"] });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["pending-recommendations-count"],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useApproveRecommendation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: { recommendationId: string; approved: boolean }) =>
|
||||||
|
fetchApi<{ data: { success: boolean } }>("/api/recommendations/approve", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["recommendations"] });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["pending-recommendations-count"],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateRecommendation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: {
|
||||||
|
id: string;
|
||||||
|
content?: string;
|
||||||
|
activityPlan?: string;
|
||||||
|
dietPlan?: string;
|
||||||
|
}) =>
|
||||||
|
fetchApi<{ data: { success: boolean } }>("/api/recommendations", {
|
||||||
|
method: "PUT",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["recommendations"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCheckIn() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (userId: string) =>
|
||||||
|
fetchApi<{ data: { success: boolean; record: AttendanceRecord } }>(
|
||||||
|
"/api/attendance/check-in",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ userId }),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["attendance"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCheckOut() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (userId: string) =>
|
||||||
|
fetchApi<{ data: { success: boolean } }>("/api/attendance/check-out", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ userId }),
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["attendance"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useInvitations() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["invitations"],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { invitations: unknown[] } }>("/api/invitations").then(
|
||||||
|
(res) => res.data?.invitations ?? [],
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useSendInvitation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: { email: string; role: string }) =>
|
||||||
|
fetchApi<{ data: { success: boolean } }>("/api/invitations", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["invitations"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AnalyticsData {
|
||||||
|
userGrowth: { label: string; value: number }[];
|
||||||
|
membershipDistribution: { label: string; value: number; color: string }[];
|
||||||
|
revenue: { label: string; value: number; color: string }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAnalytics(months: number = 6) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["analytics", months],
|
||||||
|
queryFn: () =>
|
||||||
|
fetchApi<{ data: { analytics: AnalyticsData } }>(
|
||||||
|
`/api/admin/analytics?months=${months}`,
|
||||||
|
).then((res) => res.data?.analytics),
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -96,9 +96,13 @@ export default function OnboardingScreen() {
|
|||||||
|
|
||||||
const fitnessData = {
|
const fitnessData = {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
height: parseFloat(fitnessProfile.height),
|
height: fitnessProfile.height
|
||||||
weight: parseFloat(fitnessProfile.weight),
|
? parseFloat(fitnessProfile.height)
|
||||||
age: parseInt(fitnessProfile.age),
|
: undefined,
|
||||||
|
weight: fitnessProfile.weight
|
||||||
|
? parseFloat(fitnessProfile.weight)
|
||||||
|
: undefined,
|
||||||
|
age: fitnessProfile.age ? parseInt(fitnessProfile.age, 10) : undefined,
|
||||||
fitnessGoals: fitnessProfile.goals ? [fitnessProfile.goals] : [],
|
fitnessGoals: fitnessProfile.goals ? [fitnessProfile.goals] : [],
|
||||||
medicalConditions: fitnessProfile.medicalConditions || undefined,
|
medicalConditions: fitnessProfile.medicalConditions || undefined,
|
||||||
allergies: fitnessProfile.dietaryRestrictions || undefined,
|
allergies: fitnessProfile.dietaryRestrictions || undefined,
|
||||||
|
|||||||
@@ -103,20 +103,22 @@ export default function AttendanceScreen() {
|
|||||||
>
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<Text style={[typography.h1, { color: colors.textPrimary }]}>
|
<Text
|
||||||
📍 Attendance
|
style={[typography.h1, { color: colors.textPrimary, fontSize: 32 }]}
|
||||||
|
>
|
||||||
|
Attendance
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.body,
|
typography.body,
|
||||||
{ color: colors.textSecondary, marginTop: 4 },
|
{ color: colors.textSecondary, marginTop: 8 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{activeCheckIn
|
{activeCheckIn
|
||||||
? "You're crushing it today! 💪"
|
? "You're crushing it today!"
|
||||||
: history.length === 0
|
: history.length === 0
|
||||||
? "Ready to start your fitness journey? 🚀"
|
? "Ready to start your fitness journey?"
|
||||||
: "Track your gym visits and build streaks! 🔥"}
|
: "Track your gym visits and build streaks!"}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
@@ -150,21 +150,26 @@ export default function GoalsScreen() {
|
|||||||
>
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<View>
|
<View style={{ flex: 1 }}>
|
||||||
<Text style={[typography.h1, { color: colors.textPrimary }]}>
|
<Text
|
||||||
🎯 Fitness Goals
|
style={[
|
||||||
|
typography.h1,
|
||||||
|
{ color: colors.textPrimary, fontSize: 32 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Goals
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.body,
|
typography.body,
|
||||||
{ color: colors.textSecondary, marginTop: 4 },
|
{ color: colors.textSecondary, marginTop: 8 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{activeGoals.length === 0
|
{activeGoals.length === 0
|
||||||
? "Ready to crush some goals? 💪"
|
? "Ready to crush some goals?"
|
||||||
: activeGoals.length === 1
|
: activeGoals.length === 1
|
||||||
? "You're on a mission! Keep it up! 🚀"
|
? "You're on a mission! Keep it up!"
|
||||||
: `${activeGoals.length} goals in progress. Legend! ⭐`}
|
: `${activeGoals.length} goals in progress. Let's go!`}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -183,45 +188,69 @@ export default function GoalsScreen() {
|
|||||||
{goals && goals.length > 0 && (
|
{goals && goals.length > 0 && (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<View style={styles.statsRow}>
|
<View style={styles.statsRow}>
|
||||||
<MinimalCard variant="bordered" style={styles.statCard}>
|
<MinimalCard
|
||||||
<Text style={[typography.stat, { color: colors.primary }]}>
|
variant="elevated"
|
||||||
|
style={[styles.statCard, { backgroundColor: colors.primary }]}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.white, fontSize: 36 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
{activeGoals.length}
|
{activeGoals.length}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.caption,
|
typography.label,
|
||||||
{ color: colors.textTertiary, marginTop: 4 },
|
{ color: "rgba(255,255,255,0.8)", marginTop: 4 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
🎯 Active
|
ACTIVE
|
||||||
</Text>
|
</Text>
|
||||||
</MinimalCard>
|
</MinimalCard>
|
||||||
|
|
||||||
<MinimalCard variant="bordered" style={styles.statCard}>
|
<MinimalCard
|
||||||
<Text style={[typography.stat, { color: colors.success }]}>
|
variant="elevated"
|
||||||
|
style={[styles.statCard, { backgroundColor: colors.success }]}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.white, fontSize: 36 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
{completedGoals.length}
|
{completedGoals.length}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.caption,
|
typography.label,
|
||||||
{ color: colors.textTertiary, marginTop: 4 },
|
{ color: "rgba(255,255,255,0.8)", marginTop: 4 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{completedGoals.length >= 5 ? "🏆" : "✅"} Completed
|
COMPLETED
|
||||||
</Text>
|
</Text>
|
||||||
</MinimalCard>
|
</MinimalCard>
|
||||||
|
|
||||||
<MinimalCard variant="bordered" style={styles.statCard}>
|
<MinimalCard
|
||||||
<Text style={[typography.stat, { color: colors.textPrimary }]}>
|
variant="elevated"
|
||||||
|
style={[styles.statCard, { backgroundColor: colors.accent }]}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.white, fontSize: 36 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
{avgProgress}%
|
{avgProgress}%
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.caption,
|
typography.label,
|
||||||
{ color: colors.textTertiary, marginTop: 4 },
|
{ color: "rgba(255,255,255,0.8)", marginTop: 4 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{avgProgress >= 75 ? "🔥" : "📊"} Progress
|
PROGRESS
|
||||||
</Text>
|
</Text>
|
||||||
</MinimalCard>
|
</MinimalCard>
|
||||||
</View>
|
</View>
|
||||||
@@ -229,66 +258,104 @@ export default function GoalsScreen() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Analytics Section */}
|
{/* Analytics Section */}
|
||||||
{statistics && (
|
{statistics &&
|
||||||
<View style={styles.section}>
|
(statistics.weeklyTrend.length > 0 ||
|
||||||
<MinimalCard variant="default">
|
statistics.goals.goalsByType.length > 0) && (
|
||||||
|
<View style={styles.section}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.analyticsHeader}
|
|
||||||
onPress={() => setShowAnalytics(!showAnalytics)}
|
onPress={() => setShowAnalytics(!showAnalytics)}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.85}
|
||||||
>
|
>
|
||||||
<View style={styles.analyticsHeaderLeft}>
|
<MinimalCard variant="elevated" style={styles.analyticsCard}>
|
||||||
<Ionicons
|
<View style={styles.analyticsHeader}>
|
||||||
name="bar-chart-outline"
|
<View style={styles.analyticsHeaderLeft}>
|
||||||
size={20}
|
<View
|
||||||
color={colors.primary}
|
style={[
|
||||||
/>
|
styles.analyticsIcon,
|
||||||
<Text
|
{ backgroundColor: `${colors.primary}15` },
|
||||||
style={[
|
]}
|
||||||
typography.h3,
|
>
|
||||||
{ color: colors.textPrimary, marginLeft: 8 },
|
<Ionicons
|
||||||
]}
|
name="bar-chart"
|
||||||
>
|
size={24}
|
||||||
📈 Progress Analytics
|
color={colors.primary}
|
||||||
</Text>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Ionicons
|
<View>
|
||||||
name={showAnalytics ? "chevron-up" : "chevron-down"}
|
<Text
|
||||||
size={20}
|
style={[typography.h3, { color: colors.textPrimary }]}
|
||||||
color={colors.textTertiary}
|
>
|
||||||
/>
|
Progress Analytics
|
||||||
</TouchableOpacity>
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary, marginTop: 2 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{showAnalytics ? "Tap to collapse" : "Tap to expand"}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.analyticsToggle,
|
||||||
|
{ backgroundColor: colors.surfaceElevated },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name={showAnalytics ? "chevron-up" : "chevron-down"}
|
||||||
|
size={20}
|
||||||
|
color={colors.textSecondary}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
{showAnalytics && (
|
{showAnalytics && (
|
||||||
<View
|
<View style={styles.analyticsContent}>
|
||||||
style={[
|
{statistics.weeklyTrend.length > 0 && (
|
||||||
styles.analyticsContent,
|
<View style={styles.chartSection}>
|
||||||
{ borderTopColor: colors.border },
|
<Text
|
||||||
]}
|
style={[
|
||||||
>
|
typography.h4,
|
||||||
{statistics.weeklyTrend.length > 0 && (
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
<WeeklyProgressChart
|
]}
|
||||||
weeklyData={statistics.weeklyTrend}
|
>
|
||||||
title="8-Week Trend"
|
Weekly Trend
|
||||||
/>
|
</Text>
|
||||||
|
<WeeklyProgressChart
|
||||||
|
weeklyData={statistics.weeklyTrend}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
{statistics.goals.goalsByType.length > 0 && (
|
||||||
|
<View style={styles.chartSection}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.h4,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Goals by Type
|
||||||
|
</Text>
|
||||||
|
<GoalTypeBreakdownChart
|
||||||
|
data={statistics.goals.goalsByType}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
{statistics.goals.goalsByType.length > 0 && (
|
</MinimalCard>
|
||||||
<GoalTypeBreakdownChart
|
</TouchableOpacity>
|
||||||
data={statistics.goals.goalsByType}
|
</View>
|
||||||
title="Goals by Type"
|
)}
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
</MinimalCard>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Active Goals */}
|
{/* Active Goals */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
title={`🚀 Active Goals (${activeGoals.length})`}
|
title={`Active Goals (${activeGoals.length})`}
|
||||||
actionLabel="Add New"
|
subtitle="Keep pushing forward!"
|
||||||
|
actionLabel="+ Add New"
|
||||||
onActionPress={() => setIsModalVisible(true)}
|
onActionPress={() => setIsModalVisible(true)}
|
||||||
/>
|
/>
|
||||||
{activeGoals.length === 0 ? (
|
{activeGoals.length === 0 ? (
|
||||||
@@ -331,7 +398,8 @@ export default function GoalsScreen() {
|
|||||||
{completedGoals.length > 0 && (
|
{completedGoals.length > 0 && (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
title={`✨ Completed Goals (${completedGoals.length})`}
|
title={`Completed (${completedGoals.length})`}
|
||||||
|
subtitle="Great work!"
|
||||||
/>
|
/>
|
||||||
<View style={styles.goalsList}>
|
<View style={styles.goalsList}>
|
||||||
{completedGoals.map((goal) => (
|
{completedGoals.map((goal) => (
|
||||||
@@ -386,15 +454,15 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "flex-start",
|
alignItems: "flex-start",
|
||||||
paddingHorizontal: 24,
|
paddingHorizontal: 20,
|
||||||
paddingTop: 60,
|
paddingTop: 60,
|
||||||
paddingBottom: 24,
|
paddingBottom: 20,
|
||||||
},
|
},
|
||||||
debugButton: {
|
debugButton: {
|
||||||
padding: 8,
|
padding: 8,
|
||||||
},
|
},
|
||||||
section: {
|
section: {
|
||||||
paddingHorizontal: 24,
|
paddingHorizontal: 20,
|
||||||
marginBottom: 24,
|
marginBottom: 24,
|
||||||
},
|
},
|
||||||
statsRow: {
|
statsRow: {
|
||||||
@@ -405,8 +473,12 @@ const styles = StyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
paddingVertical: 20,
|
paddingVertical: 20,
|
||||||
|
paddingHorizontal: 12,
|
||||||
borderRadius: 20,
|
borderRadius: 20,
|
||||||
},
|
},
|
||||||
|
analyticsCard: {
|
||||||
|
padding: 20,
|
||||||
|
},
|
||||||
analyticsHeader: {
|
analyticsHeader: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
@@ -416,13 +488,32 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
|
analyticsIcon: {
|
||||||
|
width: 48,
|
||||||
|
height: 48,
|
||||||
|
borderRadius: 14,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginRight: 14,
|
||||||
|
},
|
||||||
|
analyticsToggle: {
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
borderRadius: 10,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
analyticsContent: {
|
analyticsContent: {
|
||||||
paddingTop: 16,
|
paddingTop: 24,
|
||||||
marginTop: 16,
|
marginTop: 20,
|
||||||
borderTopWidth: 1,
|
borderTopWidth: 1,
|
||||||
|
borderTopColor: "rgba(0,0,0,0.05)",
|
||||||
|
},
|
||||||
|
chartSection: {
|
||||||
|
marginBottom: 20,
|
||||||
},
|
},
|
||||||
goalsList: {
|
goalsList: {
|
||||||
gap: 12,
|
gap: 16,
|
||||||
},
|
},
|
||||||
emptyState: {
|
emptyState: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@@ -433,18 +524,18 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
fabContainer: {
|
fabContainer: {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
right: 24,
|
right: 20,
|
||||||
bottom: 90,
|
bottom: 90,
|
||||||
},
|
},
|
||||||
fab: {
|
fab: {
|
||||||
width: 56,
|
width: 64,
|
||||||
height: 56,
|
height: 64,
|
||||||
borderRadius: 28,
|
borderRadius: 22,
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
shadowOffset: { width: 0, height: 4 },
|
shadowOffset: { width: 0, height: 6 },
|
||||||
shadowOpacity: 0.2,
|
shadowOpacity: 0.35,
|
||||||
shadowRadius: 8,
|
shadowRadius: 12,
|
||||||
elevation: 4,
|
elevation: 8,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -19,6 +19,7 @@ import { MinimalButton } from "../../components/MinimalButton";
|
|||||||
import { Badge } from "../../components/Badge";
|
import { Badge } from "../../components/Badge";
|
||||||
import { IconContainer } from "../../components/IconContainer";
|
import { IconContainer } from "../../components/IconContainer";
|
||||||
import { API_BASE_URL, API_ENDPOINTS } from "../../config/api";
|
import { API_BASE_URL, API_ENDPOINTS } from "../../config/api";
|
||||||
|
import { fitnessProfileApi, FitnessProfile } from "../../api/fitnessProfile";
|
||||||
import log from "../../utils/logger";
|
import log from "../../utils/logger";
|
||||||
|
|
||||||
export default function ProfileScreen() {
|
export default function ProfileScreen() {
|
||||||
@@ -35,6 +36,11 @@ export default function ProfileScreen() {
|
|||||||
const [selectedGymId, setSelectedGymId] = useState<string | null>(null);
|
const [selectedGymId, setSelectedGymId] = useState<string | null>(null);
|
||||||
const [currentGymId, setCurrentGymId] = useState<string | null>(null);
|
const [currentGymId, setCurrentGymId] = useState<string | null>(null);
|
||||||
const [currentGymName, setCurrentGymName] = useState<string | null>(null);
|
const [currentGymName, setCurrentGymName] = useState<string | null>(null);
|
||||||
|
const [showGymDropdown, setShowGymDropdown] = useState(false);
|
||||||
|
const [fitnessProfile, setFitnessProfile] = useState<FitnessProfile | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const [profileLoading, setProfileLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const gid =
|
const gid =
|
||||||
@@ -49,8 +55,23 @@ export default function ProfileScreen() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadGyms();
|
loadGyms();
|
||||||
|
loadFitnessProfile();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const loadFitnessProfile = async () => {
|
||||||
|
try {
|
||||||
|
setProfileLoading(true);
|
||||||
|
const token = await getToken();
|
||||||
|
if (!token) return;
|
||||||
|
const profile = await fitnessProfileApi.getFitnessProfile(token);
|
||||||
|
setFitnessProfile(profile);
|
||||||
|
} catch (error) {
|
||||||
|
log.error("Failed to load fitness profile", error);
|
||||||
|
} finally {
|
||||||
|
setProfileLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const loadGyms = async () => {
|
const loadGyms = async () => {
|
||||||
try {
|
try {
|
||||||
setGymsLoading(true);
|
setGymsLoading(true);
|
||||||
@@ -115,8 +136,12 @@ export default function ProfileScreen() {
|
|||||||
const handleApplyGym = async () => {
|
const handleApplyGym = async () => {
|
||||||
try {
|
try {
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
const url = `${API_BASE_URL}${API_ENDPOINTS.USERS}/gym`;
|
const url = `${API_BASE_URL}${API_ENDPOINTS.USERS.GYM}`;
|
||||||
log.debug("Updating gym selection", { url, gymId: selectedGymId });
|
log.debug("Updating gym selection", {
|
||||||
|
url,
|
||||||
|
gymId: selectedGymId,
|
||||||
|
token: token ? "present" : "missing",
|
||||||
|
});
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -213,7 +238,10 @@ export default function ProfileScreen() {
|
|||||||
contentContainerStyle={styles.content}
|
contentContainerStyle={styles.content}
|
||||||
>
|
>
|
||||||
{/* Header Card */}
|
{/* Header Card */}
|
||||||
<MinimalCard variant="elevated" style={styles.profileCard}>
|
<MinimalCard
|
||||||
|
variant="elevated"
|
||||||
|
style={[styles.profileCard, { backgroundColor: colors.primary }]}
|
||||||
|
>
|
||||||
<View style={styles.avatarContainer}>
|
<View style={styles.avatarContainer}>
|
||||||
{user?.imageUrl ? (
|
{user?.imageUrl ? (
|
||||||
<Image source={{ uri: user.imageUrl }} style={styles.avatar} />
|
<Image source={{ uri: user.imageUrl }} style={styles.avatar} />
|
||||||
@@ -221,29 +249,36 @@ export default function ProfileScreen() {
|
|||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.placeholderAvatar,
|
styles.placeholderAvatar,
|
||||||
{ backgroundColor: colors.primary },
|
{
|
||||||
|
backgroundColor: colors.white,
|
||||||
|
borderWidth: 3,
|
||||||
|
borderColor: colors.white,
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Ionicons name="person" size={40} color={colors.white} />
|
<Ionicons name="person" size={40} color={colors.primary} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<Text
|
<Text
|
||||||
style={[typography.h2, { color: colors.textPrimary, marginTop: 16 }]}
|
style={[
|
||||||
|
typography.h1,
|
||||||
|
{ color: colors.white, marginTop: 16, fontSize: 28 },
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
{user?.fullName || "User"}
|
{user?.fullName || "User"}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.body,
|
typography.body,
|
||||||
{ color: colors.textSecondary, marginTop: 4 },
|
{ color: "rgba(255,255,255,0.8)", marginTop: 4 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{user?.primaryEmailAddress?.emailAddress}
|
{user?.primaryEmailAddress?.emailAddress}
|
||||||
</Text>
|
</Text>
|
||||||
<Badge
|
<Badge
|
||||||
label="Premium Member"
|
label="Premium Member"
|
||||||
variant="primary"
|
variant="success"
|
||||||
style={{ marginTop: 12 }}
|
style={{ marginTop: 12 }}
|
||||||
/>
|
/>
|
||||||
</MinimalCard>
|
</MinimalCard>
|
||||||
@@ -321,29 +356,145 @@ export default function ProfileScreen() {
|
|||||||
onPress={() => router.push("/personal-details")}
|
onPress={() => router.push("/personal-details")}
|
||||||
/>
|
/>
|
||||||
<View style={[styles.divider, { backgroundColor: colors.border }]} />
|
<View style={[styles.divider, { backgroundColor: colors.border }]} />
|
||||||
<ListItem
|
|
||||||
title="Fitness Profile"
|
{/* Fitness Profile Card */}
|
||||||
leftIcon={
|
<TouchableOpacity
|
||||||
<IconContainer
|
|
||||||
variant="colored"
|
|
||||||
backgroundColor={`${colors.success}20`}
|
|
||||||
>
|
|
||||||
<Ionicons
|
|
||||||
name="fitness-outline"
|
|
||||||
size={20}
|
|
||||||
color={colors.success}
|
|
||||||
/>
|
|
||||||
</IconContainer>
|
|
||||||
}
|
|
||||||
rightElement={
|
|
||||||
<Ionicons
|
|
||||||
name="chevron-forward"
|
|
||||||
size={20}
|
|
||||||
color={colors.textTertiary}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onPress={() => router.push("/fitness-profile")}
|
onPress={() => router.push("/fitness-profile")}
|
||||||
/>
|
activeOpacity={0.85}
|
||||||
|
>
|
||||||
|
<MinimalCard variant="elevated" style={styles.fitnessProfileCard}>
|
||||||
|
<View style={styles.fitnessProfileHeader}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.fitnessProfileIcon,
|
||||||
|
{ backgroundColor: colors.success },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons name="fitness" size={24} color={colors.white} />
|
||||||
|
</View>
|
||||||
|
<View style={{ flex: 1, marginLeft: 14 }}>
|
||||||
|
<Text style={[typography.h4, { color: colors.textPrimary }]}>
|
||||||
|
Fitness Profile
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary, marginTop: 2 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{fitnessProfile ? "Tap to edit" : "Set up your profile"}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.editButton,
|
||||||
|
{ backgroundColor: colors.primary },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons name="pencil" size={16} color={colors.white} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{profileLoading ? (
|
||||||
|
<View style={styles.profileLoading}>
|
||||||
|
<ActivityIndicator color={colors.primary} />
|
||||||
|
</View>
|
||||||
|
) : fitnessProfile ? (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.fitnessProfileStats,
|
||||||
|
{ borderTopColor: colors.border },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<View style={styles.profileStat}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.primary, fontSize: 28 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{fitnessProfile.height || "-"}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Height (cm)
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.profileStatDivider,
|
||||||
|
{ backgroundColor: colors.border },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<View style={styles.profileStat}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.success, fontSize: 28 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{fitnessProfile.weight || "-"}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Weight (kg)
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.profileStatDivider,
|
||||||
|
{ backgroundColor: colors.border },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<View style={styles.profileStat}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.warning, fontSize: 28 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{fitnessProfile.age || "-"}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Age
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View
|
||||||
|
style={[styles.noProfile, { borderTopColor: colors.border }]}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[typography.body, { color: colors.textSecondary }]}
|
||||||
|
>
|
||||||
|
Complete your fitness profile to get personalized
|
||||||
|
recommendations
|
||||||
|
</Text>
|
||||||
|
<MinimalButton
|
||||||
|
title="Set Up Profile"
|
||||||
|
variant="primary"
|
||||||
|
size="sm"
|
||||||
|
style={{ marginTop: 12 }}
|
||||||
|
onPress={() => router.push("/fitness-profile")}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</MinimalCard>
|
||||||
|
</TouchableOpacity>
|
||||||
|
|
||||||
<View style={[styles.divider, { backgroundColor: colors.border }]} />
|
<View style={[styles.divider, { backgroundColor: colors.border }]} />
|
||||||
<ListItem
|
<ListItem
|
||||||
title="Notifications"
|
title="Notifications"
|
||||||
@@ -372,65 +523,71 @@ export default function ProfileScreen() {
|
|||||||
|
|
||||||
{/* Gym Selection */}
|
{/* Gym Selection */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<View style={styles.sectionHeader}>
|
<Text
|
||||||
<Text style={[typography.h3, { color: colors.textPrimary }]}>
|
style={[
|
||||||
Gym Selection
|
typography.h3,
|
||||||
</Text>
|
{ color: colors.textPrimary, marginBottom: 12 },
|
||||||
<TouchableOpacity onPress={loadGyms}>
|
]}
|
||||||
<Text
|
>
|
||||||
style={[
|
Gym Selection
|
||||||
typography.body,
|
</Text>
|
||||||
{ color: colors.primary, fontWeight: "600" },
|
|
||||||
]}
|
<TouchableOpacity
|
||||||
>
|
onPress={() => setShowGymDropdown(!showGymDropdown)}
|
||||||
Refresh
|
activeOpacity={0.85}
|
||||||
</Text>
|
>
|
||||||
</TouchableOpacity>
|
<MinimalCard variant="bordered" style={styles.dropdownCard}>
|
||||||
</View>
|
<View style={styles.dropdownHeader}>
|
||||||
<MinimalCard variant="default">
|
<View>
|
||||||
{currentGymName && (
|
<Text
|
||||||
<View style={styles.currentGym}>
|
style={[typography.caption, { color: colors.textTertiary }]}
|
||||||
<Text
|
>
|
||||||
style={[typography.caption, { color: colors.textTertiary }]}
|
Current Gym
|
||||||
>
|
</Text>
|
||||||
Current Gym
|
<Text
|
||||||
</Text>
|
style={[
|
||||||
<Text
|
typography.bodyEmphasis,
|
||||||
|
{ color: colors.textPrimary, marginTop: 2 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{currentGymName || "No gym selected"}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
style={[
|
style={[
|
||||||
typography.h3,
|
styles.dropdownIcon,
|
||||||
{ color: colors.textPrimary, marginTop: 4 },
|
{ backgroundColor: colors.surfaceElevated },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{currentGymName}
|
<Ionicons
|
||||||
</Text>
|
name={showGymDropdown ? "chevron-up" : "chevron-down"}
|
||||||
|
size={20}
|
||||||
|
color={colors.textSecondary}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
</MinimalCard>
|
||||||
|
</TouchableOpacity>
|
||||||
|
|
||||||
{gymsLoading ? (
|
{showGymDropdown && (
|
||||||
<View style={styles.loadingContainer}>
|
<MinimalCard variant="elevated" style={styles.dropdownOptions}>
|
||||||
<ActivityIndicator color={colors.primary} />
|
{gymsLoading ? (
|
||||||
</View>
|
<View style={styles.loadingContainer}>
|
||||||
) : (
|
<ActivityIndicator color={colors.primary} />
|
||||||
<>
|
</View>
|
||||||
<ScrollView
|
) : (
|
||||||
horizontal
|
<>
|
||||||
showsHorizontalScrollIndicator={false}
|
|
||||||
style={styles.gymScroll}
|
|
||||||
contentContainerStyle={styles.gymScrollContent}
|
|
||||||
>
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={[
|
style={[
|
||||||
styles.gymChip,
|
styles.dropdownOption,
|
||||||
{
|
selectedGymId === null && {
|
||||||
backgroundColor:
|
backgroundColor: `${colors.primary}15`,
|
||||||
selectedGymId === null
|
|
||||||
? `${colors.primary}20`
|
|
||||||
: colors.surfaceElevated,
|
|
||||||
borderColor:
|
|
||||||
selectedGymId === null ? colors.primary : colors.border,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onPress={() => setSelectedGymId(null)}
|
onPress={() => {
|
||||||
|
setSelectedGymId(null);
|
||||||
|
setShowGymDropdown(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
@@ -446,51 +603,78 @@ export default function ProfileScreen() {
|
|||||||
>
|
>
|
||||||
No Gym
|
No Gym
|
||||||
</Text>
|
</Text>
|
||||||
|
{selectedGymId === null && (
|
||||||
|
<Ionicons
|
||||||
|
name="checkmark"
|
||||||
|
size={20}
|
||||||
|
color={colors.primary}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
{gyms.map((gym) => (
|
{gyms.map((gym) => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={gym.id}
|
key={gym.id}
|
||||||
style={[
|
style={[
|
||||||
styles.gymChip,
|
styles.dropdownOption,
|
||||||
{
|
selectedGymId === gym.id && {
|
||||||
backgroundColor:
|
backgroundColor: `${colors.primary}15`,
|
||||||
selectedGymId === gym.id
|
|
||||||
? `${colors.primary}20`
|
|
||||||
: colors.surfaceElevated,
|
|
||||||
borderColor:
|
|
||||||
selectedGymId === gym.id
|
|
||||||
? colors.primary
|
|
||||||
: colors.border,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onPress={() => setSelectedGymId(gym.id)}
|
onPress={() => {
|
||||||
|
setSelectedGymId(gym.id);
|
||||||
|
setShowGymDropdown(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Text
|
<View style={{ flex: 1 }}>
|
||||||
style={[
|
<Text
|
||||||
typography.body,
|
style={[
|
||||||
{
|
typography.body,
|
||||||
color:
|
{
|
||||||
selectedGymId === gym.id
|
color:
|
||||||
? colors.primary
|
selectedGymId === gym.id
|
||||||
: colors.textSecondary,
|
? colors.primary
|
||||||
fontWeight: selectedGymId === gym.id ? "600" : "400",
|
: colors.textSecondary,
|
||||||
},
|
fontWeight:
|
||||||
]}
|
selectedGymId === gym.id ? "600" : "400",
|
||||||
>
|
},
|
||||||
{gym.name}
|
]}
|
||||||
</Text>
|
>
|
||||||
|
{gym.name}
|
||||||
|
</Text>
|
||||||
|
{gym.location && (
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary, marginTop: 2 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{gym.location}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
{selectedGymId === gym.id && (
|
||||||
|
<Ionicons
|
||||||
|
name="checkmark"
|
||||||
|
size={20}
|
||||||
|
color={colors.primary}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
))}
|
))}
|
||||||
</ScrollView>
|
{selectedGymId !== currentGymId && (
|
||||||
<MinimalButton
|
<MinimalButton
|
||||||
title="Apply Selection"
|
title="Apply Selection"
|
||||||
onPress={handleApplyGym}
|
onPress={handleApplyGym}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
style={{ marginTop: 16 }}
|
size="lg"
|
||||||
/>
|
fullWidth
|
||||||
</>
|
style={{ marginTop: 12 }}
|
||||||
)}
|
/>
|
||||||
</MinimalCard>
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</MinimalCard>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Support */}
|
{/* Support */}
|
||||||
@@ -580,8 +764,9 @@ const styles = StyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
padding: 24,
|
padding: 20,
|
||||||
paddingTop: 60,
|
paddingTop: 60,
|
||||||
|
paddingBottom: 100,
|
||||||
},
|
},
|
||||||
profileCard: {
|
profileCard: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@@ -640,4 +825,78 @@ const styles = StyleSheet.create({
|
|||||||
borderWidth: 1.5,
|
borderWidth: 1.5,
|
||||||
marginRight: 8,
|
marginRight: 8,
|
||||||
},
|
},
|
||||||
|
dropdownCard: {
|
||||||
|
padding: 16,
|
||||||
|
},
|
||||||
|
dropdownHeader: {
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
dropdownIcon: {
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
borderRadius: 10,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
dropdownOptions: {
|
||||||
|
marginTop: 8,
|
||||||
|
padding: 8,
|
||||||
|
},
|
||||||
|
dropdownOption: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
paddingVertical: 14,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
borderRadius: 12,
|
||||||
|
marginBottom: 4,
|
||||||
|
},
|
||||||
|
fitnessProfileCard: {
|
||||||
|
padding: 16,
|
||||||
|
},
|
||||||
|
fitnessProfileHeader: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
fitnessProfileIcon: {
|
||||||
|
width: 48,
|
||||||
|
height: 48,
|
||||||
|
borderRadius: 14,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
editButton: {
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
borderRadius: 8,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
profileLoading: {
|
||||||
|
paddingVertical: 20,
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
fitnessProfileStats: {
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "space-around",
|
||||||
|
marginTop: 20,
|
||||||
|
paddingTop: 16,
|
||||||
|
borderTopWidth: 1,
|
||||||
|
},
|
||||||
|
profileStat: {
|
||||||
|
alignItems: "center",
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
profileStatDivider: {
|
||||||
|
width: 1,
|
||||||
|
height: 40,
|
||||||
|
},
|
||||||
|
noProfile: {
|
||||||
|
marginTop: 16,
|
||||||
|
paddingTop: 16,
|
||||||
|
borderTopWidth: 1,
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
@@ -130,19 +130,24 @@ export default function RecommendationsScreen() {
|
|||||||
>
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<View>
|
<View style={{ flex: 1 }}>
|
||||||
<Text style={[typography.h1, { color: colors.textPrimary }]}>
|
<Text
|
||||||
✨ AI Recommendations
|
style={[
|
||||||
|
typography.h1,
|
||||||
|
{ color: colors.textPrimary, fontSize: 32 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Recommendations
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.body,
|
typography.body,
|
||||||
{ color: colors.textSecondary, marginTop: 4 },
|
{ color: colors.textSecondary, marginTop: 8 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{recommendations.length === 0
|
{recommendations.length === 0
|
||||||
? "Let's create your perfect plan! 🚀"
|
? "Let's create your perfect plan!"
|
||||||
: `${recommendations.length} plan${recommendations.length !== 1 ? "s" : ""} ready for you! 💪`}
|
: `${recommendations.length} plan${recommendations.length !== 1 ? "s" : ""} ready for you!`}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -152,9 +157,10 @@ export default function RecommendationsScreen() {
|
|||||||
>
|
>
|
||||||
<IconContainer
|
<IconContainer
|
||||||
variant="colored"
|
variant="colored"
|
||||||
backgroundColor={`${colors.accent}20`}
|
backgroundColor={colors.accent}
|
||||||
|
size="lg"
|
||||||
>
|
>
|
||||||
<Ionicons name="sparkles" size={24} color={colors.accent} />
|
<Ionicons name="sparkles" size={24} color={colors.white} />
|
||||||
{unreadCount > 0 && (
|
{unreadCount > 0 && (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -174,10 +180,11 @@ export default function RecommendationsScreen() {
|
|||||||
{/* Generate Button */}
|
{/* Generate Button */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<MinimalButton
|
<MinimalButton
|
||||||
title="🎯 Generate New Plan"
|
title="Generate New Plan"
|
||||||
onPress={handleGenerateRecommendation}
|
onPress={handleGenerateRecommendation}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
size="lg"
|
size="lg"
|
||||||
|
fullWidth
|
||||||
loading={generating}
|
loading={generating}
|
||||||
disabled={generating}
|
disabled={generating}
|
||||||
textStyle={{ fontSize: 16 }}
|
textStyle={{ fontSize: 16 }}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text,
|
Text,
|
||||||
@@ -9,13 +9,15 @@ import {
|
|||||||
Alert,
|
Alert,
|
||||||
TextInput,
|
TextInput,
|
||||||
Platform,
|
Platform,
|
||||||
} from 'react-native';
|
} from "react-native";
|
||||||
import { useRouter, Stack } from 'expo-router';
|
import { useRouter, Stack } from "expo-router";
|
||||||
import { useAuth } from '@clerk/clerk-expo';
|
import { useAuth } from "@clerk/clerk-expo";
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { LinearGradient } from 'expo-linear-gradient';
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
import { theme } from '../styles/theme';
|
import { MinimalCard } from "../components/MinimalCard";
|
||||||
import { API_BASE_URL } from '../config/api';
|
import { MinimalButton } from "../components/MinimalButton";
|
||||||
|
import { IconContainer } from "../components/IconContainer";
|
||||||
|
import { API_BASE_URL } from "../config/api";
|
||||||
|
|
||||||
interface FitnessProfileData {
|
interface FitnessProfileData {
|
||||||
height?: number;
|
height?: number;
|
||||||
@@ -30,29 +32,71 @@ interface FitnessProfileData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GENDER_OPTIONS = [
|
const GENDER_OPTIONS = [
|
||||||
{ label: 'Male', value: 'male', icon: 'male' },
|
{ label: "Male", value: "male", icon: "male-outline" },
|
||||||
{ label: 'Female', value: 'female', icon: 'female' },
|
{ label: "Female", value: "female", icon: "female-outline" },
|
||||||
{ label: 'Other', value: 'other', icon: 'transgender' },
|
{ label: "Other", value: "other", icon: "transgender-outline" },
|
||||||
|
{
|
||||||
|
label: "Prefer not to say",
|
||||||
|
value: "prefer_not_to_say",
|
||||||
|
icon: "help-circle-outline",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const FITNESS_GOAL_OPTIONS = [
|
const FITNESS_GOAL_OPTIONS = [
|
||||||
{ label: 'Weight Loss', value: 'weight_loss', icon: 'trending-down', color: theme.colors.danger },
|
{
|
||||||
{ label: 'Muscle Gain', value: 'muscle_gain', icon: 'barbell', color: theme.colors.primary },
|
label: "Weight Loss",
|
||||||
{ label: 'Endurance', value: 'endurance', icon: 'bicycle', color: theme.colors.success },
|
value: "weight_loss",
|
||||||
{ label: 'Flexibility', value: 'flexibility', icon: 'body', color: theme.colors.purple },
|
icon: "trending-down",
|
||||||
{ label: 'General Fitness', value: 'general_fitness', icon: 'fitness', color: theme.colors.warning },
|
color: "#FF3B3B",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Muscle Gain",
|
||||||
|
value: "muscle_gain",
|
||||||
|
icon: "barbell",
|
||||||
|
color: "#0066FF",
|
||||||
|
},
|
||||||
|
{ label: "Endurance", value: "endurance", icon: "bicycle", color: "#00D26A" },
|
||||||
|
{
|
||||||
|
label: "Flexibility",
|
||||||
|
value: "flexibility",
|
||||||
|
icon: "body",
|
||||||
|
color: "#7B2CBF",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "General Fitness",
|
||||||
|
value: "general_fitness",
|
||||||
|
icon: "fitness",
|
||||||
|
color: "#FFB800",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const ACTIVITY_LEVEL_OPTIONS = [
|
const ACTIVITY_LEVEL_OPTIONS = [
|
||||||
{ label: 'Sedentary', value: 'sedentary', description: 'Little to no exercise' },
|
{
|
||||||
{ label: 'Light', value: 'light', description: '1-3 days/week' },
|
label: "Sedentary",
|
||||||
{ label: 'Moderate', value: 'moderate', description: '3-5 days/week' },
|
value: "sedentary",
|
||||||
{ label: 'Active', value: 'active', description: '6-7 days/week' },
|
description: "Little to no exercise",
|
||||||
{ label: 'Very Active', value: 'very_active', description: 'Intense daily training' },
|
},
|
||||||
|
{
|
||||||
|
label: "Lightly Active",
|
||||||
|
value: "lightly_active",
|
||||||
|
description: "1-3 days/week",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Moderately Active",
|
||||||
|
value: "moderately_active",
|
||||||
|
description: "3-5 days/week",
|
||||||
|
},
|
||||||
|
{ label: "Very Active", value: "very_active", description: "6-7 days/week" },
|
||||||
|
{
|
||||||
|
label: "Extremely Active",
|
||||||
|
value: "extremely_active",
|
||||||
|
description: "Intense daily training",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function FitnessProfileScreen() {
|
export default function FitnessProfileScreen() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { colors, typography } = useTheme();
|
||||||
const { userId, getToken } = useAuth();
|
const { userId, getToken } = useAuth();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [fetchingProfile, setFetchingProfile] = useState(true);
|
const [fetchingProfile, setFetchingProfile] = useState(true);
|
||||||
@@ -66,34 +110,42 @@ export default function FitnessProfileScreen() {
|
|||||||
try {
|
try {
|
||||||
setFetchingProfile(true);
|
setFetchingProfile(true);
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
const response = await fetch(`${API_BASE_URL}/api/profile/fitness?userId=${userId}`, {
|
const response = await fetch(
|
||||||
headers: {
|
`${API_BASE_URL}/api/profile/fitness?userId=${userId}`,
|
||||||
Authorization: `Bearer ${token}`,
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.profile) {
|
if (data.profile) {
|
||||||
|
let activityLevel = data.profile.activityLevel || "";
|
||||||
|
if (activityLevel === "light") activityLevel = "lightly_active";
|
||||||
|
if (activityLevel === "moderate") activityLevel = "moderately_active";
|
||||||
|
if (activityLevel === "active") activityLevel = "very_active";
|
||||||
|
|
||||||
setProfileData({
|
setProfileData({
|
||||||
height: data.profile.height,
|
height: data.profile.height,
|
||||||
weight: data.profile.weight,
|
weight: data.profile.weight,
|
||||||
age: data.profile.age,
|
age: data.profile.age,
|
||||||
gender: data.profile.gender || '',
|
gender: data.profile.gender || "",
|
||||||
fitnessGoal: Array.isArray(data.profile.fitnessGoals)
|
fitnessGoal: Array.isArray(data.profile.fitnessGoals)
|
||||||
? data.profile.fitnessGoals[0]
|
? data.profile.fitnessGoals[0]
|
||||||
: (typeof data.profile.fitnessGoals === 'string'
|
: typeof data.profile.fitnessGoals === "string"
|
||||||
? JSON.parse(data.profile.fitnessGoals)[0]
|
? JSON.parse(data.profile.fitnessGoals)[0]
|
||||||
: ''),
|
: "",
|
||||||
activityLevel: data.profile.activityLevel || '',
|
activityLevel: activityLevel,
|
||||||
medicalConditions: data.profile.medicalConditions || '',
|
medicalConditions: data.profile.medicalConditions || "",
|
||||||
allergies: data.profile.allergies || '',
|
allergies: data.profile.allergies || "",
|
||||||
injuries: data.profile.injuries || '',
|
injuries: data.profile.injuries || "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching profile:', error);
|
console.error("Error fetching profile:", error);
|
||||||
} finally {
|
} finally {
|
||||||
setFetchingProfile(false);
|
setFetchingProfile(false);
|
||||||
}
|
}
|
||||||
@@ -104,40 +156,39 @@ export default function FitnessProfileScreen() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
|
|
||||||
// Prepare data with userId and convert fitnessGoal to fitnessGoals array
|
|
||||||
const dataToSave = {
|
const dataToSave = {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
height: profileData.height,
|
height: profileData.height,
|
||||||
weight: profileData.weight,
|
weight: profileData.weight,
|
||||||
age: profileData.age,
|
age: profileData.age,
|
||||||
gender: profileData.gender,
|
gender: profileData.gender || undefined,
|
||||||
fitnessGoals: profileData.fitnessGoal ? [profileData.fitnessGoal] : [],
|
fitnessGoals: profileData.fitnessGoal ? [profileData.fitnessGoal] : [],
|
||||||
activityLevel: profileData.activityLevel,
|
activityLevel: profileData.activityLevel || undefined,
|
||||||
medicalConditions: profileData.medicalConditions,
|
medicalConditions: profileData.medicalConditions,
|
||||||
allergies: profileData.allergies,
|
allergies: profileData.allergies,
|
||||||
injuries: profileData.injuries,
|
injuries: profileData.injuries,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch(`${API_BASE_URL}/api/profile/fitness`, {
|
const response = await fetch(`${API_BASE_URL}/api/profile/fitness`, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(dataToSave),
|
body: JSON.stringify(dataToSave),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
Alert.alert('Success', 'Fitness profile saved successfully!', [
|
Alert.alert("Success", "Fitness profile saved successfully!", [
|
||||||
{ text: 'OK', onPress: () => router.back() },
|
{ text: "OK", onPress: () => router.back() },
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
const error = await response.json();
|
const error = await response.json();
|
||||||
Alert.alert('Error', error.error || 'Failed to save profile');
|
Alert.alert("Error", error.error || "Failed to save profile");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving profile:', error);
|
console.error("Error saving profile:", error);
|
||||||
Alert.alert('Error', 'Failed to save fitness profile');
|
Alert.alert("Error", "Failed to save fitness profile");
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -149,8 +200,13 @@ export default function FitnessProfileScreen() {
|
|||||||
|
|
||||||
if (fetchingProfile) {
|
if (fetchingProfile) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.loadingContainer}>
|
<View
|
||||||
<ActivityIndicator size="large" color={theme.colors.primary} />
|
style={[
|
||||||
|
styles.loadingContainer,
|
||||||
|
{ backgroundColor: colors.background },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<ActivityIndicator size="large" color={colors.primary} />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -158,15 +214,28 @@ export default function FitnessProfileScreen() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen options={{ headerShown: false }} />
|
<Stack.Screen options={{ headerShown: false }} />
|
||||||
<View style={styles.container}>
|
<View style={[styles.container, { backgroundColor: colors.background }]}>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<LinearGradient colors={theme.gradients.primary} style={styles.header}>
|
<View
|
||||||
<TouchableOpacity style={styles.backButton} onPress={() => router.back()}>
|
style={[
|
||||||
|
styles.header,
|
||||||
|
{
|
||||||
|
backgroundColor: colors.primary,
|
||||||
|
paddingTop: Platform.OS === "ios" ? 60 : 40,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.backButton}
|
||||||
|
onPress={() => router.back()}
|
||||||
|
>
|
||||||
<Ionicons name="arrow-back" size={24} color="#fff" />
|
<Ionicons name="arrow-back" size={24} color="#fff" />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<Text style={styles.headerTitle}>Fitness Profile</Text>
|
<Text style={[typography.h2, { color: "#fff" }]}>
|
||||||
|
Fitness Profile
|
||||||
|
</Text>
|
||||||
<View style={{ width: 40 }} />
|
<View style={{ width: 40 }} />
|
||||||
</LinearGradient>
|
</View>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
style={styles.scrollView}
|
style={styles.scrollView}
|
||||||
@@ -175,87 +244,181 @@ export default function FitnessProfileScreen() {
|
|||||||
>
|
>
|
||||||
{/* Basic Information */}
|
{/* Basic Information */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>Basic Information</Text>
|
<Text
|
||||||
<View style={styles.card}>
|
style={[
|
||||||
<View style={styles.row}>
|
typography.h3,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Basic Information
|
||||||
|
</Text>
|
||||||
|
<MinimalCard variant="elevated" style={styles.card}>
|
||||||
|
<View style={styles.inputRow}>
|
||||||
<View style={styles.inputGroup}>
|
<View style={styles.inputGroup}>
|
||||||
<Text style={styles.label}>Height (cm)</Text>
|
<Text
|
||||||
<View style={styles.inputContainer}>
|
style={[
|
||||||
<Ionicons name="resize-outline" size={20} color={theme.colors.gray400} />
|
typography.label,
|
||||||
|
{ color: colors.textSecondary, marginBottom: 8 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
HEIGHT (CM)
|
||||||
|
</Text>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.inputContainer,
|
||||||
|
{
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
borderColor: colors.border,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name="resize"
|
||||||
|
size={20}
|
||||||
|
color={colors.textTertiary}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={[styles.input, { color: colors.textPrimary }]}
|
||||||
value={profileData.height?.toString() || ''}
|
value={profileData.height?.toString() || ""}
|
||||||
onChangeText={(text) =>
|
onChangeText={(text) =>
|
||||||
updateField('height', text ? parseFloat(text) : undefined)
|
updateField(
|
||||||
|
"height",
|
||||||
|
text ? parseFloat(text) : undefined,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
keyboardType="decimal-pad"
|
keyboardType="decimal-pad"
|
||||||
placeholder="175"
|
placeholder="175"
|
||||||
placeholderTextColor={theme.colors.gray400}
|
placeholderTextColor={colors.textTertiary}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputGroup}>
|
<View style={styles.inputGroup}>
|
||||||
<Text style={styles.label}>Weight (kg)</Text>
|
<Text
|
||||||
<View style={styles.inputContainer}>
|
style={[
|
||||||
<Ionicons name="scale-outline" size={20} color={theme.colors.gray400} />
|
typography.label,
|
||||||
|
{ color: colors.textSecondary, marginBottom: 8 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
WEIGHT (KG)
|
||||||
|
</Text>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.inputContainer,
|
||||||
|
{
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
borderColor: colors.border,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name="scale"
|
||||||
|
size={20}
|
||||||
|
color={colors.textTertiary}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={[styles.input, { color: colors.textPrimary }]}
|
||||||
value={profileData.weight?.toString() || ''}
|
value={profileData.weight?.toString() || ""}
|
||||||
onChangeText={(text) =>
|
onChangeText={(text) =>
|
||||||
updateField('weight', text ? parseFloat(text) : undefined)
|
updateField(
|
||||||
|
"weight",
|
||||||
|
text ? parseFloat(text) : undefined,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
keyboardType="decimal-pad"
|
keyboardType="decimal-pad"
|
||||||
placeholder="70"
|
placeholder="70"
|
||||||
placeholderTextColor={theme.colors.gray400}
|
placeholderTextColor={colors.textTertiary}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputGroup}>
|
<View style={styles.inputGroup}>
|
||||||
<Text style={styles.label}>Age</Text>
|
<Text
|
||||||
<View style={styles.inputContainer}>
|
style={[
|
||||||
<Ionicons name="calendar-outline" size={20} color={theme.colors.gray400} />
|
typography.label,
|
||||||
|
{ color: colors.textSecondary, marginBottom: 8 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
AGE
|
||||||
|
</Text>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.inputContainer,
|
||||||
|
{
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
borderColor: colors.border,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name="calendar"
|
||||||
|
size={20}
|
||||||
|
color={colors.textTertiary}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={[styles.input, { color: colors.textPrimary }]}
|
||||||
value={profileData.age?.toString() || ''}
|
value={profileData.age?.toString() || ""}
|
||||||
onChangeText={(text) =>
|
onChangeText={(text) =>
|
||||||
updateField('age', text ? parseInt(text, 10) : undefined)
|
updateField("age", text ? parseInt(text, 10) : undefined)
|
||||||
}
|
}
|
||||||
keyboardType="number-pad"
|
keyboardType="number-pad"
|
||||||
placeholder="25"
|
placeholder="25"
|
||||||
placeholderTextColor={theme.colors.gray400}
|
placeholderTextColor={colors.textTertiary}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</MinimalCard>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Gender Selection */}
|
{/* Gender Selection */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>Gender</Text>
|
<Text
|
||||||
<View style={styles.optionsRow}>
|
style={[
|
||||||
|
typography.h3,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Gender
|
||||||
|
</Text>
|
||||||
|
<View style={styles.genderRow}>
|
||||||
{GENDER_OPTIONS.map((option) => (
|
{GENDER_OPTIONS.map((option) => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={option.value}
|
key={option.value}
|
||||||
style={[
|
style={[
|
||||||
styles.optionCard,
|
styles.genderCard,
|
||||||
profileData.gender === option.value && styles.optionCardActive,
|
{
|
||||||
|
backgroundColor:
|
||||||
|
profileData.gender === option.value
|
||||||
|
? colors.primary
|
||||||
|
: colors.surfaceElevated,
|
||||||
|
borderColor:
|
||||||
|
profileData.gender === option.value
|
||||||
|
? colors.primary
|
||||||
|
: colors.border,
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
onPress={() => updateField('gender', option.value)}
|
onPress={() => updateField("gender", option.value)}
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name={option.icon as any}
|
name={option.icon as any}
|
||||||
size={24}
|
size={24}
|
||||||
color={
|
color={
|
||||||
profileData.gender === option.value
|
profileData.gender === option.value
|
||||||
? theme.colors.primary
|
? "#fff"
|
||||||
: theme.colors.gray400
|
: colors.textTertiary
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.optionLabel,
|
typography.caption,
|
||||||
profileData.gender === option.value && styles.optionLabelActive,
|
{
|
||||||
|
color:
|
||||||
|
profileData.gender === option.value
|
||||||
|
? "#fff"
|
||||||
|
: colors.textSecondary,
|
||||||
|
fontWeight:
|
||||||
|
profileData.gender === option.value ? "700" : "500",
|
||||||
|
marginTop: 6,
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{option.label}
|
{option.label}
|
||||||
@@ -267,117 +430,236 @@ export default function FitnessProfileScreen() {
|
|||||||
|
|
||||||
{/* Fitness Goal */}
|
{/* Fitness Goal */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>Primary Fitness Goal</Text>
|
<Text
|
||||||
<View style={styles.card}>
|
style={[
|
||||||
|
typography.h3,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Primary Fitness Goal
|
||||||
|
</Text>
|
||||||
|
<MinimalCard variant="elevated" style={styles.card}>
|
||||||
{FITNESS_GOAL_OPTIONS.map((option, index) => (
|
{FITNESS_GOAL_OPTIONS.map((option, index) => (
|
||||||
<React.Fragment key={option.value}>
|
<React.Fragment key={option.value}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.listItem}
|
style={styles.listItem}
|
||||||
onPress={() => updateField('fitnessGoal', option.value)}
|
onPress={() => updateField("fitnessGoal", option.value)}
|
||||||
>
|
>
|
||||||
<View style={[styles.iconCircle, { backgroundColor: `${option.color}20` }]}>
|
<View
|
||||||
<Ionicons name={option.icon as any} size={20} color={option.color} />
|
style={[
|
||||||
|
styles.iconCircle,
|
||||||
|
{ backgroundColor: `${option.color}20` },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name={option.icon as any}
|
||||||
|
size={20}
|
||||||
|
color={option.color}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.listItemText}>{option.label}</Text>
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.bodyEmphasis,
|
||||||
|
{ color: colors.textPrimary, flex: 1 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{option.label}
|
||||||
|
</Text>
|
||||||
{profileData.fitnessGoal === option.value && (
|
{profileData.fitnessGoal === option.value && (
|
||||||
<Ionicons name="checkmark-circle" size={24} color={theme.colors.primary} />
|
<Ionicons
|
||||||
|
name="checkmark-circle"
|
||||||
|
size={24}
|
||||||
|
color={colors.primary}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
{index < FITNESS_GOAL_OPTIONS.length - 1 && <View style={styles.divider} />}
|
{index < FITNESS_GOAL_OPTIONS.length - 1 && (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.divider,
|
||||||
|
{ backgroundColor: colors.border },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</View>
|
</MinimalCard>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Activity Level */}
|
{/* Activity Level */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>Activity Level</Text>
|
<Text
|
||||||
<View style={styles.card}>
|
style={[
|
||||||
|
typography.h3,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Activity Level
|
||||||
|
</Text>
|
||||||
|
<MinimalCard variant="elevated" style={styles.card}>
|
||||||
{ACTIVITY_LEVEL_OPTIONS.map((option, index) => (
|
{ACTIVITY_LEVEL_OPTIONS.map((option, index) => (
|
||||||
<React.Fragment key={option.value}>
|
<React.Fragment key={option.value}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.listItem}
|
style={styles.listItem}
|
||||||
onPress={() => updateField('activityLevel', option.value)}
|
onPress={() => updateField("activityLevel", option.value)}
|
||||||
>
|
>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<Text style={styles.listItemText}>{option.label}</Text>
|
<Text
|
||||||
<Text style={styles.listItemDescription}>{option.description}</Text>
|
style={[
|
||||||
|
typography.bodyEmphasis,
|
||||||
|
{ color: colors.textPrimary },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{option.label}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textTertiary, marginTop: 2 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{option.description}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{profileData.activityLevel === option.value && (
|
{profileData.activityLevel === option.value && (
|
||||||
<Ionicons name="checkmark-circle" size={24} color={theme.colors.primary} />
|
<Ionicons
|
||||||
|
name="checkmark-circle"
|
||||||
|
size={24}
|
||||||
|
color={colors.primary}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
{index < ACTIVITY_LEVEL_OPTIONS.length - 1 && <View style={styles.divider} />}
|
{index < ACTIVITY_LEVEL_OPTIONS.length - 1 && (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.divider,
|
||||||
|
{ backgroundColor: colors.border },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</View>
|
</MinimalCard>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Health Information */}
|
{/* Health Information */}
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>Health Information (Optional)</Text>
|
<Text
|
||||||
<View style={styles.card}>
|
style={[
|
||||||
|
typography.h3,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Health Information
|
||||||
|
</Text>
|
||||||
|
<MinimalCard variant="elevated" style={styles.card}>
|
||||||
<View style={styles.inputGroup}>
|
<View style={styles.inputGroup}>
|
||||||
<Text style={styles.label}>Medical Conditions</Text>
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.label,
|
||||||
|
{ color: colors.textSecondary, marginBottom: 8 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
MEDICAL CONDITIONS
|
||||||
|
</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[styles.textArea]}
|
style={[
|
||||||
value={profileData.medicalConditions || ''}
|
styles.textArea,
|
||||||
onChangeText={(text) => updateField('medicalConditions', text)}
|
{
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
borderColor: colors.border,
|
||||||
|
color: colors.textPrimary,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
value={profileData.medicalConditions || ""}
|
||||||
|
onChangeText={(text) =>
|
||||||
|
updateField("medicalConditions", text)
|
||||||
|
}
|
||||||
placeholder="e.g., Asthma, diabetes..."
|
placeholder="e.g., Asthma, diabetes..."
|
||||||
placeholderTextColor={theme.colors.gray400}
|
placeholderTextColor={colors.textTertiary}
|
||||||
multiline
|
multiline
|
||||||
numberOfLines={3}
|
numberOfLines={3}
|
||||||
textAlignVertical="top"
|
textAlignVertical="top"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputGroup}>
|
<View style={styles.inputGroup}>
|
||||||
<Text style={styles.label}>Allergies</Text>
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.label,
|
||||||
|
{ color: colors.textSecondary, marginBottom: 8 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
ALLERGIES
|
||||||
|
</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[styles.textArea]}
|
style={[
|
||||||
value={profileData.allergies || ''}
|
styles.textArea,
|
||||||
onChangeText={(text) => updateField('allergies', text)}
|
{
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
borderColor: colors.border,
|
||||||
|
color: colors.textPrimary,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
value={profileData.allergies || ""}
|
||||||
|
onChangeText={(text) => updateField("allergies", text)}
|
||||||
placeholder="e.g., Peanuts, latex..."
|
placeholder="e.g., Peanuts, latex..."
|
||||||
placeholderTextColor={theme.colors.gray400}
|
placeholderTextColor={colors.textTertiary}
|
||||||
multiline
|
multiline
|
||||||
numberOfLines={3}
|
numberOfLines={3}
|
||||||
textAlignVertical="top"
|
textAlignVertical="top"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputGroup}>
|
<View style={styles.inputGroup}>
|
||||||
<Text style={styles.label}>Injuries</Text>
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.label,
|
||||||
|
{ color: colors.textSecondary, marginBottom: 8 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
INJURIES
|
||||||
|
</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[styles.textArea]}
|
style={[
|
||||||
value={profileData.injuries || ''}
|
styles.textArea,
|
||||||
onChangeText={(text) => updateField('injuries', text)}
|
{
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
borderColor: colors.border,
|
||||||
|
color: colors.textPrimary,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
value={profileData.injuries || ""}
|
||||||
|
onChangeText={(text) => updateField("injuries", text)}
|
||||||
placeholder="e.g., Previous knee injury..."
|
placeholder="e.g., Previous knee injury..."
|
||||||
placeholderTextColor={theme.colors.gray400}
|
placeholderTextColor={colors.textTertiary}
|
||||||
multiline
|
multiline
|
||||||
numberOfLines={3}
|
numberOfLines={3}
|
||||||
textAlignVertical="top"
|
textAlignVertical="top"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</MinimalCard>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<View style={{ height: 120 }} />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
{/* Save Button */}
|
{/* Save Button */}
|
||||||
<View style={styles.footer}>
|
<View
|
||||||
<TouchableOpacity
|
style={[
|
||||||
style={[styles.saveButton, loading && styles.saveButtonDisabled]}
|
styles.footer,
|
||||||
|
{
|
||||||
|
backgroundColor: colors.background,
|
||||||
|
borderTopColor: colors.border,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<MinimalButton
|
||||||
|
title="Save Profile"
|
||||||
onPress={handleSave}
|
onPress={handleSave}
|
||||||
disabled={loading}
|
variant="primary"
|
||||||
>
|
size="xl"
|
||||||
<LinearGradient colors={theme.gradients.primary} style={styles.saveButtonGradient}>
|
fullWidth
|
||||||
{loading ? (
|
loading={loading}
|
||||||
<ActivityIndicator color="#fff" />
|
/>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Ionicons name="checkmark-circle" size={20} color="#fff" />
|
|
||||||
<Text style={styles.saveButtonText}>Save Profile</Text>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</LinearGradient>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
@@ -387,34 +669,26 @@ export default function FitnessProfileScreen() {
|
|||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: theme.colors.background,
|
|
||||||
},
|
},
|
||||||
loadingContainer: {
|
loadingContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
backgroundColor: theme.colors.background,
|
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
flexDirection: 'row',
|
flexDirection: "row",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'space-between',
|
justifyContent: "space-between",
|
||||||
paddingTop: Platform.OS === 'ios' ? 60 : 40,
|
|
||||||
paddingBottom: 20,
|
paddingBottom: 20,
|
||||||
paddingHorizontal: 20,
|
paddingHorizontal: 20,
|
||||||
},
|
},
|
||||||
backButton: {
|
backButton: {
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
borderRadius: 20,
|
borderRadius: 12,
|
||||||
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
backgroundColor: "rgba(255, 255, 255, 0.2)",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
},
|
|
||||||
headerTitle: {
|
|
||||||
fontSize: theme.typography.fontSize['2xl'],
|
|
||||||
fontWeight: theme.typography.fontWeight.bold,
|
|
||||||
color: '#fff',
|
|
||||||
},
|
},
|
||||||
scrollView: {
|
scrollView: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -424,148 +698,77 @@ const styles = StyleSheet.create({
|
|||||||
paddingBottom: 100,
|
paddingBottom: 100,
|
||||||
},
|
},
|
||||||
section: {
|
section: {
|
||||||
marginBottom: 24,
|
marginBottom: 28,
|
||||||
},
|
|
||||||
sectionTitle: {
|
|
||||||
fontSize: theme.typography.fontSize.lg,
|
|
||||||
fontWeight: theme.typography.fontWeight.bold,
|
|
||||||
color: theme.colors.gray900,
|
|
||||||
marginBottom: 12,
|
|
||||||
},
|
},
|
||||||
card: {
|
card: {
|
||||||
backgroundColor: '#fff',
|
padding: 4,
|
||||||
borderRadius: theme.borderRadius.xl,
|
|
||||||
padding: 16,
|
|
||||||
...theme.shadows.subtle,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: theme.colors.gray100,
|
|
||||||
},
|
},
|
||||||
row: {
|
inputRow: {
|
||||||
flexDirection: 'row',
|
flexDirection: "row",
|
||||||
gap: 12,
|
gap: 12,
|
||||||
marginBottom: 16,
|
|
||||||
},
|
},
|
||||||
inputGroup: {
|
inputGroup: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
marginBottom: 16,
|
marginBottom: 4,
|
||||||
},
|
|
||||||
label: {
|
|
||||||
fontSize: theme.typography.fontSize.sm,
|
|
||||||
fontWeight: theme.typography.fontWeight.semibold,
|
|
||||||
color: theme.colors.gray700,
|
|
||||||
marginBottom: 8,
|
|
||||||
},
|
},
|
||||||
inputContainer: {
|
inputContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: "row",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
backgroundColor: theme.colors.gray50,
|
borderRadius: 14,
|
||||||
borderRadius: theme.borderRadius.lg,
|
borderWidth: 1.5,
|
||||||
borderWidth: 1,
|
paddingHorizontal: 14,
|
||||||
borderColor: theme.colors.gray200,
|
gap: 10,
|
||||||
paddingHorizontal: 12,
|
|
||||||
gap: 8,
|
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingVertical: 12,
|
paddingVertical: 14,
|
||||||
fontSize: theme.typography.fontSize.base,
|
fontSize: 16,
|
||||||
color: theme.colors.gray900,
|
fontWeight: "600",
|
||||||
},
|
},
|
||||||
textArea: {
|
textArea: {
|
||||||
backgroundColor: theme.colors.gray50,
|
borderRadius: 14,
|
||||||
borderRadius: theme.borderRadius.lg,
|
borderWidth: 1.5,
|
||||||
borderWidth: 1,
|
padding: 14,
|
||||||
borderColor: theme.colors.gray200,
|
fontSize: 16,
|
||||||
padding: 12,
|
minHeight: 90,
|
||||||
fontSize: theme.typography.fontSize.base,
|
|
||||||
color: theme.colors.gray900,
|
|
||||||
minHeight: 80,
|
|
||||||
},
|
},
|
||||||
optionsRow: {
|
genderRow: {
|
||||||
flexDirection: 'row',
|
flexDirection: "row",
|
||||||
gap: 12,
|
gap: 10,
|
||||||
},
|
},
|
||||||
optionCard: {
|
genderCard: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: '#fff',
|
paddingVertical: 16,
|
||||||
borderRadius: theme.borderRadius.lg,
|
paddingHorizontal: 8,
|
||||||
padding: 16,
|
borderRadius: 14,
|
||||||
alignItems: 'center',
|
|
||||||
gap: 8,
|
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
borderColor: theme.colors.gray200,
|
alignItems: "center",
|
||||||
...theme.shadows.subtle,
|
|
||||||
},
|
|
||||||
optionCardActive: {
|
|
||||||
borderColor: theme.colors.primary,
|
|
||||||
backgroundColor: `${theme.colors.primary}10`,
|
|
||||||
},
|
|
||||||
optionLabel: {
|
|
||||||
fontSize: theme.typography.fontSize.sm,
|
|
||||||
fontWeight: theme.typography.fontWeight.medium,
|
|
||||||
color: theme.colors.gray600,
|
|
||||||
},
|
|
||||||
optionLabelActive: {
|
|
||||||
color: theme.colors.primary,
|
|
||||||
fontWeight: theme.typography.fontWeight.bold,
|
|
||||||
},
|
},
|
||||||
listItem: {
|
listItem: {
|
||||||
flexDirection: 'row',
|
flexDirection: "row",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
paddingVertical: 12,
|
paddingVertical: 14,
|
||||||
gap: 12,
|
paddingHorizontal: 12,
|
||||||
|
gap: 14,
|
||||||
},
|
},
|
||||||
iconCircle: {
|
iconCircle: {
|
||||||
width: 40,
|
width: 44,
|
||||||
height: 40,
|
height: 44,
|
||||||
borderRadius: 20,
|
borderRadius: 12,
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
},
|
|
||||||
listItemText: {
|
|
||||||
flex: 1,
|
|
||||||
fontSize: theme.typography.fontSize.base,
|
|
||||||
fontWeight: theme.typography.fontWeight.medium,
|
|
||||||
color: theme.colors.gray900,
|
|
||||||
},
|
|
||||||
listItemDescription: {
|
|
||||||
fontSize: theme.typography.fontSize.xs,
|
|
||||||
color: theme.colors.gray500,
|
|
||||||
marginTop: 2,
|
|
||||||
},
|
},
|
||||||
divider: {
|
divider: {
|
||||||
height: 1,
|
height: 1,
|
||||||
backgroundColor: theme.colors.gray100,
|
marginLeft: 58,
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
position: 'absolute',
|
position: "absolute",
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
padding: 20,
|
padding: 20,
|
||||||
paddingBottom: Platform.OS === 'ios' ? 40 : 20,
|
paddingBottom: 34,
|
||||||
backgroundColor: '#fff',
|
|
||||||
borderTopWidth: 1,
|
borderTopWidth: 1,
|
||||||
borderTopColor: theme.colors.gray100,
|
|
||||||
...theme.shadows.medium,
|
|
||||||
},
|
|
||||||
saveButton: {
|
|
||||||
borderRadius: theme.borderRadius.lg,
|
|
||||||
overflow: 'hidden',
|
|
||||||
},
|
|
||||||
saveButtonGradient: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
paddingVertical: 16,
|
|
||||||
gap: 8,
|
|
||||||
},
|
|
||||||
saveButtonDisabled: {
|
|
||||||
opacity: 0.6,
|
|
||||||
},
|
|
||||||
saveButtonText: {
|
|
||||||
fontSize: theme.typography.fontSize.base,
|
|
||||||
fontWeight: theme.typography.fontWeight.bold,
|
|
||||||
color: '#fff',
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
import React, { useEffect, useRef } from "react";
|
||||||
|
import { View, Animated, StyleSheet, Text } from "react-native";
|
||||||
|
import Svg, { Circle } from "react-native-svg";
|
||||||
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
|
|
||||||
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
||||||
|
|
||||||
|
interface ActivityRingProps {
|
||||||
|
size?: number;
|
||||||
|
strokeWidth?: number;
|
||||||
|
progress: number;
|
||||||
|
current: number;
|
||||||
|
goal: number;
|
||||||
|
label: string;
|
||||||
|
color: string;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ActivityRing({
|
||||||
|
size = 100,
|
||||||
|
strokeWidth = 10,
|
||||||
|
progress,
|
||||||
|
current,
|
||||||
|
goal,
|
||||||
|
label,
|
||||||
|
color,
|
||||||
|
icon,
|
||||||
|
}: ActivityRingProps) {
|
||||||
|
const { colors, typography } = useTheme();
|
||||||
|
const animatedValue = useRef(new Animated.Value(0)).current;
|
||||||
|
const radius = (size - strokeWidth) / 2;
|
||||||
|
const circumference = radius * 2 * Math.PI;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
Animated.timing(animatedValue, {
|
||||||
|
toValue: Math.min(progress, 100),
|
||||||
|
duration: 1200,
|
||||||
|
useNativeDriver: true,
|
||||||
|
}).start();
|
||||||
|
}, [progress]);
|
||||||
|
|
||||||
|
const strokeDashoffset = animatedValue.interpolate({
|
||||||
|
inputRange: [0, 100],
|
||||||
|
outputRange: [circumference, 0],
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>
|
||||||
|
<Circle
|
||||||
|
cx={size / 2}
|
||||||
|
cy={size / 2}
|
||||||
|
r={radius}
|
||||||
|
stroke={colors.surfaceElevated}
|
||||||
|
strokeWidth={strokeWidth}
|
||||||
|
fill="transparent"
|
||||||
|
/>
|
||||||
|
<AnimatedCircle
|
||||||
|
cx={size / 2}
|
||||||
|
cy={size / 2}
|
||||||
|
r={radius}
|
||||||
|
stroke={color}
|
||||||
|
strokeWidth={strokeWidth}
|
||||||
|
fill="transparent"
|
||||||
|
strokeDasharray={circumference}
|
||||||
|
strokeDashoffset={strokeDashoffset}
|
||||||
|
strokeLinecap="round"
|
||||||
|
rotation="-90"
|
||||||
|
origin={`${size / 2}, ${size / 2}`}
|
||||||
|
/>
|
||||||
|
</Svg>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
StyleSheet.absoluteFillObject,
|
||||||
|
{ justifyContent: "center", alignItems: "center" },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{icon ? (
|
||||||
|
<View style={styles.iconContainer}>{icon}</View>
|
||||||
|
) : (
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.textPrimary, fontSize: size * 0.28 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{Math.round(current)}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.label,
|
||||||
|
{ color: colors.textTertiary, marginTop: 8, textAlign: "center" },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textSecondary, marginTop: 2 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
/ {goal.toLocaleString()}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
iconContainer: {
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -10,49 +10,41 @@ type BadgeVariant =
|
|||||||
| "danger"
|
| "danger"
|
||||||
| "info"
|
| "info"
|
||||||
| "primary";
|
| "primary";
|
||||||
type BadgeSize = "sm" | "md";
|
type BadgeSize = "sm" | "md" | "lg";
|
||||||
|
|
||||||
interface BadgeProps {
|
interface BadgeProps {
|
||||||
label: string;
|
label: string;
|
||||||
variant?: BadgeVariant;
|
variant?: BadgeVariant;
|
||||||
size?: BadgeSize;
|
size?: BadgeSize;
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
|
emoji?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Badge - Pill-shaped status indicator
|
|
||||||
*
|
|
||||||
* Variants:
|
|
||||||
* - neutral: Gray badge for general labels
|
|
||||||
* - success: Green badge for positive status
|
|
||||||
* - warning: Orange/yellow badge for warnings
|
|
||||||
* - danger: Red badge for errors or critical status
|
|
||||||
* - info: Blue badge for informational status
|
|
||||||
* - primary: Primary color badge
|
|
||||||
*
|
|
||||||
* Sizes:
|
|
||||||
* - sm: 5px vertical, 10px horizontal, 11px font
|
|
||||||
* - md: 6px vertical, 12px horizontal, 13px font (default)
|
|
||||||
*/
|
|
||||||
export function Badge({
|
export function Badge({
|
||||||
label,
|
label,
|
||||||
variant = "neutral",
|
variant = "neutral",
|
||||||
size = "md",
|
size = "md",
|
||||||
style,
|
style,
|
||||||
|
emoji,
|
||||||
}: BadgeProps) {
|
}: BadgeProps) {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
const sizeStyles = {
|
const sizeStyles = {
|
||||||
sm: {
|
sm: {
|
||||||
paddingVertical: 5,
|
paddingVertical: 6,
|
||||||
paddingHorizontal: 10,
|
paddingHorizontal: 12,
|
||||||
fontSize: fontSize.xs,
|
fontSize: fontSize.xs,
|
||||||
},
|
},
|
||||||
md: {
|
md: {
|
||||||
paddingVertical: 6,
|
paddingVertical: 8,
|
||||||
paddingHorizontal: 12,
|
paddingHorizontal: 14,
|
||||||
fontSize: fontSize.sm,
|
fontSize: fontSize.sm,
|
||||||
},
|
},
|
||||||
|
lg: {
|
||||||
|
paddingVertical: 10,
|
||||||
|
paddingHorizontal: 18,
|
||||||
|
fontSize: fontSize.base,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const variantStyles: Record<
|
const variantStyles: Record<
|
||||||
@@ -64,24 +56,24 @@ export function Badge({
|
|||||||
color: colors.textSecondary,
|
color: colors.textSecondary,
|
||||||
},
|
},
|
||||||
success: {
|
success: {
|
||||||
backgroundColor: `${colors.success}20`, // 20% opacity
|
backgroundColor: colors.success,
|
||||||
color: colors.success,
|
color: colors.white,
|
||||||
},
|
},
|
||||||
warning: {
|
warning: {
|
||||||
backgroundColor: `${colors.warning}20`,
|
backgroundColor: colors.warning,
|
||||||
color: colors.warning,
|
color: colors.black,
|
||||||
},
|
},
|
||||||
danger: {
|
danger: {
|
||||||
backgroundColor: `${colors.danger}20`,
|
backgroundColor: colors.danger,
|
||||||
color: colors.danger,
|
color: colors.white,
|
||||||
},
|
},
|
||||||
info: {
|
info: {
|
||||||
backgroundColor: `${colors.info}20`,
|
backgroundColor: colors.info,
|
||||||
color: colors.info,
|
color: colors.white,
|
||||||
},
|
},
|
||||||
primary: {
|
primary: {
|
||||||
backgroundColor: `${colors.primary}20`,
|
backgroundColor: colors.primary,
|
||||||
color: colors.primary,
|
color: colors.white,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,10 +95,11 @@ export function Badge({
|
|||||||
{
|
{
|
||||||
color: variantStyles[variant].color,
|
color: variantStyles[variant].color,
|
||||||
fontSize: sizeStyles[size].fontSize,
|
fontSize: sizeStyles[size].fontSize,
|
||||||
fontWeight: fontWeight.medium,
|
fontWeight: fontWeight.bold,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
{emoji && `${emoji} `}
|
||||||
{label}
|
{label}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
@@ -115,7 +108,7 @@ export function Badge({
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
badge: {
|
badge: {
|
||||||
borderRadius: 999, // Full pill shape
|
borderRadius: 12,
|
||||||
alignSelf: "flex-start",
|
alignSelf: "flex-start",
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { View, StyleSheet, TouchableOpacity } from "react-native";
|
import { View, StyleSheet, TouchableOpacity, Text } from "react-native";
|
||||||
import { BottomTabBarProps } from "@react-navigation/bottom-tabs";
|
import { BottomTabBarProps } from "@react-navigation/bottom-tabs";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
import { useTheme } from "../contexts/ThemeContext";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
|
|
||||||
/**
|
|
||||||
* CustomTabBar - Minimal bottom navigation with pill indicator
|
|
||||||
*
|
|
||||||
* Design:
|
|
||||||
* - Simple flat design (no floating, no glassmorphism)
|
|
||||||
* - Clean icons with outline/filled states
|
|
||||||
* - Small pill indicator below active tab
|
|
||||||
* - 56px height (reduced from 70px)
|
|
||||||
* - No animations (just opacity fade on press)
|
|
||||||
* - Theme-aware colors
|
|
||||||
*/
|
|
||||||
export function CustomTabBar({
|
export function CustomTabBar({
|
||||||
state,
|
state,
|
||||||
descriptors,
|
descriptors,
|
||||||
@@ -71,6 +60,23 @@ export function CustomTabBar({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getLabel = (routeName: string) => {
|
||||||
|
switch (routeName) {
|
||||||
|
case "index":
|
||||||
|
return "Home";
|
||||||
|
case "goals":
|
||||||
|
return "Goals";
|
||||||
|
case "attendance":
|
||||||
|
return "Attendance";
|
||||||
|
case "recommendations":
|
||||||
|
return "Plans";
|
||||||
|
case "profile":
|
||||||
|
return "Profile";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={index}
|
key={index}
|
||||||
@@ -85,7 +91,7 @@ export function CustomTabBar({
|
|||||||
<View style={styles.iconWrapper}>
|
<View style={styles.iconWrapper}>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name={getIconName(route.name, isFocused)}
|
name={getIconName(route.name, isFocused)}
|
||||||
size={24}
|
size={26}
|
||||||
color={isFocused ? colors.primary : colors.textTertiary}
|
color={isFocused ? colors.primary : colors.textTertiary}
|
||||||
/>
|
/>
|
||||||
{isFocused && (
|
{isFocused && (
|
||||||
@@ -97,6 +103,17 @@ export function CustomTabBar({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.label,
|
||||||
|
{
|
||||||
|
color: isFocused ? colors.primary : colors.textTertiary,
|
||||||
|
fontWeight: isFocused ? "700" : "500",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{getLabel(route.name)}
|
||||||
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -107,8 +124,9 @@ export function CustomTabBar({
|
|||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
height: 56,
|
height: 70,
|
||||||
borderTopWidth: 1,
|
borderTopWidth: 1,
|
||||||
|
paddingTop: 8,
|
||||||
},
|
},
|
||||||
tabItem: {
|
tabItem: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -121,9 +139,13 @@ const styles = StyleSheet.create({
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
},
|
},
|
||||||
indicator: {
|
indicator: {
|
||||||
width: 24,
|
width: 20,
|
||||||
height: 3,
|
height: 4,
|
||||||
borderRadius: 999,
|
borderRadius: 2,
|
||||||
|
marginTop: 4,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
fontSize: 11,
|
||||||
marginTop: 4,
|
marginTop: 4,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -122,15 +122,17 @@ export function GoalProgressCard({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View style={{ transform: [{ scale: scaleAnim }] }}>
|
<Animated.View style={{ transform: [{ scale: scaleAnim }] }}>
|
||||||
<TouchableOpacity onPress={onPress} activeOpacity={0.7}>
|
<TouchableOpacity onPress={onPress} activeOpacity={0.85}>
|
||||||
<MinimalCard
|
<MinimalCard
|
||||||
variant="bordered"
|
variant="elevated"
|
||||||
style={[
|
style={[
|
||||||
styles.card,
|
styles.card,
|
||||||
isCompleted && {
|
isCompleted && {
|
||||||
backgroundColor: colors.overlayLight,
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
opacity: 0.8,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
padding={20}
|
||||||
>
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
@@ -289,13 +291,14 @@ export function GoalProgressCard({
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
card: {
|
card: {
|
||||||
marginBottom: 12,
|
marginBottom: 16,
|
||||||
|
borderRadius: 20,
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "flex-start",
|
alignItems: "flex-start",
|
||||||
marginBottom: 12,
|
marginBottom: 16,
|
||||||
},
|
},
|
||||||
titleRow: {
|
titleRow: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
@@ -304,23 +307,23 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
titleContainer: {
|
titleContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
marginLeft: 12,
|
marginLeft: 14,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
gap: 8,
|
gap: 12,
|
||||||
},
|
},
|
||||||
actionButton: {
|
actionButton: {
|
||||||
padding: 4,
|
padding: 6,
|
||||||
},
|
},
|
||||||
progressSection: {
|
progressSection: {
|
||||||
marginBottom: 12,
|
marginBottom: 16,
|
||||||
},
|
},
|
||||||
progressInfo: {
|
progressInfo: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: 8,
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { View, Text, StyleSheet, Dimensions } from "react-native";
|
import { View, Text, StyleSheet, Dimensions } from "react-native";
|
||||||
import { PieChart } from "react-native-chart-kit";
|
import { PieChart } from "react-native-chart-kit";
|
||||||
import { theme } from "../styles/theme";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
|
|
||||||
interface GoalTypeData {
|
interface GoalTypeData {
|
||||||
goalType: string;
|
goalType: string;
|
||||||
@@ -17,37 +17,40 @@ export function GoalTypeBreakdownChart({
|
|||||||
data,
|
data,
|
||||||
title = "Goals by Type",
|
title = "Goals by Type",
|
||||||
}: GoalTypeBreakdownChartProps) {
|
}: GoalTypeBreakdownChartProps) {
|
||||||
|
const { colors, typography } = useTheme();
|
||||||
const screenWidth = Dimensions.get("window").width;
|
const screenWidth = Dimensions.get("window").width;
|
||||||
|
|
||||||
// Color palette for different goal types
|
const chartColors = [
|
||||||
const colors = [
|
colors.primary,
|
||||||
"#3b82f6", // Blue
|
colors.success,
|
||||||
"#10b981", // Green
|
colors.warning,
|
||||||
"#f59e0b", // Orange
|
colors.accent,
|
||||||
"#8b5cf6", // Purple
|
colors.secondary,
|
||||||
"#ec4899", // Pink
|
colors.info,
|
||||||
"#06b6d4", // Cyan
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Prepare chart data
|
|
||||||
const chartData = data.map((item, index) => ({
|
const chartData = data.map((item, index) => ({
|
||||||
name: item.goalType,
|
name: item.goalType
|
||||||
|
.replace(/_/g, " ")
|
||||||
|
.replace(/\b\w/g, (l) => l.toUpperCase()),
|
||||||
count: item.count,
|
count: item.count,
|
||||||
color: colors[index % colors.length],
|
color: chartColors[index % chartColors.length],
|
||||||
legendFontColor: theme.colors.gray600,
|
legendFontColor: colors.textSecondary,
|
||||||
legendFontSize: 12,
|
legendFontSize: 12,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const chartConfig = {
|
const totalGoals = data.reduce((sum, item) => sum + item.count, 0);
|
||||||
color: (opacity = 1) => `rgba(59, 130, 246, ${opacity})`,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.title}>{title}</Text>
|
<Text style={[typography.h4, { color: colors.textPrimary }]}>
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
<View style={styles.emptyState}>
|
<View style={styles.emptyState}>
|
||||||
<Text style={styles.emptyText}>No goals yet</Text>
|
<Text style={[typography.body, { color: colors.textTertiary }]}>
|
||||||
|
No goals yet
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -55,46 +58,123 @@ export function GoalTypeBreakdownChart({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.title}>{title}</Text>
|
<Text
|
||||||
|
style={[typography.h4, { color: colors.textPrimary, marginBottom: 16 }]}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{/* Summary Stats */}
|
||||||
|
<View style={styles.summaryRow}>
|
||||||
|
<View style={styles.summaryItem}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.primary, fontSize: 32 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{totalGoals}
|
||||||
|
</Text>
|
||||||
|
<Text style={[typography.caption, { color: colors.textTertiary }]}>
|
||||||
|
Total Goals
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.summaryItem}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.statLarge,
|
||||||
|
{ color: colors.success, fontSize: 32 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{data.length}
|
||||||
|
</Text>
|
||||||
|
<Text style={[typography.caption, { color: colors.textTertiary }]}>
|
||||||
|
Types
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View style={styles.chartContainer}>
|
<View style={styles.chartContainer}>
|
||||||
<PieChart
|
<PieChart
|
||||||
data={chartData}
|
data={chartData}
|
||||||
width={screenWidth - 60}
|
width={screenWidth - 80}
|
||||||
height={200}
|
height={160}
|
||||||
chartConfig={chartConfig}
|
chartConfig={{
|
||||||
|
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
|
||||||
|
}}
|
||||||
accessor="count"
|
accessor="count"
|
||||||
backgroundColor="transparent"
|
backgroundColor="transparent"
|
||||||
paddingLeft="15"
|
paddingLeft="15"
|
||||||
absolute
|
absolute
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{/* Legend */}
|
||||||
|
<View style={styles.legendGrid}>
|
||||||
|
{data.map((item, index) => (
|
||||||
|
<View key={item.goalType} style={styles.legendItem}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.legendDot,
|
||||||
|
{ backgroundColor: chartColors[index % chartColors.length] },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.caption,
|
||||||
|
{ color: colors.textSecondary, flex: 1 },
|
||||||
|
]}
|
||||||
|
numberOfLines={1}
|
||||||
|
>
|
||||||
|
{item.goalType
|
||||||
|
.replace(/_/g, " ")
|
||||||
|
.replace(/\b\w/g, (l) => l.toUpperCase())}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[typography.bodyEmphasis, { color: colors.textPrimary }]}
|
||||||
|
>
|
||||||
|
{item.count}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
backgroundColor: theme.colors.white,
|
borderRadius: 16,
|
||||||
borderRadius: theme.borderRadius.xl,
|
padding: 4,
|
||||||
padding: 16,
|
|
||||||
marginBottom: 16,
|
|
||||||
...theme.shadows.medium,
|
|
||||||
},
|
},
|
||||||
title: {
|
summaryRow: {
|
||||||
fontSize: theme.typography.fontSize.lg,
|
flexDirection: "row",
|
||||||
fontWeight: theme.typography.fontWeight.bold,
|
justifyContent: "space-around",
|
||||||
color: theme.colors.gray700,
|
marginBottom: 16,
|
||||||
marginBottom: 12,
|
paddingVertical: 12,
|
||||||
|
},
|
||||||
|
summaryItem: {
|
||||||
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
chartContainer: {
|
chartContainer: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
marginBottom: 16,
|
||||||
|
},
|
||||||
|
legendGrid: {
|
||||||
|
gap: 10,
|
||||||
|
},
|
||||||
|
legendItem: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 10,
|
||||||
|
},
|
||||||
|
legendDot: {
|
||||||
|
width: 12,
|
||||||
|
height: 12,
|
||||||
|
borderRadius: 6,
|
||||||
},
|
},
|
||||||
emptyState: {
|
emptyState: {
|
||||||
paddingVertical: 40,
|
paddingVertical: 32,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
emptyText: {
|
|
||||||
fontSize: theme.typography.fontSize.sm,
|
|
||||||
color: theme.colors.gray400,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
@@ -3,7 +3,7 @@ import { View, StyleSheet, ViewStyle, StyleProp } from "react-native";
|
|||||||
import { useTheme } from "../contexts/ThemeContext";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
|
|
||||||
type IconContainerVariant = "plain" | "subtle" | "colored";
|
type IconContainerVariant = "plain" | "subtle" | "colored";
|
||||||
type IconContainerSize = "sm" | "md" | "lg";
|
type IconContainerSize = "sm" | "md" | "lg" | "xl";
|
||||||
|
|
||||||
interface IconContainerProps {
|
interface IconContainerProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -13,19 +13,6 @@ interface IconContainerProps {
|
|||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* IconContainer - Clean container for icons with subtle backgrounds
|
|
||||||
*
|
|
||||||
* Variants:
|
|
||||||
* - plain: No background, just the icon
|
|
||||||
* - subtle: Light background (surfaceSecondary)
|
|
||||||
* - colored: Custom background color (pass backgroundColor prop)
|
|
||||||
*
|
|
||||||
* Sizes:
|
|
||||||
* - sm: 32px circle
|
|
||||||
* - md: 40px circle (default)
|
|
||||||
* - lg: 48px circle
|
|
||||||
*/
|
|
||||||
export function IconContainer({
|
export function IconContainer({
|
||||||
children,
|
children,
|
||||||
variant = "subtle",
|
variant = "subtle",
|
||||||
@@ -37,19 +24,24 @@ export function IconContainer({
|
|||||||
|
|
||||||
const sizeStyles: Record<IconContainerSize, ViewStyle> = {
|
const sizeStyles: Record<IconContainerSize, ViewStyle> = {
|
||||||
sm: {
|
sm: {
|
||||||
width: 32,
|
width: 36,
|
||||||
height: 32,
|
height: 36,
|
||||||
borderRadius: 16,
|
borderRadius: 10,
|
||||||
},
|
},
|
||||||
md: {
|
md: {
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
borderRadius: 20,
|
|
||||||
},
|
|
||||||
lg: {
|
|
||||||
width: 48,
|
width: 48,
|
||||||
height: 48,
|
height: 48,
|
||||||
borderRadius: 24,
|
borderRadius: 14,
|
||||||
|
},
|
||||||
|
lg: {
|
||||||
|
width: 56,
|
||||||
|
height: 56,
|
||||||
|
borderRadius: 16,
|
||||||
|
},
|
||||||
|
xl: {
|
||||||
|
width: 64,
|
||||||
|
height: 64,
|
||||||
|
borderRadius: 18,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,13 @@ import {
|
|||||||
import { useTheme } from "../contexts/ThemeContext";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
import { fontSize, fontWeight } from "../styles/typography";
|
import { fontSize, fontWeight } from "../styles/typography";
|
||||||
|
|
||||||
type ButtonVariant = "primary" | "secondary" | "tertiary" | "danger";
|
type ButtonVariant =
|
||||||
type ButtonSize = "sm" | "md" | "lg";
|
| "primary"
|
||||||
|
| "secondary"
|
||||||
|
| "tertiary"
|
||||||
|
| "danger"
|
||||||
|
| "success";
|
||||||
|
type ButtonSize = "sm" | "md" | "lg" | "xl";
|
||||||
|
|
||||||
interface MinimalButtonProps {
|
interface MinimalButtonProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -23,22 +28,9 @@ interface MinimalButtonProps {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
textStyle?: StyleProp<TextStyle>;
|
textStyle?: StyleProp<TextStyle>;
|
||||||
|
fullWidth?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* MinimalButton - Clean button component with solid colors
|
|
||||||
*
|
|
||||||
* Variants:
|
|
||||||
* - primary: Solid primary background
|
|
||||||
* - secondary: Outlined with primary color
|
|
||||||
* - tertiary: Text only, no background
|
|
||||||
* - danger: Solid danger background
|
|
||||||
*
|
|
||||||
* Sizes:
|
|
||||||
* - sm: 12px vertical padding, 16px horizontal
|
|
||||||
* - md: 14px vertical padding, 24px horizontal (default)
|
|
||||||
* - lg: 16px vertical padding, 32px horizontal
|
|
||||||
*/
|
|
||||||
export function MinimalButton({
|
export function MinimalButton({
|
||||||
title,
|
title,
|
||||||
onPress,
|
onPress,
|
||||||
@@ -48,37 +40,42 @@ export function MinimalButton({
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
style,
|
style,
|
||||||
textStyle,
|
textStyle,
|
||||||
|
fullWidth = false,
|
||||||
}: MinimalButtonProps) {
|
}: MinimalButtonProps) {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
const isDisabled = disabled || loading;
|
const isDisabled = disabled || loading;
|
||||||
|
|
||||||
// Get button styles based on variant
|
|
||||||
const getButtonStyle = (): ViewStyle => {
|
const getButtonStyle = (): ViewStyle => {
|
||||||
const baseStyle: ViewStyle = {
|
const baseStyle: ViewStyle = {
|
||||||
borderRadius: 10,
|
borderRadius: 14,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
opacity: isDisabled ? 0.5 : 1,
|
opacity: isDisabled ? 0.5 : 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Size-specific padding
|
|
||||||
const sizeStyles: Record<
|
const sizeStyles: Record<
|
||||||
ButtonSize,
|
ButtonSize,
|
||||||
{ paddingVertical: number; paddingHorizontal: number }
|
{ paddingVertical: number; paddingHorizontal: number }
|
||||||
> = {
|
> = {
|
||||||
sm: { paddingVertical: 12, paddingHorizontal: 16 },
|
sm: { paddingVertical: 12, paddingHorizontal: 20 },
|
||||||
md: { paddingVertical: 14, paddingHorizontal: 24 },
|
md: { paddingVertical: 16, paddingHorizontal: 28 },
|
||||||
lg: { paddingVertical: 16, paddingHorizontal: 32 },
|
lg: { paddingVertical: 18, paddingHorizontal: 36 },
|
||||||
|
xl: { paddingVertical: 20, paddingHorizontal: 44 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const variantStyles: Record<ButtonVariant, ViewStyle> = {
|
const variantStyles: Record<ButtonVariant, ViewStyle> = {
|
||||||
primary: {
|
primary: {
|
||||||
backgroundColor: colors.primary,
|
backgroundColor: colors.primary,
|
||||||
|
shadowColor: colors.primary,
|
||||||
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
shadowOpacity: 0.3,
|
||||||
|
shadowRadius: 8,
|
||||||
|
elevation: 4,
|
||||||
},
|
},
|
||||||
secondary: {
|
secondary: {
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
borderWidth: 1.5,
|
borderWidth: 2,
|
||||||
borderColor: colors.primary,
|
borderColor: colors.primary,
|
||||||
},
|
},
|
||||||
tertiary: {
|
tertiary: {
|
||||||
@@ -86,6 +83,19 @@ export function MinimalButton({
|
|||||||
},
|
},
|
||||||
danger: {
|
danger: {
|
||||||
backgroundColor: colors.danger,
|
backgroundColor: colors.danger,
|
||||||
|
shadowColor: colors.danger,
|
||||||
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
shadowOpacity: 0.3,
|
||||||
|
shadowRadius: 8,
|
||||||
|
elevation: 4,
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
backgroundColor: colors.success,
|
||||||
|
shadowColor: colors.success,
|
||||||
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
shadowOpacity: 0.3,
|
||||||
|
shadowRadius: 8,
|
||||||
|
elevation: 4,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,29 +103,23 @@ export function MinimalButton({
|
|||||||
...baseStyle,
|
...baseStyle,
|
||||||
...sizeStyles[size],
|
...sizeStyles[size],
|
||||||
...variantStyles[variant],
|
...variantStyles[variant],
|
||||||
|
...(fullWidth && { width: "100%" }),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get text styles based on variant
|
|
||||||
const getTextStyle = (): TextStyle => {
|
const getTextStyle = (): TextStyle => {
|
||||||
const baseTextStyle: TextStyle = {
|
const baseTextStyle: TextStyle = {
|
||||||
fontSize: fontSize.base,
|
fontSize: size === "sm" ? fontSize.sm : fontSize.md,
|
||||||
fontWeight: fontWeight.semibold,
|
fontWeight: fontWeight.bold,
|
||||||
|
letterSpacing: 0.5,
|
||||||
};
|
};
|
||||||
|
|
||||||
const variantTextStyles: Record<ButtonVariant, TextStyle> = {
|
const variantTextStyles: Record<ButtonVariant, TextStyle> = {
|
||||||
primary: {
|
primary: { color: colors.white },
|
||||||
color: colors.white,
|
secondary: { color: colors.primary },
|
||||||
},
|
tertiary: { color: colors.primary },
|
||||||
secondary: {
|
danger: { color: colors.white },
|
||||||
color: colors.primary,
|
success: { color: colors.white },
|
||||||
},
|
|
||||||
tertiary: {
|
|
||||||
color: colors.primary,
|
|
||||||
},
|
|
||||||
danger: {
|
|
||||||
color: colors.white,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -129,7 +133,7 @@ export function MinimalButton({
|
|||||||
style={[getButtonStyle(), style]}
|
style={[getButtonStyle(), style]}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.85}
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<ActivityIndicator
|
<ActivityIndicator
|
||||||
@@ -146,7 +150,3 @@ export function MinimalButton({
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
// No static styles needed - all dynamic based on theme
|
|
||||||
});
|
|
||||||
@@ -8,28 +8,22 @@ import {
|
|||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { useTheme } from "../contexts/ThemeContext";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
|
|
||||||
type CardVariant = "default" | "elevated" | "bordered";
|
type CardVariant = "default" | "elevated" | "bordered" | "gradient";
|
||||||
|
|
||||||
interface MinimalCardProps {
|
interface MinimalCardProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
variant?: CardVariant;
|
variant?: CardVariant;
|
||||||
onPress?: () => void;
|
onPress?: () => void;
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
|
padding?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* MinimalCard - Clean card component without gradients
|
|
||||||
*
|
|
||||||
* Variants:
|
|
||||||
* - default: Subtle shadow on surface background
|
|
||||||
* - elevated: More prominent shadow
|
|
||||||
* - bordered: Border instead of shadow
|
|
||||||
*/
|
|
||||||
export function MinimalCard({
|
export function MinimalCard({
|
||||||
children,
|
children,
|
||||||
variant = "default",
|
variant = "default",
|
||||||
onPress,
|
onPress,
|
||||||
style,
|
style,
|
||||||
|
padding = 20,
|
||||||
}: MinimalCardProps) {
|
}: MinimalCardProps) {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
@@ -37,13 +31,20 @@ export function MinimalCard({
|
|||||||
styles.base,
|
styles.base,
|
||||||
{
|
{
|
||||||
backgroundColor: colors.surface,
|
backgroundColor: colors.surface,
|
||||||
|
padding: padding,
|
||||||
},
|
},
|
||||||
variant === "default" && styles.default,
|
variant === "default" && styles.default,
|
||||||
variant === "elevated" && styles.elevated,
|
variant === "elevated" && {
|
||||||
|
...styles.elevated,
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
},
|
||||||
variant === "bordered" && {
|
variant === "bordered" && {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: colors.border,
|
borderColor: colors.border,
|
||||||
},
|
},
|
||||||
|
variant === "gradient" && {
|
||||||
|
backgroundColor: colors.surfaceElevated,
|
||||||
|
},
|
||||||
style,
|
style,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ export function MinimalCard({
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={cardStyles}
|
style={cardStyles}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.85}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -64,21 +65,20 @@ export function MinimalCard({
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
base: {
|
base: {
|
||||||
borderRadius: 12,
|
borderRadius: 20,
|
||||||
padding: 16,
|
|
||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
shadowColor: "#000",
|
|
||||||
shadowOffset: { width: 0, height: 1 },
|
|
||||||
shadowOpacity: 0.05,
|
|
||||||
shadowRadius: 3,
|
|
||||||
elevation: 1,
|
|
||||||
},
|
|
||||||
elevated: {
|
|
||||||
shadowColor: "#000",
|
shadowColor: "#000",
|
||||||
shadowOffset: { width: 0, height: 2 },
|
shadowOffset: { width: 0, height: 2 },
|
||||||
shadowOpacity: 0.08,
|
shadowOpacity: 0.08,
|
||||||
shadowRadius: 8,
|
shadowRadius: 8,
|
||||||
elevation: 2,
|
elevation: 3,
|
||||||
|
},
|
||||||
|
elevated: {
|
||||||
|
shadowColor: "#000",
|
||||||
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
shadowOpacity: 0.12,
|
||||||
|
shadowRadius: 16,
|
||||||
|
elevation: 6,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -3,43 +3,28 @@ import { View, StyleSheet, ViewStyle, StyleProp } from "react-native";
|
|||||||
import { useTheme } from "../contexts/ThemeContext";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
|
|
||||||
interface ProgressBarProps {
|
interface ProgressBarProps {
|
||||||
progress: number; // 0-1 (e.g., 0.75 for 75%)
|
progress: number;
|
||||||
color?: string;
|
color?: string;
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
height?: number;
|
height?: number;
|
||||||
borderRadius?: number;
|
borderRadius?: number;
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
|
animated?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ProgressBar - Simple linear progress indicator
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* - Goal progress tracking
|
|
||||||
* - Loading states
|
|
||||||
* - Completion indicators
|
|
||||||
*
|
|
||||||
* Props:
|
|
||||||
* - progress: Value between 0 and 1 (e.g., 0.75 for 75%)
|
|
||||||
* - color: Custom fill color (defaults to theme primary)
|
|
||||||
* - backgroundColor: Custom track color (defaults to theme border)
|
|
||||||
* - height: Bar height in pixels (defaults to 8)
|
|
||||||
* - borderRadius: Corner radius (defaults to 999 for full pill shape)
|
|
||||||
*/
|
|
||||||
export function ProgressBar({
|
export function ProgressBar({
|
||||||
progress,
|
progress,
|
||||||
color,
|
color,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
height = 8,
|
height = 10,
|
||||||
borderRadius = 999,
|
borderRadius = 999,
|
||||||
style,
|
style,
|
||||||
}: ProgressBarProps) {
|
}: ProgressBarProps) {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
// Clamp progress between 0 and 1
|
|
||||||
const clampedProgress = Math.min(Math.max(progress, 0), 1);
|
const clampedProgress = Math.min(Math.max(progress, 0), 1);
|
||||||
|
|
||||||
const trackColor = backgroundColor || colors.border;
|
const trackColor = backgroundColor || colors.surfaceElevated;
|
||||||
const fillColor = color || colors.primary;
|
const fillColor = color || colors.primary;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -17,14 +17,6 @@ interface SectionHeaderProps {
|
|||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SectionHeader - Clean section header with optional action button
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* - Divides content into logical sections
|
|
||||||
* - Optional subtitle for additional context
|
|
||||||
* - Optional action button (e.g., "See All", "Add New")
|
|
||||||
*/
|
|
||||||
export function SectionHeader({
|
export function SectionHeader({
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
@@ -44,7 +36,7 @@ export function SectionHeader({
|
|||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
typography.caption,
|
typography.caption,
|
||||||
{ color: colors.textTertiary, marginTop: 2 },
|
{ color: colors.textTertiary, marginTop: 4 },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{subtitle}
|
{subtitle}
|
||||||
@@ -53,12 +45,7 @@ export function SectionHeader({
|
|||||||
</View>
|
</View>
|
||||||
{actionLabel && onActionPress && (
|
{actionLabel && onActionPress && (
|
||||||
<TouchableOpacity onPress={onActionPress} activeOpacity={0.7}>
|
<TouchableOpacity onPress={onActionPress} activeOpacity={0.7}>
|
||||||
<Text
|
<Text style={[typography.bodyEmphasis, { color: colors.primary }]}>
|
||||||
style={[
|
|
||||||
typography.body,
|
|
||||||
{ color: colors.primary, fontWeight: "600" },
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
{actionLabel}
|
{actionLabel}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -72,7 +59,7 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: 12,
|
marginBottom: 16,
|
||||||
},
|
},
|
||||||
textContainer: {
|
textContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { View, Text, StyleSheet, Dimensions } from "react-native";
|
import { View, Text, StyleSheet, Dimensions } from "react-native";
|
||||||
import { LineChart } from "react-native-chart-kit";
|
import { LineChart } from "react-native-chart-kit";
|
||||||
import { theme } from "../styles/theme";
|
import { useTheme } from "../contexts/ThemeContext";
|
||||||
import type { WeeklyTrendData } from "../api/types";
|
import type { WeeklyTrendData } from "../api/types";
|
||||||
|
|
||||||
interface WeeklyProgressChartProps {
|
interface WeeklyProgressChartProps {
|
||||||
@@ -13,28 +13,26 @@ export function WeeklyProgressChart({
|
|||||||
weeklyData,
|
weeklyData,
|
||||||
title = "Weekly Progress",
|
title = "Weekly Progress",
|
||||||
}: WeeklyProgressChartProps) {
|
}: WeeklyProgressChartProps) {
|
||||||
|
const { colors, typography } = useTheme();
|
||||||
const screenWidth = Dimensions.get("window").width;
|
const screenWidth = Dimensions.get("window").width;
|
||||||
|
|
||||||
// Prepare chart data
|
const labels = weeklyData.map((week: WeeklyTrendData) => week.weekLabel);
|
||||||
const labels = weeklyData.map((week) => week.weekLabel);
|
const checkInsData = weeklyData.map((week: WeeklyTrendData) => week.checkIns);
|
||||||
const checkInsData = weeklyData.map((week) => week.checkIns);
|
const goalsCompletedData = weeklyData.map(
|
||||||
const goalsCompletedData = weeklyData.map((week) => week.goalsCompleted);
|
(week: WeeklyTrendData) => week.goalsCompleted,
|
||||||
const avgProgressData = weeklyData.map((week) => week.averageProgress);
|
);
|
||||||
|
|
||||||
const chartConfig = {
|
const chartConfig = {
|
||||||
backgroundColor: theme.colors.white,
|
backgroundColor: colors.surface,
|
||||||
backgroundGradientFrom: theme.colors.white,
|
backgroundGradientFrom: colors.surface,
|
||||||
backgroundGradientTo: theme.colors.white,
|
backgroundGradientTo: colors.surface,
|
||||||
decimalPlaces: 0,
|
decimalPlaces: 0,
|
||||||
color: (opacity = 1) => `rgba(59, 130, 246, ${opacity})`,
|
color: (opacity = 1) => `rgba(0, 102, 255, ${opacity})`,
|
||||||
labelColor: (opacity = 1) => `rgba(107, 114, 128, ${opacity})`,
|
labelColor: (opacity = 1) => colors.textTertiary,
|
||||||
style: {
|
|
||||||
borderRadius: theme.borderRadius.lg,
|
|
||||||
},
|
|
||||||
propsForDots: {
|
propsForDots: {
|
||||||
r: "4",
|
r: "5",
|
||||||
strokeWidth: "2",
|
strokeWidth: "2",
|
||||||
stroke: theme.colors.primary,
|
stroke: colors.primary,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,31 +41,40 @@ export function WeeklyProgressChart({
|
|||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
data: checkInsData,
|
data: checkInsData,
|
||||||
color: (opacity = 1) => `rgba(59, 130, 246, ${opacity})`, // Blue for check-ins
|
color: () => colors.primary,
|
||||||
strokeWidth: 2,
|
strokeWidth: 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
data: goalsCompletedData,
|
data: goalsCompletedData,
|
||||||
color: (opacity = 1) => `rgba(16, 185, 129, ${opacity})`, // Green for goals
|
color: () => colors.success,
|
||||||
strokeWidth: 2,
|
strokeWidth: 3,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
legend: ["Check-ins", "Goals Completed"],
|
legend: ["Check-ins", "Goals"],
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.title}>{title}</Text>
|
{title && (
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
typography.h4,
|
||||||
|
{ color: colors.textPrimary, marginBottom: 16 },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
<View style={styles.chartContainer}>
|
<View style={styles.chartContainer}>
|
||||||
<LineChart
|
<LineChart
|
||||||
data={data}
|
data={data}
|
||||||
width={screenWidth - 60}
|
width={screenWidth - 80}
|
||||||
height={220}
|
height={180}
|
||||||
chartConfig={chartConfig}
|
chartConfig={chartConfig}
|
||||||
bezier
|
bezier
|
||||||
style={styles.chart}
|
style={styles.chart}
|
||||||
withInnerLines={true}
|
withInnerLines={true}
|
||||||
withOuterLines={true}
|
withOuterLines={false}
|
||||||
withVerticalLabels={true}
|
withVerticalLabels={true}
|
||||||
withHorizontalLabels={true}
|
withHorizontalLabels={true}
|
||||||
fromZero={true}
|
fromZero={true}
|
||||||
@@ -75,12 +82,20 @@ export function WeeklyProgressChart({
|
|||||||
</View>
|
</View>
|
||||||
<View style={styles.legend}>
|
<View style={styles.legend}>
|
||||||
<View style={styles.legendItem}>
|
<View style={styles.legendItem}>
|
||||||
<View style={[styles.legendDot, { backgroundColor: "#3b82f6" }]} />
|
<View
|
||||||
<Text style={styles.legendText}>Check-ins</Text>
|
style={[styles.legendDot, { backgroundColor: colors.primary }]}
|
||||||
|
/>
|
||||||
|
<Text style={[typography.caption, { color: colors.textSecondary }]}>
|
||||||
|
Check-ins
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.legendItem}>
|
<View style={styles.legendItem}>
|
||||||
<View style={[styles.legendDot, { backgroundColor: "#10b981" }]} />
|
<View
|
||||||
<Text style={styles.legendText}>Goals Completed</Text>
|
style={[styles.legendDot, { backgroundColor: colors.success }]}
|
||||||
|
/>
|
||||||
|
<Text style={[typography.caption, { color: colors.textSecondary }]}>
|
||||||
|
Goals
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -89,17 +104,8 @@ export function WeeklyProgressChart({
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
backgroundColor: theme.colors.white,
|
borderRadius: 16,
|
||||||
borderRadius: theme.borderRadius.xl,
|
padding: 4,
|
||||||
padding: 16,
|
|
||||||
marginBottom: 16,
|
|
||||||
...theme.shadows.medium,
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
fontSize: theme.typography.fontSize.lg,
|
|
||||||
fontWeight: theme.typography.fontWeight.bold,
|
|
||||||
color: theme.colors.gray700,
|
|
||||||
marginBottom: 12,
|
|
||||||
},
|
},
|
||||||
chartContainer: {
|
chartContainer: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@@ -107,26 +113,22 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
chart: {
|
chart: {
|
||||||
marginVertical: 8,
|
marginVertical: 8,
|
||||||
borderRadius: theme.borderRadius.lg,
|
borderRadius: 12,
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
gap: 20,
|
gap: 24,
|
||||||
paddingTop: 8,
|
paddingTop: 8,
|
||||||
},
|
},
|
||||||
legendItem: {
|
legendItem: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: 6,
|
gap: 8,
|
||||||
},
|
},
|
||||||
legendDot: {
|
legendDot: {
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10,
|
height: 10,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
},
|
},
|
||||||
legendText: {
|
|
||||||
fontSize: theme.typography.fontSize.sm,
|
|
||||||
color: theme.colors.gray500,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
@@ -35,6 +35,7 @@ export const API_ENDPOINTS = {
|
|||||||
USERS: {
|
USERS: {
|
||||||
LIST: "/api/users",
|
LIST: "/api/users",
|
||||||
STATISTICS: "/api/users/statistics",
|
STATISTICS: "/api/users/statistics",
|
||||||
|
GYM: "/api/users/gym",
|
||||||
},
|
},
|
||||||
GYMS: "/api/gyms",
|
GYMS: "/api/gyms",
|
||||||
ATTENDANCE: {
|
ATTENDANCE: {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* FitAI Color System
|
* FitAI Color System - BOLD MODERN
|
||||||
* Nord Color Palette - A minimal, arctic-inspired palette
|
* Electric Blue palette with high-energy fitness app aesthetics
|
||||||
* https://www.nordtheme.com/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface ColorScheme {
|
export interface ColorScheme {
|
||||||
@@ -12,6 +11,7 @@ export interface ColorScheme {
|
|||||||
|
|
||||||
// Accent Colors
|
// Accent Colors
|
||||||
accent: string;
|
accent: string;
|
||||||
|
secondary: string;
|
||||||
terracotta: string;
|
terracotta: string;
|
||||||
sand: string;
|
sand: string;
|
||||||
|
|
||||||
@@ -21,6 +21,11 @@ export interface ColorScheme {
|
|||||||
danger: string;
|
danger: string;
|
||||||
info: string;
|
info: string;
|
||||||
|
|
||||||
|
// Activity Ring Colors
|
||||||
|
calories: string;
|
||||||
|
water: string;
|
||||||
|
workouts: string;
|
||||||
|
|
||||||
// Neutrals
|
// Neutrals
|
||||||
background: string;
|
background: string;
|
||||||
surface: string;
|
surface: string;
|
||||||
@@ -39,97 +44,119 @@ export interface ColorScheme {
|
|||||||
overlay: string;
|
overlay: string;
|
||||||
overlayLight: string;
|
overlayLight: string;
|
||||||
|
|
||||||
// Legacy compatibility (will be phased out)
|
// Gradients (as arrays)
|
||||||
|
primaryGradient: string[];
|
||||||
|
cardGradient: string[];
|
||||||
|
|
||||||
|
// Legacy compatibility
|
||||||
white: string;
|
white: string;
|
||||||
black: string;
|
black: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Light Mode Color Palette
|
* Light Mode - Bold & Energetic
|
||||||
* Nord Snow Storm (light backgrounds) with Polar Night (dark text)
|
|
||||||
*/
|
*/
|
||||||
export const lightColors: ColorScheme = {
|
export const lightColors: ColorScheme = {
|
||||||
// Primary Colors (Nord Frost - Aurora blue-green)
|
// Primary Colors - Electric Blue
|
||||||
primary: "#88C0D0", // Nord Frost 8 (main actions, cyan)
|
primary: "#0066FF",
|
||||||
primaryDark: "#5E81AC", // Nord Frost 10 (dark blue)
|
primaryDark: "#0052CC",
|
||||||
primaryLight: "#8FBCBB", // Nord Frost 7 (pale cyan)
|
primaryLight: "#3385FF",
|
||||||
|
|
||||||
// Accent Colors
|
// Accent Colors
|
||||||
accent: "#81A1C1", // Nord Frost 9 (blue-gray)
|
accent: "#7B2CBF", // Purple
|
||||||
terracotta: "#D08770", // Nord Aurora 12 (orange - replaces terracotta)
|
secondary: "#FF3B7A", // Hot Pink
|
||||||
sand: "#EBCB8B", // Nord Aurora 13 (yellow - warm accent)
|
terracotta: "#FF6B35", // Neon Orange
|
||||||
|
sand: "#FFD60A", // Electric Yellow
|
||||||
|
|
||||||
// Status Colors
|
// Status Colors - Vibrant
|
||||||
success: "#A3BE8C", // Nord Aurora 14 (green)
|
success: "#00D26A",
|
||||||
warning: "#EBCB8B", // Nord Aurora 13 (yellow)
|
warning: "#FFB800",
|
||||||
danger: "#BF616A", // Nord Aurora 11 (red)
|
danger: "#FF3B3B",
|
||||||
info: "#81A1C1", // Nord Frost 9 (blue)
|
info: "#00B8D9",
|
||||||
|
|
||||||
// Neutrals (Snow Storm palette)
|
// Activity Ring Colors
|
||||||
background: "#ECEFF4", // Nord Snow Storm 3 (lightest)
|
calories: "#FF6B35", // Orange for calories
|
||||||
surface: "#E5E9F0", // Nord Snow Storm 2 (medium)
|
water: "#00B8D9", // Cyan for water
|
||||||
surfaceElevated: "#D8DEE9", // Nord Snow Storm 1 (slightly darker)
|
workouts: "#0066FF", // Blue for workouts
|
||||||
|
|
||||||
// Text (Polar Night palette)
|
// Neutrals - Bold dark on light
|
||||||
textPrimary: "#2E3440", // Nord Polar Night 0 (darkest)
|
background: "#F5F5F7",
|
||||||
textSecondary: "#3B4252", // Nord Polar Night 1
|
surface: "#FFFFFF",
|
||||||
textTertiary: "#4C566A", // Nord Polar Night 3
|
surfaceElevated: "#FFFFFF",
|
||||||
|
|
||||||
|
// Text - High contrast dark
|
||||||
|
textPrimary: "#1A1A1A",
|
||||||
|
textSecondary: "#4A4A4A",
|
||||||
|
textTertiary: "#8E8E93",
|
||||||
|
|
||||||
// Borders
|
// Borders
|
||||||
border: "#D8DEE9", // Nord Snow Storm 1
|
border: "#E5E5EA",
|
||||||
borderLight: "#E5E9F0", // Nord Snow Storm 2
|
borderLight: "#F0F0F5",
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
overlay: "rgba(46, 52, 64, 0.5)", // Polar Night 0
|
overlay: "rgba(0, 0, 0, 0.5)",
|
||||||
overlayLight: "rgba(46, 52, 64, 0.05)",
|
overlayLight: "rgba(0, 0, 0, 0.03)",
|
||||||
|
|
||||||
|
// Gradients
|
||||||
|
primaryGradient: ["#0066FF", "#0052CC"],
|
||||||
|
cardGradient: ["#FFFFFF", "#F8F8FA"],
|
||||||
|
|
||||||
// Legacy
|
// Legacy
|
||||||
white: "#ECEFF4",
|
white: "#FFFFFF",
|
||||||
black: "#2E3440",
|
black: "#1A1A1A",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dark Mode Color Palette
|
* Dark Mode - Premium & Immersive
|
||||||
* Nord Polar Night (dark backgrounds) with Snow Storm (light text)
|
|
||||||
*/
|
*/
|
||||||
export const darkColors: ColorScheme = {
|
export const darkColors: ColorScheme = {
|
||||||
// Primary Colors (Nord Frost - adjusted for dark mode)
|
// Primary Colors - Electric Blue (brighter on dark)
|
||||||
primary: "#88C0D0", // Nord Frost 8 (cyan - brighter on dark)
|
primary: "#0A84FF",
|
||||||
primaryDark: "#5E81AC", // Nord Frost 10 (dark blue)
|
primaryDark: "#0066FF",
|
||||||
primaryLight: "#8FBCBB", // Nord Frost 7 (pale cyan)
|
primaryLight: "#5AC8FA",
|
||||||
|
|
||||||
// Accent Colors
|
// Accent Colors
|
||||||
accent: "#81A1C1", // Nord Frost 9 (blue-gray)
|
accent: "#BF5AF2", // Purple
|
||||||
terracotta: "#D08770", // Nord Aurora 12 (orange)
|
secondary: "#FF375F", // Hot Pink
|
||||||
sand: "#EBCB8B", // Nord Aurora 13 (yellow)
|
terracotta: "#FF9500", // Orange
|
||||||
|
sand: "#FFD60A", // Yellow
|
||||||
|
|
||||||
// Status Colors
|
// Status Colors
|
||||||
success: "#A3BE8C", // Nord Aurora 14 (green)
|
success: "#30D158",
|
||||||
warning: "#EBCB8B", // Nord Aurora 13 (yellow)
|
warning: "#FFD60A",
|
||||||
danger: "#BF616A", // Nord Aurora 11 (red)
|
danger: "#FF453A",
|
||||||
info: "#81A1C1", // Nord Frost 9 (blue)
|
info: "#64D2FF",
|
||||||
|
|
||||||
// Neutrals (Polar Night palette)
|
// Activity Ring Colors (even brighter for dark mode)
|
||||||
background: "#2E3440", // Nord Polar Night 0 (darkest)
|
calories: "#FF9500",
|
||||||
surface: "#3B4252", // Nord Polar Night 1 (medium dark)
|
water: "#64D2FF",
|
||||||
surfaceElevated: "#434C5E", // Nord Polar Night 2 (lighter)
|
workouts: "#0A84FF",
|
||||||
|
|
||||||
// Text (Snow Storm palette)
|
// Neutrals - Dark backgrounds
|
||||||
textPrimary: "#ECEFF4", // Nord Snow Storm 3 (lightest)
|
background: "#000000",
|
||||||
textSecondary: "#E5E9F0", // Nord Snow Storm 2
|
surface: "#1C1C1E",
|
||||||
textTertiary: "#D8DEE9", // Nord Snow Storm 1
|
surfaceElevated: "#2C2C2E",
|
||||||
|
|
||||||
|
// Text - Bright on dark
|
||||||
|
textPrimary: "#FFFFFF",
|
||||||
|
textSecondary: "#EBEBF5",
|
||||||
|
textTertiary: "#8E8E93",
|
||||||
|
|
||||||
// Borders
|
// Borders
|
||||||
border: "#434C5E", // Nord Polar Night 2
|
border: "#38383A",
|
||||||
borderLight: "#3B4252", // Nord Polar Night 1
|
borderLight: "#48484A",
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
overlay: "rgba(0, 0, 0, 0.6)",
|
overlay: "rgba(0, 0, 0, 0.6)",
|
||||||
overlayLight: "rgba(236, 239, 244, 0.05)", // Snow Storm 3
|
overlayLight: "rgba(255, 255, 255, 0.05)",
|
||||||
|
|
||||||
|
// Gradients
|
||||||
|
primaryGradient: ["#0A84FF", "#0066FF"],
|
||||||
|
cardGradient: ["#1C1C1E", "#2C2C2E"],
|
||||||
|
|
||||||
// Legacy
|
// Legacy
|
||||||
white: "#ECEFF4",
|
white: "#FFFFFF",
|
||||||
black: "#2E3440",
|
black: "#000000",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,53 +1,54 @@
|
|||||||
/**
|
/**
|
||||||
* FitAI Typography System
|
* FitAI Typography System - BOLD MODERN
|
||||||
* Minimalist typography with clear hierarchy using system fonts
|
* High-impact typography with clear hierarchy using system fonts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TextStyle } from "react-native";
|
import { TextStyle } from "react-native";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Font Sizes
|
* Font Sizes - Larger for bold impact
|
||||||
* Refined scale with fewer sizes for clearer hierarchy
|
|
||||||
*/
|
*/
|
||||||
export const fontSize = {
|
export const fontSize = {
|
||||||
xs: 11,
|
xs: 12,
|
||||||
sm: 13,
|
sm: 14,
|
||||||
base: 15,
|
base: 16,
|
||||||
md: 17, // Body emphasis
|
md: 18, // Body emphasis
|
||||||
lg: 20,
|
lg: 22,
|
||||||
xl: 24,
|
xl: 26,
|
||||||
"2xl": 28,
|
"2xl": 32,
|
||||||
"3xl": 34,
|
"3xl": 40,
|
||||||
"4xl": 40,
|
"4xl": 52,
|
||||||
|
"5xl": 64,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Font Weights
|
* Font Weights - Emphasize bold
|
||||||
*/
|
*/
|
||||||
export const fontWeight = {
|
export const fontWeight = {
|
||||||
regular: "400" as TextStyle["fontWeight"],
|
regular: "400" as TextStyle["fontWeight"],
|
||||||
medium: "500" as TextStyle["fontWeight"],
|
medium: "500" as TextStyle["fontWeight"],
|
||||||
semibold: "600" as TextStyle["fontWeight"],
|
semibold: "600" as TextStyle["fontWeight"],
|
||||||
bold: "700" as TextStyle["fontWeight"],
|
bold: "700" as TextStyle["fontWeight"],
|
||||||
|
extrabold: "800" as TextStyle["fontWeight"],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Line Heights
|
* Line Heights
|
||||||
*/
|
*/
|
||||||
export const lineHeight = {
|
export const lineHeight = {
|
||||||
tight: 1.2,
|
tight: 1.15,
|
||||||
normal: 1.5,
|
normal: 1.4,
|
||||||
relaxed: 1.7,
|
relaxed: 1.6,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Letter Spacing
|
* Letter Spacing
|
||||||
*/
|
*/
|
||||||
export const letterSpacing = {
|
export const letterSpacing = {
|
||||||
tight: -0.5,
|
tight: -1,
|
||||||
normal: 0,
|
normal: 0,
|
||||||
wide: 0.5,
|
wide: 0.5,
|
||||||
wider: 1,
|
wider: 1.5,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,11 +59,14 @@ export interface TypographyPresets {
|
|||||||
h1: TextStyle;
|
h1: TextStyle;
|
||||||
h2: TextStyle;
|
h2: TextStyle;
|
||||||
h3: TextStyle;
|
h3: TextStyle;
|
||||||
|
h4: TextStyle;
|
||||||
body: TextStyle;
|
body: TextStyle;
|
||||||
bodyEmphasis: TextStyle;
|
bodyEmphasis: TextStyle;
|
||||||
label: TextStyle;
|
label: TextStyle;
|
||||||
stat: TextStyle;
|
stat: TextStyle;
|
||||||
|
statLarge: TextStyle;
|
||||||
caption: TextStyle;
|
caption: TextStyle;
|
||||||
|
button: TextStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTypographyPresets = (
|
export const createTypographyPresets = (
|
||||||
@@ -70,25 +74,33 @@ export const createTypographyPresets = (
|
|||||||
textSecondary: string,
|
textSecondary: string,
|
||||||
textTertiary: string,
|
textTertiary: string,
|
||||||
): TypographyPresets => ({
|
): TypographyPresets => ({
|
||||||
// Display Text (Screen Titles)
|
// Display Text (Screen Titles) - Extra Bold
|
||||||
h1: {
|
h1: {
|
||||||
fontSize: fontSize["3xl"],
|
fontSize: fontSize["4xl"],
|
||||||
fontWeight: fontWeight.bold,
|
fontWeight: fontWeight.extrabold,
|
||||||
letterSpacing: letterSpacing.tight,
|
letterSpacing: letterSpacing.tight,
|
||||||
lineHeight: fontSize["3xl"] * lineHeight.tight,
|
lineHeight: fontSize["4xl"] * lineHeight.tight,
|
||||||
color: textPrimary,
|
color: textPrimary,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Section Headers
|
// Section Headers - Bold
|
||||||
h2: {
|
h2: {
|
||||||
fontSize: fontSize.xl,
|
fontSize: fontSize["2xl"],
|
||||||
|
fontWeight: fontWeight.bold,
|
||||||
|
letterSpacing: -0.5,
|
||||||
|
color: textPrimary,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Card Titles - Semibold
|
||||||
|
h3: {
|
||||||
|
fontSize: fontSize.lg,
|
||||||
fontWeight: fontWeight.semibold,
|
fontWeight: fontWeight.semibold,
|
||||||
letterSpacing: -0.3,
|
letterSpacing: -0.3,
|
||||||
color: textPrimary,
|
color: textPrimary,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Card Titles
|
// Small Headers
|
||||||
h3: {
|
h4: {
|
||||||
fontSize: fontSize.md,
|
fontSize: fontSize.md,
|
||||||
fontWeight: fontWeight.semibold,
|
fontWeight: fontWeight.semibold,
|
||||||
color: textPrimary,
|
color: textPrimary,
|
||||||
@@ -112,17 +124,27 @@ export const createTypographyPresets = (
|
|||||||
|
|
||||||
// Labels (uppercase, spaced)
|
// Labels (uppercase, spaced)
|
||||||
label: {
|
label: {
|
||||||
fontSize: fontSize.sm,
|
fontSize: fontSize.xs,
|
||||||
fontWeight: fontWeight.medium,
|
fontWeight: fontWeight.semibold,
|
||||||
letterSpacing: letterSpacing.wide,
|
letterSpacing: letterSpacing.wider,
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
color: textTertiary,
|
color: textTertiary,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Stats/Numbers
|
// Stats/Numbers - Bold Large
|
||||||
stat: {
|
stat: {
|
||||||
fontSize: fontSize["2xl"],
|
fontSize: fontSize["3xl"],
|
||||||
fontWeight: fontWeight.bold,
|
fontWeight: fontWeight.bold,
|
||||||
|
letterSpacing: -1,
|
||||||
|
color: textPrimary,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Large Stats (Hero numbers)
|
||||||
|
statLarge: {
|
||||||
|
fontSize: fontSize["5xl"],
|
||||||
|
fontWeight: fontWeight.extrabold,
|
||||||
|
letterSpacing: -2,
|
||||||
|
lineHeight: fontSize["5xl"] * lineHeight.tight,
|
||||||
color: textPrimary,
|
color: textPrimary,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -132,6 +154,13 @@ export const createTypographyPresets = (
|
|||||||
fontWeight: fontWeight.regular,
|
fontWeight: fontWeight.regular,
|
||||||
color: textTertiary,
|
color: textTertiary,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Button Text
|
||||||
|
button: {
|
||||||
|
fontSize: fontSize.base,
|
||||||
|
fontWeight: fontWeight.bold,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user