fix auth
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
} from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Clipboard, Truck, Package } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
interface Order {
|
||||
orderId: string;
|
||||
@@ -49,6 +50,8 @@ export default function OrderDetailsPage() {
|
||||
const [productNames, setProductNames] = useState<Record<string, string>>({});
|
||||
const [isPaid, setIsPaid] = useState(false);
|
||||
|
||||
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
const orderId = params?.id;
|
||||
|
||||
@@ -110,6 +113,7 @@ export default function OrderDetailsPage() {
|
||||
setIsPaid(true);
|
||||
}
|
||||
} catch (err: any) {
|
||||
router.push("/dashboard/orders");
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Dashboard from "@/components/kokonutui/dashboard";
|
||||
import { Package } from "lucide-react";
|
||||
import OrderTable from "@/components/order-table"
|
||||
import OrderTable from "@/components/order-table";
|
||||
|
||||
export default function OrdersPage() {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const authToken = document.cookie
|
||||
.split("; ")
|
||||
.find((row) => row.startsWith("Authorization="))
|
||||
?.split("=")[1];
|
||||
|
||||
if (!authToken) {
|
||||
router.push("/login");
|
||||
}
|
||||
}, [router]);
|
||||
|
||||
return (
|
||||
<Dashboard>
|
||||
<div className="space-y-6">
|
||||
@@ -13,9 +30,8 @@ export default function OrdersPage() {
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{/* ✅ Order Table Component */}
|
||||
<OrderTable />
|
||||
</div>
|
||||
</Dashboard>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user