'use client'; import { ReactNode, useEffect, useState } from 'react'; import Sidebar from './sidebar'; import { usePathname } from 'next/navigation'; import { getCustomer } from '../../../actions/billing.actions'; import { Button } from '@heroui/react'; import { useRouter } from 'next/navigation'; interface AppLayoutProps { children: ReactNode; useAuth?: boolean; useBilling?: boolean; } export default function AppLayout({ children, useAuth = false, useBilling = false }: AppLayoutProps) { const router = useRouter(); const [sidebarCollapsed, setSidebarCollapsed] = useState(true); const [billingPastDue, setBillingPastDue] = useState(false); const pathname = usePathname(); let projectId: string | null = null; if (pathname.startsWith('/projects')) { projectId = pathname.split('/')[2]; } useEffect(() => { async function checkBillingPastDue() { const billingCustomer = await getCustomer(); if (billingCustomer.subscriptionStatus === "past_due") { setBillingPastDue(true); } } if (!useBilling) { return; } checkBillingPastDue(); }, [useBilling]); // Layout with sidebar for all routes return (