arbret/frontend/app/page.tsx
counterweight d6002b0cfc
Phase 3.3: Add Admin Trades page
New /admin/trades page for managing exchange trades:
- Upcoming trades tab with user contact info
- History tab with status/user search filters
- Complete/No-show/Cancel actions for admin
- Trade details: direction, amounts, rates, premium

Update navigation:
- Admin home redirects to /admin/trades
- Regular user home redirects to /exchange
- Header shows 'Trades' for admin
2025-12-22 20:06:16 +01:00

39 lines
950 B
TypeScript

"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useAuth } from "./auth-context";
import { layoutStyles } from "./styles/shared";
import constants from "../../shared/constants.json";
const { ADMIN, REGULAR } = constants.roles;
export default function Home() {
const { user, isLoading, hasRole } = useAuth();
const router = useRouter();
useEffect(() => {
if (isLoading) return;
if (!user) {
router.replace("/login");
return;
}
// Redirect based on role
if (hasRole(ADMIN)) {
router.replace("/admin/trades");
} else if (hasRole(REGULAR)) {
router.replace("/exchange");
} else {
// User with no roles - redirect to login
router.replace("/login");
}
}, [user, isLoading, hasRole, router]);
return (
<main style={layoutStyles.main}>
<div style={layoutStyles.loader}>Redirecting...</div>
</main>
);
}