import { z } from "zod";
import type { IConsent } from "../consent.interface";

export const isGrantedHandlerInputSchema = z
  .object({
    category: z.string().min(1),
  })
  .strict();

export type IsGrantedHandlerInput = z.infer<typeof isGrantedHandlerInputSchema>;

export function isGrantedHandler(
  consent: IConsent,
  input: IsGrantedHandlerInput,
): { granted: boolean } {
  return { granted: consent.isGranted(input.category) };
}
