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

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

export type WithdrawHandlerInput = z.infer<typeof withdrawHandlerInputSchema>;

export async function withdrawHandler(
  consent: IConsent,
  input: WithdrawHandlerInput,
): Promise<{ success: true }> {
  await consent.withdraw(input.category);
  return { success: true };
}
