Skip to content

Commit

Permalink
Merge pull request #571 from mfts/feat/enable-full-trial
Browse files Browse the repository at this point in the history
feat: enable all functions for trial
  • Loading branch information
mfts authored Aug 28, 2024
2 parents a83ade1 + 3ecd6cf commit d3d493e
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 53 deletions.
6 changes: 6 additions & 0 deletions components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
}, []);

const userPlan = plan;
const isTrial = !!userTrial;

const navigation = [
// {
Expand Down Expand Up @@ -158,6 +159,11 @@ export const SidebarComponent = ({ className }: { className?: string }) => {
{userPlan.charAt(0).toUpperCase() + userPlan.slice(1)}
</span>
) : null}
{isTrial ? (
<span className="ml-4 rounded-sm bg-foreground px-2 py-0.5 text-xs tracking-normal text-background ring-1 ring-gray-800">
Trial
</span>
) : null}
</p>
</div>

Expand Down
8 changes: 5 additions & 3 deletions components/billing/upgrade-plan-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export function UpgradePlanModal({
const [period, setPeriod] = useState<"yearly" | "monthly">("yearly");
const [clicked, setClicked] = useState<boolean>(false);
const teamInfo = useTeam();
const { plan: teamPlan } = usePlan();
const { plan: teamPlan, trial } = usePlan();
const analytics = useAnalytics();

const isTrial = !!trial;

const features = useMemo(() => {
if (plan === "Pro") {
return [
Expand Down Expand Up @@ -291,13 +293,13 @@ export function UpgradePlanModal({
}}
>{`Upgrade to ${plan} ${capitalize(period)}`}</Button>
<div className="flex items-center justify-center space-x-2">
{plan === "Business" ? (
{plan === "Business" && !isTrial ? (
<DataroomTrialModal>
<button
className="text-center text-xs text-muted-foreground underline-offset-4 transition-all hover:text-gray-800 hover:underline hover:dark:text-muted-foreground/80"
onClick={() => analytics.capture("Dataroom Trial Clicked")}
>
Looking for a dataroom trial?
Looking for a trial?
</button>
</DataroomTrialModal>
) : (
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/agreement-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { LinkUpgradeOptions } from "./link-options";
export default function AgreementSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand Down Expand Up @@ -70,7 +70,7 @@ export default function AgreementSection({
title="Require NDA to view"
enabled={enabled}
action={handleAgreement}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="datarooms"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/allow-list-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { LinkUpgradeOptions } from "./link-options";
export default function AllowListSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand Down Expand Up @@ -77,7 +77,7 @@ export default function AllowListSection({
<LinkItem
title="Allow specified viewers"
enabled={enabled}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
action={handleEnableAllowList}
requiredPlan="business"
upgradeAction={() =>
Expand Down
7 changes: 4 additions & 3 deletions components/links/link-sheet/deny-list-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import { LinkUpgradeOptions } from "./link-options";
export default function DenyListSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;

isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand Down Expand Up @@ -77,7 +78,7 @@ export default function DenyListSection({
title="Block specified viewers"
enabled={enabled}
action={handleEnableDenyList}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="business"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/email-authentication-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { LinkUpgradeOptions } from "./link-options";
export default function EmailAuthenticationSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand Down Expand Up @@ -42,7 +42,7 @@ export default function EmailAuthenticationSection({
title="Require email verification"
enabled={enabled}
action={handleEnableAuthentication}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="pro"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
14 changes: 7 additions & 7 deletions components/links/link-sheet/link-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export default function LinkItem({
title,
enabled,
action,
hasFreePlan,
isAllowed = true,
requiredPlan,
upgradeAction,
}: {
title: string;
enabled: boolean;
action: () => void;
hasFreePlan?: boolean;
isAllowed?: boolean;
requiredPlan?: string;
upgradeAction?: () => void;
}) {
Expand All @@ -26,17 +26,17 @@ export default function LinkItem({
"cursor-pointer text-sm font-medium leading-6",
enabled ? "text-foreground" : "text-muted-foreground",
)}
onClick={hasFreePlan ? () => upgradeAction?.() : action}
onClick={isAllowed ? action : () => upgradeAction?.()}
>
{title}
{hasFreePlan && requiredPlan && <PlanBadge plan={requiredPlan} />}
{!isAllowed && requiredPlan && <PlanBadge plan={requiredPlan} />}
</h2>
</div>
<Switch
checked={enabled}
onClick={hasFreePlan ? () => upgradeAction?.() : undefined}
className={hasFreePlan ? "opacity-50" : undefined}
onCheckedChange={hasFreePlan ? undefined : action}
onClick={isAllowed ? undefined : () => upgradeAction?.()}
className={isAllowed ? undefined : "opacity-50"}
onCheckedChange={isAllowed ? action : undefined}
/>
</div>
);
Expand Down
56 changes: 39 additions & 17 deletions components/links/link-sheet/link-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ export const LinkOptions = ({
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
linkType: LinkType;
}) => {
const { plan } = usePlan();
const { plan, trial } = usePlan();
const { limits } = useLimits();
const hasFreePlan = plan === "free";
const isNotBusiness = plan !== "business";
const isNotDatarooms = plan !== "datarooms";

const isTrial = !!trial;
const isPro = plan === "pro";
const isBusiness = plan === "business";
const isDatarooms = plan === "datarooms";
const allowAdvancedLinkControls = limits
? limits?.advancedLinkControlsOnPro
: false;

const [openUpgradeModal, setOpenUpgradeModal] = useState<boolean>(false);
const [trigger, setTrigger] = useState<string>("");
Expand Down Expand Up @@ -70,56 +75,73 @@ export const LinkOptions = ({
<ExpirationSection {...{ data, setData }} />
<OGSection
{...{ data, setData }}
hasFreePlan={
isNotBusiness && isNotDatarooms && !limits?.advancedLinkControlsOnPro
isAllowed={
isTrial ||
(isPro && allowAdvancedLinkControls) ||
isBusiness ||
isDatarooms
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>

<EmailAuthenticationSection
{...{ data, setData }}
hasFreePlan={hasFreePlan}
isAllowed={isTrial || isPro || isBusiness || isDatarooms}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
<AllowListSection
{...{ data, setData }}
hasFreePlan={
isNotBusiness && isNotDatarooms && !limits?.advancedLinkControlsOnPro
isAllowed={
isTrial ||
(isPro && allowAdvancedLinkControls) ||
isBusiness ||
isDatarooms
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
<DenyListSection
{...{ data, setData }}
hasFreePlan={
isNotBusiness && isNotDatarooms && !limits?.advancedLinkControlsOnPro
isAllowed={
isTrial ||
(isPro && allowAdvancedLinkControls) ||
isBusiness ||
isDatarooms
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
<PasswordSection {...{ data, setData }} />
<ScreenshotProtectionSection
{...{ data, setData }}
hasFreePlan={
isNotBusiness && isNotDatarooms && !limits?.advancedLinkControlsOnPro
isAllowed={
isTrial ||
(isPro && allowAdvancedLinkControls) ||
isBusiness ||
isDatarooms
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
<FeedbackSection {...{ data, setData }} />
<QuestionSection
{...{ data, setData }}
hasFreePlan={
isNotBusiness && isNotDatarooms && !limits?.advancedLinkControlsOnPro
isAllowed={
isTrial ||
(isPro && allowAdvancedLinkControls) ||
isBusiness ||
isDatarooms
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
<AgreementSection
{...{ data, setData }}
hasFreePlan={isNotDatarooms}
isAllowed={isTrial || isDatarooms}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
{linkType === LinkType.DOCUMENT_LINK ? (
<ProBannerSection
{...{ data, setData }}
hasFreePlan={hasFreePlan || plan === "starter"}
isAllowed={
isTrial || isPro || isBusiness || isDatarooms || plan === "starter"
}
handleUpgradeStateChange={handleUpgradeStateChange}
/>
) : null}
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/og-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import { LinkUpgradeOptions } from "./link-options";
export default function OGSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function OGSection({
title="Custom social media cards"
enabled={enableCustomMetatag}
action={handleCustomMetatag}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="Business"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/pro-banner-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { LinkUpgradeOptions } from "./link-options";
export function ProBannerSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand All @@ -39,7 +39,7 @@ export function ProBannerSection({
title="Show Visitor Statistics & Papermark Branding"
enabled={enabled}
action={handleShowBanner}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="pro"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/question-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { LinkUpgradeOptions } from "./link-options";
export default function QuestionSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand All @@ -53,7 +53,7 @@ export default function QuestionSection({
title="Feedback Question"
enabled={enabled}
action={handleQuestion}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="business"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
6 changes: 3 additions & 3 deletions components/links/link-sheet/screenshot-protection-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { LinkUpgradeOptions } from "./link-options";
export default function ScreenshotProtectionSection({
data,
setData,
hasFreePlan,
isAllowed,
handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
hasFreePlan: boolean;
isAllowed: boolean;
handleUpgradeStateChange: ({
state,
trigger,
Expand Down Expand Up @@ -41,7 +41,7 @@ export default function ScreenshotProtectionSection({
title="Enable screenshot protection"
enabled={enabled}
action={handleEnableScreenshotProtection}
hasFreePlan={hasFreePlan}
isAllowed={isAllowed}
requiredPlan="business"
upgradeAction={() =>
handleUpgradeStateChange({
Expand Down
3 changes: 2 additions & 1 deletion components/welcome/dataroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export default function Dataroom() {
Get a data room trial
</Button>
<span className="text-xs text-muted-foreground">
Data rooms are available on our `Business` plan. <br />
Data rooms are available on our `Business` and `Data Rooms` plan.{" "}
<br />
You receive a 7-day trial.
</span>
</motion.div>
Expand Down
Loading

0 comments on commit d3d493e

Please sign in to comment.