Skip to content

Commit

Permalink
feat: banner display with page map
Browse files Browse the repository at this point in the history
  • Loading branch information
ogous committed Aug 29, 2024
1 parent fd62f36 commit 1bf7f7a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions web/src/components/Banners/BottomBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@ import { graphql, useFragment } from "@/gql";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
import { useGraphqlUser } from "@/hooks/useGraphql";
import { cn } from "@/lib/utils";
import { useWelcomeStore } from "@/stores/useWelcomeStore";
import { usePathname } from "next/navigation";
import { useState } from "react";
const NotesFragment = graphql(`
fragment NotesFragment on Note {
content
placement
}
`);

const pagesWithBanner = ["/", "/stake/pool", "/swap/confirm"];
export default function BottomBanner() {
const pathname = usePathname();
const renderBanner = pagesWithBanner.includes(pathname);
const { data } = useGraphqlUser();
const notes = useFragment(NotesFragment, data?.notes);
const bottomNote = notes?.find((item) => item.placement.includes("bottom"));
const showBanners = useFeatureFlag("ui show banners");
const featureEnabled = useFeatureFlag("ui show banners");
const [isBannerClosed, setIsBannerClosed] = useState(false);
const welcome = useWelcomeStore((state) => state.welcome);
const dontRenderBanner =
!bottomNote ||
!featureEnabled ||
isBannerClosed ||
!renderBanner ||
welcome;

if (!bottomNote || !showBanners || isBannerClosed) return null;
if (dontRenderBanner) return null;

const isLeftBanner = bottomNote.placement.includes("left");
return (
Expand Down

0 comments on commit 1bf7f7a

Please sign in to comment.