import { getRoute } from "@/router/methods/get-route";

export async function checkPagePrerequisites(pageName) {
    const route = getRoute(pageName);

    if (!route) {
        return false;
    }

    let component = route.components;

    // Virtual routes have no component, so skip check.
    if (!component) {
        return true;
    }

    if (component?.default?.methods === undefined) {
        component = await component?.default();
    }

    return component?.default?.methods?.arePagePrerequisitesValid();
}
