Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: add createdAt to team

Marc Seitz50f38d5d9678
diff --git a/components/layouts/trial-banner.tsx b/components/layouts/trial-banner.tsx
index af147a53..fe6a50c8 100644
--- a/components/layouts/trial-banner.tsx
+++ b/components/layouts/trial-banner.tsx
@@ -1,16 +1,17 @@
import { Dispatch, SetStateAction, useEffect, useState } from "react";
+import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
import Cookies from "js-cookie";
import { usePlausible } from "next-plausible";
-import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
-import X from "@/components/shared/icons/x";
-
import { usePlan } from "@/lib/swr/use-billing";
import useDatarooms from "@/lib/swr/use-datarooms";
import { daysLeft } from "@/lib/utils";
+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import X from "@/components/shared/icons/x";
+
export default function TrialBanner() {
const { trial } = usePlan();
const isTrial = !!trial;
@@ -36,6 +37,7 @@ function TrialBannerComponent({
}: {
setShowTrialBanner: Dispatch<SetStateAction<boolean | null>>;
}) {
+ const teamInfo = useTeam();
const plausible = usePlausible();
const handleHideBanner = () => {
@@ -62,8 +64,16 @@ function TrialBannerComponent({
<div className="flex flex-col space-y-2">
<div className="text-sm font-bold">
Data Room trial:{" "}
- {datarooms && daysLeft(new Date(datarooms[0].createdAt), 7)} days
- left
+ {datarooms &&
+ daysLeft(
+ new Date(
+ datarooms[0].createdAt ??
+ teamInfo?.currentTeam?.createdAt ??
+ new Date(),
+ ),
+ 7,
+ )}
+ days left
</div>
<div className="text-sm">
diff --git a/lib/types.ts b/lib/types.ts
index 5802e127..42d376e5 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -272,6 +272,7 @@ export interface Team {
name?: string;
logo?: React.ElementType;
plan?: string;
+ createdAt?: Date;
}
export interface TeamDetail {
diff --git a/pages/api/teams/index.ts b/pages/api/teams/index.ts
index c5563b60..5ed2b96d 100644
--- a/pages/api/teams/index.ts
+++ b/pages/api/teams/index.ts
@@ -33,6 +33,7 @@ export default async function handle(
id: true,
name: true,
plan: true,
+ createdAt: true,
},
},
},
@@ -64,6 +65,7 @@ export default async function handle(
id: true,
name: true,
plan: true,
+ createdAt: true,
},
});
teams.push(defaultTeam);