mirror of
https://github.com/arkorty/B.Tech-Project-III.git
synced 2026-04-19 20:51:49 +00:00
init
This commit is contained in:
86
negot8/dashboard/lib/utils.ts
Normal file
86
negot8/dashboard/lib/utils.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
// Shared UI helpers — badges, labels, colour maps
|
||||
|
||||
import type { FeatureType, NegotiationStatus, Personality } from "@/lib/types";
|
||||
|
||||
// ─── Feature ────────────────────────────────────────────────────────────────
|
||||
|
||||
export const FEATURE_LABELS: Record<FeatureType, string> = {
|
||||
scheduling: "📅 Scheduling",
|
||||
expenses: "💰 Expenses",
|
||||
freelance: "💼 Freelance",
|
||||
roommate: "🏠 Roommate",
|
||||
trip: "✈️ Trip",
|
||||
marketplace: "🛒 Marketplace",
|
||||
collaborative: "🍕 Collaborative",
|
||||
conflict: "⚖️ Conflict",
|
||||
generic: "🤝 Generic",
|
||||
};
|
||||
|
||||
// ─── Personality ─────────────────────────────────────────────────────────────
|
||||
|
||||
export const PERSONALITY_LABELS: Record<Personality, string> = {
|
||||
aggressive: "😤 Aggressive",
|
||||
people_pleaser: "🤝 Pleaser",
|
||||
analytical: "📊 Analytical",
|
||||
empathetic: "💚 Empathetic",
|
||||
balanced: "⚖️ Balanced",
|
||||
};
|
||||
|
||||
export const PERSONALITY_COLORS: Record<Personality, string> = {
|
||||
aggressive: "bg-red-500/20 text-red-300 border-red-500/30",
|
||||
people_pleaser: "bg-blue-500/20 text-blue-300 border-blue-500/30",
|
||||
analytical: "bg-yellow-500/20 text-yellow-300 border-yellow-500/30",
|
||||
empathetic: "bg-green-500/20 text-green-300 border-green-500/30",
|
||||
balanced: "bg-purple-500/20 text-purple-300 border-purple-500/30",
|
||||
};
|
||||
|
||||
// ─── Status ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export const STATUS_LABELS: Record<NegotiationStatus, string> = {
|
||||
pending: "⏳ Pending",
|
||||
active: "🔄 Active",
|
||||
resolved: "✅ Resolved",
|
||||
escalated: "⚠️ Escalated",
|
||||
};
|
||||
|
||||
export const STATUS_COLORS: Record<NegotiationStatus, string> = {
|
||||
pending: "bg-zinc-500/20 text-zinc-400 border-zinc-500/30",
|
||||
active: "bg-blue-500/20 text-blue-300 border-blue-500/30 animate-pulse",
|
||||
resolved: "bg-green-500/20 text-green-300 border-green-500/30",
|
||||
escalated: "bg-amber-500/20 text-amber-300 border-amber-500/30",
|
||||
};
|
||||
|
||||
// ─── Fairness colour ─────────────────────────────────────────────────────────
|
||||
|
||||
export function fairnessColor(score: number): string {
|
||||
if (score >= 80) return "text-green-400";
|
||||
if (score >= 60) return "text-yellow-400";
|
||||
return "text-red-400";
|
||||
}
|
||||
|
||||
export function fairnessBarColor(score: number): string {
|
||||
if (score >= 80) return "bg-green-500";
|
||||
if (score >= 60) return "bg-yellow-500";
|
||||
return "bg-red-500";
|
||||
}
|
||||
|
||||
// ─── Satisfaction colour ─────────────────────────────────────────────────────
|
||||
|
||||
export function satColor(score: number): string {
|
||||
if (score >= 70) return "text-green-400";
|
||||
if (score >= 40) return "text-yellow-400";
|
||||
return "text-red-400";
|
||||
}
|
||||
|
||||
// ─── Time formatting ─────────────────────────────────────────────────────────
|
||||
|
||||
export function relativeTime(iso: string): string {
|
||||
const diff = Date.now() - new Date(iso).getTime();
|
||||
const s = Math.floor(diff / 1000);
|
||||
if (s < 60) return `${s}s ago`;
|
||||
const m = Math.floor(s / 60);
|
||||
if (m < 60) return `${m}m ago`;
|
||||
const h = Math.floor(m / 60);
|
||||
if (h < 24) return `${h}h ago`;
|
||||
return `${Math.floor(h / 24)}d ago`;
|
||||
}
|
||||
Reference in New Issue
Block a user