import { protectedProcedure, resourceOverviewProcedure } from "../trpc.js";
import {
  ResourceDirectoryQuerySchema,
  ResourceListQuerySchema,
} from "./resource-read-shared.js";
import {
  ResolveResponsiblePersonNameInputSchema,
  ResourceChargeabilitySummaryInputSchema,
  ResourceSummarySnapshotInputSchema,
  getChargeabilitySummary,
  listResourceChapters,
  listResourceDirectory,
  listResourceSummaries,
  listResourceSummaryDetails,
  listStaffResourceEntries,
  resolveResponsiblePersonName,
} from "./resource-summary-read-procedure-support.js";

export const resourceSummaryReadProcedures = {
  resolveResponsiblePersonName: resourceOverviewProcedure
    .input(ResolveResponsiblePersonNameInputSchema)
    .query(({ ctx, input }) => resolveResponsiblePersonName(ctx, input)),

  getChargeabilitySummary: protectedProcedure
    .input(ResourceChargeabilitySummaryInputSchema)
    .query(({ ctx, input }) => getChargeabilitySummary(ctx, input)),

  listSummaries: resourceOverviewProcedure
    .input(ResourceSummarySnapshotInputSchema)
    .query(({ ctx, input }) => listResourceSummaries(ctx, input)),

  listSummariesDetail: resourceOverviewProcedure
    .input(ResourceSummarySnapshotInputSchema)
    .query(({ ctx, input }) => listResourceSummaryDetails(ctx, input)),

  directory: protectedProcedure
    .input(ResourceDirectoryQuerySchema)
    .query(({ ctx, input }) => listResourceDirectory(ctx, input)),

  listStaff: resourceOverviewProcedure
    .input(ResourceListQuerySchema)
    .query(({ ctx, input }) => listStaffResourceEntries(ctx, input)),

  chapters: protectedProcedure.query(({ ctx }) => listResourceChapters(ctx)),
};
