import { router } from "@repo/core-shared/trpc/init";

import { marketingPagesContainer } from "../../di/container";
import { MARKETING_PAGES_SYMBOLS } from "../../di/symbols";

import { getPageBySlugInputSchema } from "../../application/use-cases/get-page-by-slug.use-case";
import { getSiteSettingsInputSchema } from "../../application/use-cases/get-site-settings.use-case";

import type { IGetPageBySlugController } from "../../interface-adapters/controllers/get-page-by-slug.controller";
import type { IGetSiteSettingsController } from "../../interface-adapters/controllers/get-site-settings.controller";

import { marketingPagesProcedure } from "./procedures";

export const marketingPagesRouter = router({
  pageBySlug: marketingPagesProcedure
    .input(getPageBySlugInputSchema)
    .query(({ input }) => {
      const ctrl = marketingPagesContainer.get<IGetPageBySlugController>(
        MARKETING_PAGES_SYMBOLS.IGetPageBySlugController,
      );
      return ctrl(input);
    }),

  siteSettings: marketingPagesProcedure
    .input(getSiteSettingsInputSchema)
    .query(({ input }) => {
      const ctrl = marketingPagesContainer.get<IGetSiteSettingsController>(
        MARKETING_PAGES_SYMBOLS.IGetSiteSettingsController,
      );
      return ctrl(input);
    }),
});

export type MarketingPagesRouter = typeof marketingPagesRouter;
