fix mini app bot father
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { Copy, ImageIcon, LayoutGrid, Loader2, RefreshCw, TextQuote, UserCircle2 } from 'lucide-react';
|
||||
import { Copy, ImageIcon, LayoutGrid, Loader2, RefreshCw, TextQuote, UserCircle2, ArrowLeft } from 'lucide-react';
|
||||
import { usePublicSettings } from '@/components/id/public-settings-provider';
|
||||
import { useToast } from '@/components/id/toast-provider';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -75,9 +75,17 @@ function SectionCard({
|
||||
);
|
||||
}
|
||||
|
||||
export function BotManageMiniAppContent() {
|
||||
export function BotManageMiniAppContent({
|
||||
botId: botIdProp,
|
||||
onBack,
|
||||
botHint
|
||||
}: {
|
||||
botId?: string;
|
||||
onBack?: () => void;
|
||||
botHint?: string;
|
||||
} = {}) {
|
||||
const searchParams = useSearchParams();
|
||||
const botId = searchParams.get('botId') ?? '';
|
||||
const botId = botIdProp ?? searchParams.get('botId') ?? '';
|
||||
const { projectName } = usePublicSettings();
|
||||
const { effectiveToken, canUse: canUseSession, authReady, waitingForBridge, isLoading } = useMiniAppAuth();
|
||||
const { showToast } = useToast();
|
||||
@@ -239,8 +247,20 @@ export function BotManageMiniAppContent() {
|
||||
<div className="min-h-screen bg-[#f4f5f8] p-4 pb-8">
|
||||
<div className="mx-auto max-w-lg space-y-4">
|
||||
<div className="rounded-[24px] bg-white p-5 shadow-sm">
|
||||
<h1 className="text-lg font-semibold">Настройки бота</h1>
|
||||
<p className="text-sm text-[#667085]">Интерактивное управление профилем — аналог команд BotFather</p>
|
||||
<div className="flex items-start gap-3">
|
||||
{onBack ? (
|
||||
<Button type="button" variant="ghost" size="icon" className="mt-0.5 h-9 w-9 shrink-0" onClick={onBack}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
) : null}
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold">Настройки бота</h1>
|
||||
<p className="text-sm text-[#667085]">
|
||||
{botHint ? `@${botHint.replace(/_bot$/i, '')}_bot · ` : ''}
|
||||
Полное управление как в BotFather
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
|
||||
@@ -1,20 +1,40 @@
|
||||
import { Suspense } from 'react';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { BotManageMiniAppContent } from './content';
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
function BotManageLegacyRedirectContent() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const botId = searchParams.get('botId');
|
||||
|
||||
useEffect(() => {
|
||||
const target = botId
|
||||
? `/mini-apps/bot-father?botId=${encodeURIComponent(botId)}`
|
||||
: '/mini-apps/bot-father';
|
||||
router.replace(target);
|
||||
}, [botId, router]);
|
||||
|
||||
function BotManageFallback() {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center p-6 text-sm text-[#667085]">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
Загрузка Mini App...
|
||||
Перенаправление...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function BotManageMiniAppPage() {
|
||||
export default function BotManageLegacyRedirectPage() {
|
||||
return (
|
||||
<Suspense fallback={<BotManageFallback />}>
|
||||
<BotManageMiniAppContent />
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="flex min-h-screen items-center justify-center p-6 text-sm text-[#667085]">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<BotManageLegacyRedirectContent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user