From 4336cf5e6056c6eb0a11420de5bbe3921e6a10f6 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 2 Sep 2025 16:55:41 +0300 Subject: [PATCH] feat(env): add BOT_URL to environment variables and update related configurations - Introduced BOT_URL to the environment schema for enhanced configuration management. - Updated turbo.json to include BOT_URL in the environment variables list. - Modified subscription-bar.tsx to improve user messaging for subscription availability. --- apps/web/app/(main)/pro/page.tsx | 73 +++++++++++++++++++ .../components/profile/subscription-bar.tsx | 2 +- apps/web/components/subscription/index.ts | 1 + .../subscription/try-free-button.tsx | 25 +++++++ apps/web/config/env.ts | 2 +- turbo.json | 9 ++- 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 apps/web/app/(main)/pro/page.tsx create mode 100644 apps/web/components/subscription/index.ts create mode 100644 apps/web/components/subscription/try-free-button.tsx diff --git a/apps/web/app/(main)/pro/page.tsx b/apps/web/app/(main)/pro/page.tsx new file mode 100644 index 0000000..680fe26 --- /dev/null +++ b/apps/web/app/(main)/pro/page.tsx @@ -0,0 +1,73 @@ +import { getSubscription } from '@/actions/api/subscriptions'; +import { getSessionUser } from '@/actions/session'; +import { TryFreeButton } from '@/components/subscription'; +import { env } from '@/config/env'; +import { Button } from '@repo/ui/components/ui/button'; +import { ArrowRight, Crown } from 'lucide-react'; + +export default async function ProPage() { + const { telegramId } = await getSessionUser(); + const subscriptionData = await getSubscription({ telegramId }); + + // Простая логика для проверки статуса подписки + const subscription = subscriptionData?.subscription; + const isActive = + subscription?.isActive && + subscription?.expiresAt && + new Date() < new Date(subscription.expiresAt); + + // Проверка возможности использования пробного периода + const hasUsedTrial = subscription?.subscriptionHistories?.some( + (item) => item && item.period === 'trial' && item.state === 'success', + ); + const canUseTrial = !isActive && !hasUsedTrial; + + return ( +
+ {/* Hero Section */} +
+
+
+
+
+
+ +
+
+
+ +

+ Подписка{' '} + + Pro + +

+ +

+ {isActive + ? 'Ваша подписка Pro активна! Доступно неограниченное количество записей' + : 'Разблокируйте неограниченное количество записей в месяц'} +

+ + {!isActive && ( + + )} +
+
+
+ ); +} diff --git a/apps/web/components/profile/subscription-bar.tsx b/apps/web/components/profile/subscription-bar.tsx index 8546dcb..5172c43 100644 --- a/apps/web/components/profile/subscription-bar.tsx +++ b/apps/web/components/profile/subscription-bar.tsx @@ -24,7 +24,7 @@ export function SubscriptionInfoBar() { } if (!isLoading && remainingOrdersCount && maxOrdersPerMonth) { - description = `Осталось ${remainingOrdersCount} из ${maxOrdersPerMonth} записей в этом месяце`; + description = `Доступно ${remainingOrdersCount} из ${maxOrdersPerMonth} записей в этом месяце`; } return ( diff --git a/apps/web/components/subscription/index.ts b/apps/web/components/subscription/index.ts new file mode 100644 index 0000000..db73aba --- /dev/null +++ b/apps/web/components/subscription/index.ts @@ -0,0 +1 @@ +export * from './try-free-button'; diff --git a/apps/web/components/subscription/try-free-button.tsx b/apps/web/components/subscription/try-free-button.tsx new file mode 100644 index 0000000..e89f6ba --- /dev/null +++ b/apps/web/components/subscription/try-free-button.tsx @@ -0,0 +1,25 @@ +'use client'; + +import { Button } from '@repo/ui/components/ui/button'; +import { Sparkles } from 'lucide-react'; + +type TryFreeButtonProps = { + readonly className?: string; + readonly size?: 'default' | 'lg'; +}; + +export function TryFreeButton({ className = '', size = 'lg' }: TryFreeButtonProps) { + // eslint-disable-next-line unicorn/consistent-function-scoping + const handleTryFree = () => {}; + + return ( + + ); +} diff --git a/apps/web/config/env.ts b/apps/web/config/env.ts index 39fa01a..d9cf351 100644 --- a/apps/web/config/env.ts +++ b/apps/web/config/env.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; export const envSchema = z.object({ __DEV_TELEGRAM_ID: z.string().default(''), - BOT_TOKEN: z.string(), + BOT_URL: z.string(), }); export const env = envSchema.parse(process.env); diff --git a/turbo.json b/turbo.json index c027a66..cb8cd93 100644 --- a/turbo.json +++ b/turbo.json @@ -6,7 +6,14 @@ "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", ".env*"], "outputs": [".next/**", "!.next/cache/**"], - "env": ["URL_GRAPHQL", "PASSWORD_GRAPHQL", "LOGIN_GRAPHQL", "BOT_TOKEN", "NEXTAUTH_SECRET"] + "env": [ + "URL_GRAPHQL", + "PASSWORD_GRAPHQL", + "LOGIN_GRAPHQL", + "BOT_TOKEN", + "NEXTAUTH_SECRET", + "BOT_URL" + ] }, "lint": { "dependsOn": ["^lint"]