diff --git a/src/app/dashboard/accounts/page.tsx b/src/app/dashboard/accounts/page.tsx
index e499809..3f93ee3 100644
--- a/src/app/dashboard/accounts/page.tsx
+++ b/src/app/dashboard/accounts/page.tsx
@@ -30,7 +30,7 @@ import {
} from "@/components/ui/alert-dialog";
import { AccountAvatar } from "@/components/accounts";
import { ConnectPlatformGrid } from "./_components/connect-platform-grid";
-import { PLATFORM_NAMES, type Platform } from "@/lib/late-api";
+import { getPlatformName, type Platform } from "@/lib/late-api";
import { Users, Plus, Loader2, AlertCircle, RefreshCw, Trash2 } from "lucide-react";
export default function AccountsPage() {
@@ -127,7 +127,7 @@ export default function AccountsPage() {
- {PLATFORM_NAMES[account.platform as Platform]}
+ {getPlatformName(account.platform)}
{needsReconnect && (
diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx
index 765cbd8..2c232ce 100644
--- a/src/app/dashboard/page.tsx
+++ b/src/app/dashboard/page.tsx
@@ -8,7 +8,7 @@ import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { AccountAvatar } from "@/components/accounts";
import { PlatformIcons, PostStatusBadge } from "@/components/posts";
-import { PLATFORM_NAMES, type Platform } from "@/lib/late-api";
+import { getPlatformName } from "@/lib/late-api";
import { format } from "date-fns/format";
import { parseISO } from "date-fns/parseISO";
import {
@@ -221,7 +221,7 @@ export default function DashboardPage() {
- {PLATFORM_NAMES[account.platform as Platform]}
+ {getPlatformName(account.platform)}
))
diff --git a/src/components/accounts/account-card.tsx b/src/components/accounts/account-card.tsx
index 2548320..da02b6d 100644
--- a/src/components/accounts/account-card.tsx
+++ b/src/components/accounts/account-card.tsx
@@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { PlatformIcon } from "@/components/shared/platform-icon";
-import { PLATFORM_NAMES, PLATFORM_COLORS, type Platform } from "@/lib/late-api";
+import { getPlatformName, getPlatformColor, type Platform } from "@/lib/late-api";
import { Trash2, RefreshCw, CheckCircle2, AlertCircle } from "lucide-react";
import type { Account, AccountHealth } from "@/hooks";
@@ -38,7 +38,7 @@ export function AccountCard({
- {PLATFORM_NAMES[platform]}
+ {getPlatformName(platform)}
@@ -109,7 +109,7 @@ export function AccountAvatar({ account, size = "md" }: AccountAvatarProps) {
- {PLATFORM_NAMES[platform]}
+ {getPlatformName(platform)}
{selected && (
diff --git a/src/components/shared/platform-icon.tsx b/src/components/shared/platform-icon.tsx
index 447fc8b..c0cbaf5 100644
--- a/src/components/shared/platform-icon.tsx
+++ b/src/components/shared/platform-icon.tsx
@@ -1,6 +1,6 @@
"use client";
-import { type Platform, PLATFORM_COLORS, PLATFORM_COLORS_DARK } from "@/lib/late-api";
+import { type Platform, getPlatformColor } from "@/lib/late-api";
import { cn } from "@/lib/utils";
import { useTheme } from "next-themes";
@@ -73,6 +73,15 @@ const platformIcons: Record = ({ className, style }) => (
+
+);
+
interface PlatformIconProps {
platform: Platform;
className?: string;
@@ -94,10 +103,10 @@ export function PlatformIcon({
showColor = false,
size = "md",
}: PlatformIconProps) {
- const Icon = platformIcons[platform];
+ const Icon = platformIcons[platform] ?? FallbackPlatformIcon;
const { resolvedTheme } = useTheme();
const isDark = resolvedTheme === "dark";
- const color = isDark ? PLATFORM_COLORS_DARK[platform] : PLATFORM_COLORS[platform];
+ const color = getPlatformColor(platform, isDark);
return (
= {
telegram: "#5BC4F0",
};
+// The API can return platforms this app doesn't know about yet (e.g. whatsapp,
+// discord, ads accounts). Rendering must degrade gracefully, never crash, so
+// name/color lookups for arbitrary platform strings go through these helpers.
+export function getPlatformName(platform: string): string {
+ return (
+ PLATFORM_NAMES[platform as Platform] ??
+ platform.charAt(0).toUpperCase() + platform.slice(1)
+ );
+}
+
+export function getPlatformColor(platform: string, isDark = false): string {
+ const colors = isDark ? PLATFORM_COLORS_DARK : PLATFORM_COLORS;
+ return colors[platform as Platform] ?? (isDark ? "#9CA3AF" : "#6B7280");
+}
+
// Platforms that require entity selection after OAuth
export const PLATFORMS_WITH_ENTITY_SELECTION = [
"facebook",