Skip to content

Commit 7d6d385

Browse files
committed
dont refresh page
1 parent ee64eaa commit 7d6d385

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

web/components/layout/auth/authLayout.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const AuthLayout = (props: AuthLayoutProps) => {
3434

3535
const [open, setOpen] = useState(false);
3636
const [chatWindowOpen, setChatWindowOpen] = useState(false);
37+
const [bannerDismissed, setBannerDismissed] = useState(false);
3738
const agentChatPanelRef = useRef<any>(null);
3839

3940
const auth = useHeliconeAuthClient();
@@ -128,8 +129,8 @@ const AuthLayout = (props: AuthLayoutProps) => {
128129
const isEligibleForDiscount = GATEWAY_DISCOUNT_ELIGIBLE_ORGS.includes(
129130
orgContext?.currentOrg?.id || ""
130131
);
131-
const gatewayBannerDismissed = typeof window !== "undefined" &&
132-
sessionStorage.getItem("gateway-discount-banner-dismissed") === "true";
132+
const gatewayBannerDismissed = bannerDismissed || (typeof window !== "undefined" &&
133+
sessionStorage.getItem("gateway-discount-banner-dismissed") === "true");
133134

134135
if (isEligibleForDiscount && !gatewayBannerDismissed) {
135136
return {
@@ -142,7 +143,7 @@ const AuthLayout = (props: AuthLayoutProps) => {
142143
dismissible: true,
143144
onDismiss: () => {
144145
sessionStorage.setItem("gateway-discount-banner-dismissed", "true");
145-
window.location.reload();
146+
setBannerDismissed(true);
146147
},
147148
} as BannerType;
148149
}
@@ -168,7 +169,7 @@ const AuthLayout = (props: AuthLayoutProps) => {
168169
} as BannerType;
169170
}
170171
return null;
171-
}, [alertBanners?.data, orgContext, router]);
172+
}, [alertBanners?.data, orgContext, router, bannerDismissed]);
172173

173174
const { changelog } = useChangelog();
174175

web/components/templates/dashboard/dashboardPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ const DashboardPage = (props: DashboardPageProps) => {
318318
.filter((d) => d.value !== 0);
319319

320320
const [openSuggestGraph, setOpenSuggestGraph] = useState(false);
321+
const [gatewayDiscountDismissed, setGatewayDiscountDismissed] = useState(false);
321322

322323
return (
323324
<>
@@ -541,6 +542,7 @@ const DashboardPage = (props: DashboardPageProps) => {
541542
orgContext?.currentOrg?.id || "",
542543
) &&
543544
metrics.totalCost.data?.data &&
545+
!gatewayDiscountDismissed &&
544546
!sessionStorage.getItem("gateway-discount-dismissed") && (
545547
<div className="group flex items-center gap-1">
546548
<button
@@ -581,7 +583,7 @@ const DashboardPage = (props: DashboardPageProps) => {
581583
<button
582584
onClick={() => {
583585
sessionStorage.setItem("gateway-discount-dismissed", "true");
584-
window.location.reload();
586+
setGatewayDiscountDismissed(true);
585587
}}
586588
className="text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100"
587589
aria-label="Dismiss"

web/components/templates/dashboard/panels/scores/scoresPanel.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import LoadingAnimation from "@/components/shared/loadingAnimation";
22
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
33
import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart";
4-
import clsx from "clsx";
54
import { useScores } from "./useScores";
65
import { ScoresPanelProps } from "./ScoresPanelProps";
76
import { useOrg } from "@/components/layout/org/organizationContext";

0 commit comments

Comments
 (0)