fix(navigation): append query parameter to bottom-nav links and enhance back navigation logic in success page
This commit is contained in:
parent
6e91315647
commit
c3cac74228
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user