import { Button } from "~/components/ui/button"; import { ArrowRight } from "lucide-react"; import { Link, useNavigate } from "@remix-run/react"; import { ProductDetail } from "src/api/types"; import { useCreateChatThread } from "~/requestHandler/use-chat-hooks"; import { useState } from "react"; import { useRootData } from "~/hooks/use-root-data"; import { LoginRequiredDialog } from "~/components/LoginRequiredDialog"; import SellerLogo from "~/components/SellerLogo"; import { safeGoBack } from "~/utils/helpers"; interface ProductHeaderProps { product: ProductDetail; } export const ProductHeader = ({ product }: ProductHeaderProps) => { const navigate = useNavigate(); const { user } = useRootData(); const [isLoginDialogOpen, setIsLoginDialogOpen] = useState(false); const { mutate: createChatThread, isPending: isCreatingChatThread } = useCreateChatThread(); const handleCreateChatThread = () => { if (!user) { setIsLoginDialogOpen(true); return; } if (!product.seller?.id) return; createChatThread( { participantId: product.seller.id, productId: product.id }, { onSuccess: (threadData) => { navigate(`/profile/threads/${threadData.id}`); }, } ); }; return ( <>
safeGoBack(navigate)} className="absolute right-5" style={{ top: "calc(env(safe-area-inset-top, 0px) + 20px)" }} />

{product.seller?.username}

); };