import React from 'react'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Separator } from '@/components/ui/separator'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { CoinsData, HabitsData, WishlistData, UserData, User, CoinTransaction } from '@/lib/types'; import { t2d } from '@/lib/utils'; import Link from 'next/link'; import { DropdownMenuItem } from '@/components/ui/dropdown-menu'; import { Info } from 'lucide-react'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; interface NotificationDropdownProps { currentUser: User | null; unreadNotifications: CoinTransaction[]; displayedReadNotifications: CoinTransaction[]; habitsData: HabitsData; // Keep needed props wishlistData: WishlistData; usersData: UserData; } // Helper function to generate notification message const getNotificationMessage = (tx: CoinTransaction, triggeringUser?: User, relatedItemName?: string): string => { const username = triggeringUser?.username || 'Someone'; const itemName = relatedItemName || 'a shared item'; switch (tx.type) { case 'HABIT_COMPLETION': case 'TASK_COMPLETION': return `${username} completed ${itemName}.`; case 'WISH_REDEMPTION': return `${username} redeemed ${itemName}.`; // Add other relevant transaction types if needed default: return `Activity related to ${itemName} by ${username}.`; // Fallback message } }; // Helper function to get the name of the related item const getRelatedItemName = (tx: CoinTransaction, habitsData: HabitsData, wishlistData: WishlistData): string | undefined => { if (!tx.relatedItemId) return undefined; if (tx.type === 'HABIT_COMPLETION' || tx.type === 'TASK_COMPLETION') { return habitsData.habits.find(h => h.id === tx.relatedItemId)?.name; } if (tx.type === 'WISH_REDEMPTION') { return wishlistData.items.find(w => w.id === tx.relatedItemId)?.name; } return undefined; }; export default function NotificationDropdown({ currentUser, unreadNotifications, // Use props directly displayedReadNotifications, // Use props directly habitsData, wishlistData, usersData, }: NotificationDropdownProps) { if (!currentUser) { return
{message}
{timeAgo}
Shows completions or redemptions by other users for habits or wishlist that you shared with them (you must be admin)