refactor: update Dockerfile to use Node.js 22-alpine and optimize project queries in portal pages
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# ── Production Dockerfile (Dokploy / Coolify ready) ──────────────
|
# ── Production Dockerfile (Dokploy / Coolify ready) ──────────────
|
||||||
FROM node:20-alpine AS base
|
FROM node:22-alpine AS base
|
||||||
|
|
||||||
# ── 1. Install dependencies ─────────────────────────────────────
|
# ── 1. Install dependencies ─────────────────────────────────────
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export function AnalyticsClient({ data }: AnalyticsClientProps) {
|
|||||||
))}
|
))}
|
||||||
</Pie>
|
</Pie>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
formatter={(value: number) => `₺${value}`}
|
formatter={(value) => `₺${Number(value ?? 0)}`}
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
backgroundColor: 'hsl(var(--background))',
|
backgroundColor: 'hsl(var(--background))',
|
||||||
borderColor: 'hsl(var(--border))',
|
borderColor: 'hsl(var(--border))',
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ export default function TimeTrackingPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right: Analytics & AI */}
|
{/* Right: Analytics & AI */}
|
||||||
<div className="flex flex-col gap-8">
|
<div className="flex flex-col gap-8">
|
||||||
|
|||||||
+5
-16
@@ -1,6 +1,6 @@
|
|||||||
import { createClient } from "@/lib/supabase/server";
|
import { createClient } from "@/lib/supabase/server";
|
||||||
import { Card, CardContent, Badge } from "poyraz-ui/atoms";
|
import { Card, CardContent, Badge } from "poyraz-ui/atoms";
|
||||||
import { FolderKanban, CheckCircle2, Clock, Activity, Wallet, BarChart } from "lucide-react";
|
import { FolderKanban, CheckCircle2, Clock, Activity, BarChart } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { tr } from "date-fns/locale";
|
import { tr } from "date-fns/locale";
|
||||||
@@ -32,7 +32,7 @@ export default async function PortalDashboardPage() {
|
|||||||
// 2. Get Projects
|
// 2. Get Projects
|
||||||
const { data: projectsData } = await supabase
|
const { data: projectsData } = await supabase
|
||||||
.from("projects")
|
.from("projects")
|
||||||
.select("id, name, status, progress, due_date, budget_amount, currency, created_at")
|
.select("id, name, status, progress, due_date, created_at")
|
||||||
.eq("client_id", clientData.id)
|
.eq("client_id", clientData.id)
|
||||||
.order("created_at", { ascending: false });
|
.order("created_at", { ascending: false });
|
||||||
|
|
||||||
@@ -41,17 +41,8 @@ export default async function PortalDashboardPage() {
|
|||||||
const activeProjects = projects.filter(p => p.status !== 'completed' && p.status !== 'cancelled');
|
const activeProjects = projects.filter(p => p.status !== 'completed' && p.status !== 'cancelled');
|
||||||
const completedProjects = projects.filter(p => p.status === 'completed');
|
const completedProjects = projects.filter(p => p.status === 'completed');
|
||||||
|
|
||||||
const totalBudget = activeProjects.reduce((sum, p) => sum + (Number(p.budget_amount) || 0), 0);
|
|
||||||
const avgProgress = projects.length > 0 ? (projects.reduce((sum, p) => sum + (p.progress || 0), 0) / projects.length).toFixed(0) : "0";
|
const avgProgress = projects.length > 0 ? (projects.reduce((sum, p) => sum + (p.progress || 0), 0) / projects.length).toFixed(0) : "0";
|
||||||
|
|
||||||
const formatCurrency = (val: number) => {
|
|
||||||
return new Intl.NumberFormat("tr-TR", {
|
|
||||||
style: "currency",
|
|
||||||
currency: projects[0]?.currency || "USD",
|
|
||||||
maximumFractionDigits: 0,
|
|
||||||
}).format(val);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto flex max-w-7xl flex-col gap-6">
|
<div className="mx-auto flex max-w-7xl flex-col gap-6">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -66,18 +57,17 @@ export default async function PortalDashboardPage() {
|
|||||||
Müşteri Paneli
|
Müşteri Paneli
|
||||||
</h1>
|
</h1>
|
||||||
<p className="mt-1 max-w-2xl text-sm text-muted-foreground">
|
<p className="mt-1 max-w-2xl text-sm text-muted-foreground">
|
||||||
Hoş geldiniz, {clientData.name}. Aktif projelerinizi, ilerlemeleri ve bütçe durumunuzu buradan takip edin.
|
Hoş geldiniz, {clientData.name}. Aktif projelerinizi ve ilerlemeleri buradan takip edin.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* KPI Cards */}
|
{/* KPI Cards */}
|
||||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
<div className="grid gap-4 md:grid-cols-3">
|
||||||
<StatCard label="Aktif Projeler" value={activeProjects.length.toString()} icon={FolderKanban} tone="blue" />
|
<StatCard label="Aktif Projeler" value={activeProjects.length.toString()} icon={FolderKanban} tone="blue" />
|
||||||
<StatCard label="Tamamlanan" value={completedProjects.length.toString()} icon={CheckCircle2} tone="green" />
|
<StatCard label="Tamamlanan" value={completedProjects.length.toString()} icon={CheckCircle2} tone="green" />
|
||||||
<StatCard label="Ortalama İlerleme" value={`%${avgProgress}`} icon={BarChart} tone="amber" />
|
<StatCard label="Ortalama İlerleme" value={`%${avgProgress}`} icon={BarChart} tone="amber" />
|
||||||
<StatCard label="Aktif Bütçe" value={formatCurrency(totalBudget)} icon={Wallet} tone="red" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Projects */}
|
{/* Projects */}
|
||||||
@@ -146,13 +136,12 @@ function StatCard({
|
|||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
icon: any;
|
icon: any;
|
||||||
tone: "green" | "blue" | "amber" | "red";
|
tone: "green" | "blue" | "amber";
|
||||||
}) {
|
}) {
|
||||||
const toneClass = {
|
const toneClass = {
|
||||||
green: "bg-emerald-50 text-emerald-700",
|
green: "bg-emerald-50 text-emerald-700",
|
||||||
blue: "bg-blue-50 text-blue-700",
|
blue: "bg-blue-50 text-blue-700",
|
||||||
amber: "bg-amber-50 text-amber-700",
|
amber: "bg-amber-50 text-amber-700",
|
||||||
red: "bg-primary/10 text-primary",
|
|
||||||
}[tone];
|
}[tone];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default async function PortalProjectPage({ params }: { params: Promise<{
|
|||||||
// 2. Get Project
|
// 2. Get Project
|
||||||
const { data: project, error } = await supabase
|
const { data: project, error } = await supabase
|
||||||
.from("projects")
|
.from("projects")
|
||||||
.select("*")
|
.select("id, name, description, status, progress, due_date, revision_quota")
|
||||||
.eq("id", id)
|
.eq("id", id)
|
||||||
.eq("client_id", clientData.id)
|
.eq("client_id", clientData.id)
|
||||||
.single();
|
.single();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default async function PortalProjectsPage() {
|
|||||||
|
|
||||||
const { data: projectsData } = await supabase
|
const { data: projectsData } = await supabase
|
||||||
.from("projects")
|
.from("projects")
|
||||||
.select("id, name, status, progress, due_date, budget_amount, currency")
|
.select("id, name, status, progress, due_date")
|
||||||
.eq("client_id", clientData.id)
|
.eq("client_id", clientData.id)
|
||||||
.order("created_at", { ascending: false });
|
.order("created_at", { ascending: false });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user