mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
cloud trial refactor
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Alert } from "@mantine/core";
|
import { Alert } from "@mantine/core";
|
||||||
import { useBillingQuery } from "@/ee/billing/queries/billing-query.ts";
|
import { useBillingQuery } from "@/ee/billing/queries/billing-query.ts";
|
||||||
import useTrial from "@/ee/hooks/use-trial.tsx";
|
import useTrial from "@/ee/hooks/use-trial.tsx";
|
||||||
|
import { getBillingTrialDays } from '@/lib/config.ts';
|
||||||
|
|
||||||
export default function BillingTrial() {
|
export default function BillingTrial() {
|
||||||
const { data: billing, isLoading } = useBillingQuery();
|
const { data: billing, isLoading } = useBillingQuery();
|
||||||
@@ -15,14 +16,14 @@ export default function BillingTrial() {
|
|||||||
{trialDaysLeft > 0 && !billing && (
|
{trialDaysLeft > 0 && !billing && (
|
||||||
<Alert title="Your Trial is Active 🎉" color="blue" radius="md">
|
<Alert title="Your Trial is Active 🎉" color="blue" radius="md">
|
||||||
You have {trialDaysLeft} {trialDaysLeft === 1 ? "day" : "days"} left
|
You have {trialDaysLeft} {trialDaysLeft === 1 ? "day" : "days"} left
|
||||||
in your 7-day trial. Please subscribe to a plan before your trial
|
in your {getBillingTrialDays()}-day free trial. Please subscribe to a paid plan before your trial
|
||||||
ends.
|
ends.
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{trialDaysLeft === 0 && (
|
{trialDaysLeft === 0 && (
|
||||||
<Alert title="Your Trial has ended" color="red" radius="md">
|
<Alert title="Your Trial has ended" color="red" radius="md">
|
||||||
Your 7-day trial has come to an end. Please subscribe to a plan to
|
Your {getBillingTrialDays()}-day free trial has come to an end. Please subscribe to a paid plan to
|
||||||
continue using this service.
|
continue using this service.
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import { isCloud } from "@/lib/config.ts";
|
import { getBillingTrialDays, isCloud } from "@/lib/config.ts";
|
||||||
import APP_ROUTE from "@/lib/app-route.ts";
|
import APP_ROUTE from "@/lib/app-route.ts";
|
||||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
@@ -18,7 +18,7 @@ export const useTrialEndAction = () => {
|
|||||||
notifications.show({
|
notifications.show({
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
color: "red",
|
color: "red",
|
||||||
title: "Your 7-day trial has ended",
|
title: `Your ${getBillingTrialDays()}-day trial has ended`,
|
||||||
message:
|
message:
|
||||||
"Please upgrade to a paid plan or contact your workspace admin.",
|
"Please upgrade to a paid plan or contact your workspace admin.",
|
||||||
autoClose: false,
|
autoClose: false,
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ export function getDrawioUrl() {
|
|||||||
return getConfigValue("DRAWIO_URL", "https://embed.diagrams.net");
|
return getConfigValue("DRAWIO_URL", "https://embed.diagrams.net");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getBillingTrialDays() {
|
||||||
|
return getConfigValue("BILLING_TRIAL_DAYS");
|
||||||
|
}
|
||||||
|
|
||||||
function getConfigValue(key: string, defaultValue: string = undefined): string {
|
function getConfigValue(key: string, defaultValue: string = undefined): string {
|
||||||
const rawValue = import.meta.env.DEV
|
const rawValue = import.meta.env.DEV
|
||||||
? process?.env?.[key]
|
? process?.env?.[key]
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
CLOUD,
|
CLOUD,
|
||||||
SUBDOMAIN_HOST,
|
SUBDOMAIN_HOST,
|
||||||
COLLAB_URL,
|
COLLAB_URL,
|
||||||
|
BILLING_TRIAL_DAYS,
|
||||||
} = loadEnv(mode, envPath, "");
|
} = loadEnv(mode, envPath, "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -23,6 +24,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
CLOUD,
|
CLOUD,
|
||||||
SUBDOMAIN_HOST,
|
SUBDOMAIN_HOST,
|
||||||
COLLAB_URL,
|
COLLAB_URL,
|
||||||
|
BILLING_TRIAL_DAYS,
|
||||||
},
|
},
|
||||||
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: d3095f2d8b...4e7319ab01
@@ -42,6 +42,9 @@ export class StaticModule implements OnModuleInit {
|
|||||||
? this.environmentService.getSubdomainHost()
|
? this.environmentService.getSubdomainHost()
|
||||||
: undefined,
|
: undefined,
|
||||||
COLLAB_URL: this.environmentService.getCollabUrl(),
|
COLLAB_URL: this.environmentService.getCollabUrl(),
|
||||||
|
BILLING_TRIAL_DAYS: this.environmentService.isCloud()
|
||||||
|
? this.environmentService.getBillingTrialDays()
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user