
import Client, { IClientArgs } from "./Client";
import { IFacetValue, IPageContent, ISearchResponse, ISection } from "./Types";

export interface IHomePageProps {
    sections: ISection[];
    metadata: Record<string, any>;
    groups: Record<string, ISection>;
}

export type IContentPageProps = IPageContent;

export interface ISearchPageProps {
    sections: ISection[];
    loading: boolean;
    facets: Record<string, IFacetValue[]>;
    response: ISearchResponse;
}

export class Core {
    public client: Client;

    constructor(args: IClientArgs) {
        this.client = new Client(args);
    }

    public async getHomePageData(): Promise<IHomePageProps> {
        const sections = await this.client.content.getSections();
        const groups = await this.client.content.getAllGroups();
        const metadata = { };
        return { sections, metadata, groups };
    }

}
