"use client";
import { Suspense, useEffect, useState } from "react";
import AccountStatementPage from "./accountStatement";
import { useRouter } from "next/navigation";

export default function AccountStatement() {
    const [authorized, SetAuthorized] = useState<boolean | null>(null);
    const router = useRouter();
    useEffect(() => {
        const token = localStorage.getItem("access_token");
        if (!token) {
            SetAuthorized(false);
            router.push("/login");
        }
        else {
            SetAuthorized(true);
        }
    }, []);
    if (authorized) {
        return (
            <Suspense fallback={<div>Loading...</div>}>
                <AccountStatementPage />
            </Suspense>
        );
    }
}


