import Image from "next/image"; import JanImage from "../JanImage"; import { displayDate } from "@/_utils/datetime"; import Link from "next/link"; import { useStore } from "@/_models/RootStore"; import useGetCurrentUser from "@/_hooks/useGetCurrentUser"; import { CreateMessageMutation, CreateMessageDocument, GenerateImageMutation, GenerateImageDocument, } from "@/graphql"; import { useMutation } from "@apollo/client"; type Props = { avatarUrl?: string; senderName: string; text?: string; createdAt: number; imageUrls: string[]; }; const SimpleImageMessage: React.FC = ({ avatarUrl = "", senderName, imageUrls, text, createdAt, }) => { const { historyStore } = useStore(); const { user } = useGetCurrentUser(); const [createMessageMutation] = useMutation( CreateMessageDocument ); const [imageGenerationMutation] = useMutation( GenerateImageDocument ); const onRegenerate = () => { if (!user) { // TODO: we should show an error here return; } historyStore.sendMessage( createMessageMutation, imageGenerationMutation, text ?? "", user.id, senderName, avatarUrl ); }; return (
{senderName}
{displayDate(createdAt)}
Download
); }; export default SimpleImageMessage;