/**
 * App Component - Main admin application shell
 */

import OrdersPage from '../pages/Orders';
import CustomersPage from '../pages/Customers';
import ProductsPage from '../pages/Products';
import FormsPage from '../pages/Forms';
import CouponsPage from '../pages/Coupons';
import AccessPage from '../pages/Access';
import LicensesPage from '../pages/Licenses';

const pageComponents = {
    orders: OrdersPage,
    customers: CustomersPage,
    products: ProductsPage,
    forms: FormsPage,
    coupons: CouponsPage,
    access: AccessPage,
    licenses: LicensesPage,
};

export default function App({ page, initialData }) {
    const PageComponent = pageComponents[page];

    if (!PageComponent) {
        return (
            <div className="formipay-error">
                <p>Unknown page: {page}</p>
            </div>
        );
    }

    return (
        <div className="formipay-admin-wrap">
            <PageComponent initialData={initialData} />
        </div>
    );
}
