import React from "react";
import { ResolverProps } from "@/validations/mutual/resolvers/validations";
import { retrievePageToRender } from "@/hooks/application/hook";
import { ContentProps } from "@/validations/mutual/dashboard/props";

import pageIndexMulti from "@/pages/multi/index";
import pageIndexSingle from "@/pages/single/index";

function resolveWhichPageToRenderSingle({
    activePageUrl,
}: ResolverProps): React.FC<ContentProps> {
    const ApplicationToRender = pageIndexSingle[activePageUrl]
    return ApplicationToRender
}

async function resolveWhichPageToRenderMulti({
    activePageUrl,
}: ResolverProps): Promise<React.FC<ContentProps> | null> {
    const pageToRender = await retrievePageToRender(activePageUrl)        // TODO: Retrieve page to render
    try {
        const ApplicationToRender = pageIndexMulti[activePageUrl][pageToRender]
        return ApplicationToRender
    } catch (error) {
        console.error(error)
    }
    return null
}

export { resolveWhichPageToRenderSingle, resolveWhichPageToRenderMulti };
