feat(login): add redirect parameter to login links for better user experience
This commit is contained in:
@@ -26,7 +26,7 @@ export default async function Dashboard({ searchParams }) {
|
||||
|
||||
if (!ability.can("access", "Dashboard") || !token) {
|
||||
removeToken();
|
||||
return redirect("/login");
|
||||
return redirect("/login?redirect=/dashboard");
|
||||
}
|
||||
|
||||
// The userInfo cookie holds the real user uuid; the standalone `uuid` cookie
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams, useRouter, useSearchParams } from "next/navigation";
|
||||
import { useParams, usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { request } from "@/services/response";
|
||||
import { formatToman } from "@/lib/money";
|
||||
import Cookies from "js-cookie";
|
||||
@@ -10,6 +10,7 @@ import Layout from "@/components/layout";
|
||||
export default function PaymentDetailsPage() {
|
||||
const params = useParams();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const [payment, setPayment] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -32,7 +33,7 @@ export default function PaymentDetailsPage() {
|
||||
// بررسی لاگین بودن کاربر
|
||||
const userInfo = Cookies.get("userInfo");
|
||||
if (!userInfo) {
|
||||
router.push("/login");
|
||||
router.push(`/login?redirect=${encodeURIComponent(pathname)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ export default function PaymentDetailsPage() {
|
||||
if (params.uuid) {
|
||||
fetchPaymentDetails();
|
||||
}
|
||||
}, [params.uuid, router]);
|
||||
}, [params.uuid, router, pathname]);
|
||||
|
||||
// پس از دیدن جزئیاتِ پرداختِ موفق، خودکار به تاریخچهٔ نوبتها (تب تأییدشده) برو.
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user