import { z } from 'zod';

import { type LokaliseTFunction } from 'src/utils/i18n';

const autocompleteOptionSchema = z.object({
  label: z.string(),
  value: z.union([z.string(), z.number()]),
});

export const createKudosFormSchema = (t: LokaliseTFunction) =>
  z.object({
    acknowledgeds: z
      .array(autocompleteOptionSchema)
      .min(1, t('validations:not_empty')),
    categoryId: autocompleteOptionSchema
      .nullable()
      .refine(val => val !== null, {
        message: t('validations:not_empty'),
      }),
    body: z.string().min(1, t('validations:not_empty')),
    attachments: z.array(z.any()).default([]),
  });
