The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update Announcement.tsx (#4023)
Jonathan Summers-Muir692c0f4383b0
diff --git a/www/components/Nav/Announcement.tsx b/www/components/Nav/Announcement.tsxindex e6cdc1ef968..a4069846c4f 100644--- a/www/components/Nav/Announcement.tsx+++ b/www/components/Nav/Announcement.tsx@@ -1,14 +1,46 @@-import React from 'react'-import Link from 'next/link'+import React, { useEffect, useState } from 'react'import announcement from '~/data/Announcement.json'-import { IconChevronRight, Button, IconX } from '@supabase/ui'+import { IconChevronRight, IconX } from '@supabase/ui'+import { useRouter } from 'next/router'const Announcement = () => {+ const [hidden, setHidden] = useState(false)++ const router = useRouter()++ // override to hide announcementif (!announcement.show) return null- return (- <Link href={announcement.link}>++ // construct the key for the announcement, based on the title text+ const announcementKey = 'announcement_' + announcement.text.replace(/ /g, '')++ // window.localStorage is kept inside useEffect+ // to prevent error+ useEffect(function () {+ if (window.localStorage.getItem(announcementKey)) {+ return setHidden(true)+ }+ }, [])++ function handleClose(event: any) {+ event.stopPropagation()++ window.localStorage.setItem(announcementKey, 'hidden')+ return setHidden(true)+ }++ function handleLink() {+ router.push(announcement.link)+ window.localStorage.setItem(announcementKey, 'hidden')+ }++ if (hidden) {+ return null+ } else {+ return (<div+ onClick={handleLink}className="relativecursor-pointer@@ -35,12 +67,15 @@ const Announcement = () => {<IconChevronRight size={14} /></span></div>- <div className="transition-opacity absolute right-4 h-full flex items-center opacity-50 hover:opacity-100">+ <div+ className="transition-opacity absolute right-4 h-full flex items-center opacity-50 hover:opacity-100"+ onClick={handleClose}+ ><IconX size={16} /></div></div>- </Link>- )+ )+ }}export default Announcement