import React, { useContext, useMemo } from 'react'; import { Tooltip, Card, CardHeader, useTheme } from '@mui/material'; import { type Event } from 'nostr-tools'; // Icons import { Coordinator } from '../../../../models'; import RobotAvatar from '../../../../components/RobotAvatar'; import { UseAppStoreType, AppContext } from '../../../../contexts/AppContext'; import { useNavigate } from 'react-router-dom'; import { Grid } from '@mui/system'; import { GarageContext, UseGarageStoreType } from '../../../../contexts/GarageContext'; interface Props { event: Event; robotHashId?: string; coordinator?: Coordinator; setShow: (show: boolean) => void; } const NotificationCard: React.FC = ({ event, robotHashId, coordinator, setShow }) => { const theme = useTheme(); const navigate = useNavigate(); const { navigateToPage } = useContext(AppContext); const { garage } = useContext(GarageContext); const cardColor = theme.palette.mode === 'light' ? '#d1e6fa' : '#082745'; const avatar = useMemo(() => { if (!coordinator) return <>; return ( ); }, [coordinator]); const handleOnClick = () => { const orderId = event.tags.find((t) => t[0] === 'order_id')?.[1]; if (orderId) { const nostrHexPubkey = event.tags.find((t) => t[0] === 'p')?.[1]; const slot = garage.getSlotByNostrPubKey(nostrHexPubkey ?? ''); if (slot?.token) { setShow(false); garage.setCurrentSlot(slot.token); navigateToPage(`order/${orderId}`, navigate); } } }; return ( {new Date(event.created_at).toLocaleString()}
{coordinator?.longAlias} } >
{event.content}
} />
); }; export default NotificationCard;