import { z } from 'zod'; import { USER_REACTION } from '../../constants'; import { PresentationSchema } from '../../models/presentation'; export namespace SetReactionToPresentationCommand { export const RequestSchema = z.object({ uuid: z.string().uuid(), }); export type Request = z.infer; export const RequestBodySchema = z .object({ reaction: z.nativeEnum(USER_REACTION).nullable(), dislikeReason: z.string().nullable().default(null), }) .refine( (data) => { if (data.reaction !== USER_REACTION.DISLIKED && data.dislikeReason) { return false; } return true; }, { message: 'Dislike reason is not allowed when reaction is not DISLIKED', }, ); export type RequestParams = z.infer; export const ResponseSchema = z.object({ data: PresentationSchema, }); export type Response = z.infer; }