diff --git a/components/project/activity/action-icon.tsx b/components/project/activity/action-icon.tsx new file mode 100644 index 0000000..34cbfee --- /dev/null +++ b/components/project/activity/action-icon.tsx @@ -0,0 +1,53 @@ +import { ActivityIcon, Plus, RefreshCw, Trash2 } from "lucide-react"; +import { cn } from "@/lib/utils"; + +function CreatedIcon({ className }: { className?: string }) { + return ( +
+ +
+ ); +} + +function UpdatedIcon({ className }: { className?: string }) { + return ( +
+ +
+ ); +} + +function DeletedIcon({ className }: { className?: string }) { + return ( +
+ +
+ ); +} + +function DefaultIcon({ className }: { className?: string }) { + return ( +
+ +
+ ); +} + +export function ActionIcon({ + action, + className, +}: { + action: string; + className?: string; +}) { + switch (action) { + case "created": + return ; + case "updated": + return ; + case "deleted": + return ; + default: + return ; + } +} diff --git a/components/project/activity/activity-detail-panel.tsx b/components/project/activity/activity-detail-panel.tsx index 4f972ca..2cdaa1c 100644 --- a/components/project/activity/activity-detail-panel.tsx +++ b/components/project/activity/activity-detail-panel.tsx @@ -1,24 +1,18 @@ "use client"; import { useQuery } from "@tanstack/react-query"; -import { - CalendarIcon, - CompassIcon, - RefreshCw, - UserIcon, - X, -} from "lucide-react"; +import { CalendarIcon, CompassIcon, UserIcon, X } from "lucide-react"; import { useParams } from "next/navigation"; import { Panel } from "@/components/core/panel"; import { UserAvatar } from "@/components/core/user-avatar"; import { SpinnerWithSpacing } from "@/components/core/loaders"; import { formatEventTypeLabel, - getActionIcon, getEventDescription, } from "@/lib/activity/message"; import { guessTimezone, toFullDateTimeString } from "@/lib/utils/date"; import { useTRPCClient } from "@/trpc/client"; +import { ActionIcon } from "./action-icon"; function SectionLabel({ icon: Icon, @@ -64,9 +58,6 @@ export function ActivityDetailPanel({ }), }); - const actionConfig = item ? getActionIcon(item.action) : null; - const ActionIcon = actionConfig?.icon ?? RefreshCw; - return (
-
- -
+

{formatEventTypeLabel(item.type, item.action)} diff --git a/components/project/activity/activity-feed.tsx b/components/project/activity/activity-feed.tsx index 410bd15..dc517af 100644 --- a/components/project/activity/activity-feed.tsx +++ b/components/project/activity/activity-feed.tsx @@ -13,10 +13,10 @@ import type { ActivityWithActor } from "@/drizzle/types"; import { formatEventTypeLabel, generateObjectDiffMessage, - getActionIcon, } from "@/lib/activity/message"; import { guessTimezone, toDateTimeString } from "@/lib/utils/date"; import { useTRPCClient } from "@/trpc/client"; +import { ActionIcon } from "./action-icon"; import { ActivityDetailPanel } from "./activity-detail-panel"; const ACTIVITIES_LIMIT = 25; @@ -25,9 +25,6 @@ export function ActivityItem({ item, onSelect, }: { item: ActivityWithActor; onSelect: (id: number) => void }) { - const actionConfig = getActionIcon(item.action); - const ActionIcon = actionConfig.icon; - return (