fix(navigation): append query parameter to bottom-nav links and enhance back navigation logic in success page

This commit is contained in:
vchikalkin 2025-07-18 16:33:24 +03:00
parent 6e91315647
commit c3cac74228
2 changed files with 18 additions and 8 deletions

View File

@ -27,7 +27,7 @@ export function NavButton({ disabled, href, icon, label }: NavButtonProps) {
<span className="mt-1 text-xs">{label}</span>
</div>
) : (
<Link href={href}>
<Link href={href + '?from=bottom-nav'}>
<span>{icon}</span>
<span className="mt-1 text-xs">{label}</span>
</Link>

View File

@ -3,8 +3,8 @@
import { useOrderStore } from '@/stores/order';
import { Button } from '@repo/ui/components/ui/button';
import { Card, CardContent } from '@repo/ui/components/ui/card';
import { AlertCircle, CheckCircle2, Home, RefreshCw } from 'lucide-react';
import Link from 'next/link';
import { AlertCircle, CheckCircle2, RefreshCw } from 'lucide-react';
import { useRouter, useSearchParams } from 'next/navigation';
export function ErrorPage() {
const setStep = useOrderStore((store) => store.setStep);
@ -35,6 +35,19 @@ export function ErrorPage() {
}
export function SuccessPage() {
const router = useRouter();
const from = useSearchParams().get('from');
const handleBack = () => {
if (from === 'bottom-nav') {
router.push('/');
} else if (window.history.length > 1) {
router.back();
} else {
router.push('/');
}
};
return (
<div className="flex min-h-screen items-center justify-center bg-background p-4">
<Card className="w-full max-w-sm border-none bg-card text-card-foreground shadow-none">
@ -46,11 +59,8 @@ export function SuccessPage() {
<h1 className="text-2xl font-bold">Готово!</h1>
<p className="text-muted-foreground">Запись успешно создана</p>
</div>
<Button asChild className="w-full">
<Link href="/">
<Home className="mr-2 size-4" />
На главный экран
</Link>
<Button className="w-full" onClick={handleBack}>
ОК
</Button>
</CardContent>
</Card>