import { A, buildContract } from '@jig-software/trest-core';
import { z } from 'zod';

export const AttendanceReportInit = z.object({
  year: z.number().int(),
  month: z.number().int(),
});

export const exportContract = buildContract((c) =>
  c
    .prefix('/export')
    .parse((p) => p.error.text(400))
    .endpoints({
      downloadAttendanceReport: (e) =>
        e
          .method('GET')
          .path('/attendance-report')
          .prepare((p) => p.query(AttendanceReportInit).annotate<[init: A]>())
          .parse((p) => p.success.file(200)),
    }),
);
