bot(priceButtons): продлить/доступ

This commit is contained in:
vchikalkin 2025-09-18 19:41:05 +03:00
parent 29ecc47822
commit 3e0ac818f2

View File

@ -40,7 +40,11 @@ export async function subscription(conversation: Conversation<Context, Context>,
const prices = sift(subscriptionPrices);
// строим клавиатуру с указанием даты окончания после покупки
const keyboard = buildPricesKeyboard(prices, currentSubscription?.expiresAt);
const keyboard = buildPricesKeyboard(
prices,
currentSubscription?.expiresAt,
hasActiveSubscription,
);
// сообщение с выбором плана
const messageWithPrices = await ctx.reply(
@ -123,6 +127,7 @@ function addDays(date: Date, days: number) {
function buildPricesKeyboard(
prices: GQL.SubscriptionPriceFieldsFragment[],
currentExpiresAt?: string,
hasActiveSubscription = false,
) {
const keyboard = new InlineKeyboard();
const baseTime = currentExpiresAt
@ -138,7 +143,7 @@ function buildPricesKeyboard(
keyboard.row({
callback_data: price.period,
pay: true,
text: `Продлить до ${targetDateRu} (${formatMoney(price.amount)})`,
text: `${hasActiveSubscription ? 'Продлить' : 'Доступ'} до ${targetDateRu} (${formatMoney(price.amount)})`,
});
}