CoolFace
Apppublic

legends810/testingnew

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
NetlifyDeploymentLink.client.tsx52 linesDownload Raw Back to chat
1import { useStore } from '@nanostores/react';2import { netlifyConnection, fetchNetlifyStats } from '~/lib/stores/netlify';3import { chatId } from '~/lib/persistence/useChatHistory';4import * as Tooltip from '@radix-ui/react-tooltip';5import { useEffect } from 'react';6 7export function NetlifyDeploymentLink() {8  const connection = useStore(netlifyConnection);9  const currentChatId = useStore(chatId);10 11  useEffect(() => {12    if (connection.token && currentChatId) {13      fetchNetlifyStats(connection.token);14    }15  }, [connection.token, currentChatId]);16 17  const deployedSite = connection.stats?.sites?.find((site) => site.name.includes(`bolt-diy-${currentChatId}`));18 19  if (!deployedSite) {20    return null;21  }22 23  return (24    <Tooltip.Provider>25      <Tooltip.Root>26        <Tooltip.Trigger asChild>27          <a28            href={deployedSite.url}29            target="_blank"30            rel="noopener noreferrer"31            className="inline-flex items-center justify-center w-8 h-8 rounded hover:bg-bolt-elements-item-backgroundActive text-bolt-elements-textSecondary hover:text-[#00AD9F] z-50"32            onClick={(e) => {33              e.stopPropagation(); // Add this to prevent click from bubbling up34            }}35          >36            <div className="i-ph:rocket-launch w-5 h-5" />37          </a>38        </Tooltip.Trigger>39        <Tooltip.Portal>40          <Tooltip.Content41            className="px-3 py-2 rounded bg-bolt-elements-background-depth-3 text-bolt-elements-textPrimary text-xs z-50"42            sideOffset={5}43          >44            {deployedSite.url}45            <Tooltip.Arrow className="fill-bolt-elements-background-depth-3" />46          </Tooltip.Content>47        </Tooltip.Portal>48      </Tooltip.Root>49    </Tooltip.Provider>50  );51}52