mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-11-02 22:22:45 +00:00
108 files: README, marketing copy, page titles, meta tags, footer text, email templates, .env.example, UI strings. URLs swapped from papermark.com/papermark.io to dataroom.hanzo.ai. Internal identifiers left intact per repo policy: localStorage keys (papermark.email/papermark.name/last_papermark_login — changing them logs users out), type field names (papermarkUserId), internal helper symbols (PAPERMARK_HEADERS, PapermarkSparkle component, isPapermarkUrl helper), internal-only filenames. LLM.md retains 'Upstream: Papermark' attribution line. Per-locale .po translations regenerate from source on the next lingui-extract CI run. DB migrations untouched (append-only history; rewriting them breaks installed schemas). LICENSE stays AGPL-3.0.
92 lines
3.0 KiB
TypeScript
92 lines
3.0 KiB
TypeScript
import { useRouter } from "next/router";
|
|
|
|
import { Dispatch, SetStateAction, useState } from "react";
|
|
|
|
import { useTeam } from "@/context/team-context";
|
|
import { getPriceIdFromPlan } from "@/lib/billing/legacy/functions/get-price-id-from-plan";
|
|
import Cookies from "js-cookie";
|
|
import { toast } from "sonner";
|
|
|
|
import { usePlan } from "@/lib/swr/use-billing";
|
|
|
|
import X from "@/components/shared/icons/x";
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
export default function ProAnnualBanner({
|
|
setShowProAnnualBanner,
|
|
}: {
|
|
setShowProAnnualBanner: Dispatch<SetStateAction<boolean | null>>;
|
|
}) {
|
|
const router = useRouter();
|
|
const teamInfo = useTeam();
|
|
const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();
|
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const handleHideBanner = () => {
|
|
setShowProAnnualBanner(false);
|
|
Cookies.set("hideProAnnualBanner", "pro-annual-banner", {
|
|
expires: 7,
|
|
});
|
|
};
|
|
|
|
return (
|
|
<aside className="relative mb-2 flex w-full flex-col justify-center rounded-lg border border-gray-700 bg-background p-4 text-foreground">
|
|
<button
|
|
type="button"
|
|
onClick={handleHideBanner}
|
|
className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
|
|
>
|
|
<X className="h-4 w-4" />
|
|
<span className="sr-only">Close</span>
|
|
</button>
|
|
<div className="flex space-x-2">
|
|
<span className="text-sm font-bold">Hanzo Dataroom Pro Annual ✨</span>
|
|
</div>
|
|
<p className="my-4 text-sm">
|
|
Lock in a better price and get 2 months free.
|
|
</p>
|
|
<div className="flex">
|
|
<Button
|
|
type="button"
|
|
className="grow"
|
|
loading={isLoading}
|
|
onClick={() => {
|
|
if (isCustomer && teamPlan === "pro") {
|
|
setIsLoading(true);
|
|
fetch(`/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
priceId: getPriceIdFromPlan({
|
|
planSlug: "pro",
|
|
isOld: isOldAccount,
|
|
period: "yearly",
|
|
}),
|
|
upgradePlan: true,
|
|
proAnnualBanner: true,
|
|
}),
|
|
})
|
|
.then(async (res) => {
|
|
const url = await res.json();
|
|
router.push(url);
|
|
})
|
|
.catch((err) => {
|
|
alert(err);
|
|
toast.error("Something went wrong");
|
|
})
|
|
.finally(() => {
|
|
setIsLoading(false);
|
|
});
|
|
}
|
|
}}
|
|
>
|
|
{isLoading ? "Redirecting..." : "Upgrade"}
|
|
</Button>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|