Skip to content

Commit 988f5b6

Browse files
committed
feat(trial-banner): add trial banner component to display trial status in sidebar
1 parent e369541 commit 988f5b6

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Rocket } from "lucide-react";
2+
import { useRouter } from "next/router";
3+
import { Button } from "@/components/ui/button";
4+
import { api } from "@/utils/api";
5+
6+
export const TrialBanner = () => {
7+
const router = useRouter();
8+
const { data: billingStatus } = api.stripe.getBillingStatus.useQuery();
9+
10+
if (!billingStatus?.isOnTrial) {
11+
return null;
12+
}
13+
14+
const daysRemaining = billingStatus.trialDaysRemaining ?? 0;
15+
16+
return (
17+
<div className="sticky top-0 z-20 mx-4 mt-4 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 rounded-lg border border-primary/20 bg-primary/10 px-4 py-2 text-sm">
18+
<span className="flex items-center gap-2">
19+
<Rocket className="h-4 w-4 text-primary shrink-0" />
20+
{daysRemaining > 0
21+
? `You have ${daysRemaining} day${daysRemaining === 1 ? "" : "s"} left in your free trial.`
22+
: "Your free trial ends today."}
23+
</span>
24+
<Button
25+
size="sm"
26+
variant="default"
27+
className="h-7"
28+
onClick={() => router.push("/dashboard/settings/billing")}
29+
>
30+
Upgrade now
31+
</Button>
32+
</div>
33+
);
34+
};

‎apps/dokploy/components/layouts/side.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import { authClient } from "@/lib/auth-client";
101101
import { cn } from "@/lib/utils";
102102
import type { AppRouter } from "@/server/api/root";
103103
import { api } from "@/utils/api";
104+
import { TrialBanner } from "../dashboard/billing/trial-banner";
104105
import { AddOrganization } from "../dashboard/organization/handle-organization";
105106
import { DialogAction } from "../shared/dialog-action";
106107
import { Logo } from "../shared/logo";
@@ -1229,6 +1230,7 @@ export default function Page({ children }: Props) {
12291230
<SidebarRail />
12301231
</Sidebar>
12311232
<SidebarInset>
1233+
{isCloud === true && <TrialBanner />}
12321234
{!includesProjects && (
12331235
<header className="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
12341236
<div className="flex items-center justify-between w-full px-4">

0 commit comments

Comments
 (0)