104 lines
4.0 KiB
TypeScript
104 lines
4.0 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
// ── Holiday Schemas ──
|
|
|
|
export const createHolidaySchema = z.object({
|
|
holidayDate: z.string().min(1, 'Holiday date is required'),
|
|
holidayName: z.string().min(1, 'Holiday name is required').max(255, 'Holiday name too long'),
|
|
description: z.string().max(1000, 'Description too long').optional(),
|
|
holidayType: z.enum(['NATIONAL', 'REGIONAL', 'ORGANIZATIONAL', 'OPTIONAL']).optional(),
|
|
isRecurring: z.boolean().optional(),
|
|
});
|
|
|
|
export const updateHolidaySchema = createHolidaySchema.partial();
|
|
|
|
export const holidayParamsSchema = z.object({
|
|
holidayId: z.string().uuid('Invalid holiday ID'),
|
|
});
|
|
|
|
export const calendarParamsSchema = z.object({
|
|
year: z.string().regex(/^\d{4}$/, 'Year must be a 4-digit number'),
|
|
});
|
|
|
|
// ── Configuration Schemas ──
|
|
|
|
export const configKeyParamsSchema = z.object({
|
|
configKey: z.string().min(1, 'Config key is required').max(100, 'Config key too long'),
|
|
});
|
|
|
|
export const updateConfigSchema = z.object({
|
|
configValue: z.union([z.string(), z.number(), z.boolean(), z.record(z.any())]),
|
|
});
|
|
|
|
// ── User Role Management Schemas ──
|
|
|
|
export const assignRoleSchema = z.object({
|
|
email: z.string().email('Valid email is required'),
|
|
role: z.enum(['USER', 'MANAGEMENT', 'ADMIN'], {
|
|
errorMap: () => ({ message: 'Role must be USER, MANAGEMENT, or ADMIN' }),
|
|
}),
|
|
});
|
|
|
|
export const updateRoleSchema = z.object({
|
|
role: z.enum(['USER', 'MANAGEMENT', 'ADMIN'], {
|
|
errorMap: () => ({ message: 'Role must be USER, MANAGEMENT, or ADMIN' }),
|
|
}),
|
|
});
|
|
|
|
export const userIdParamsSchema = z.object({
|
|
userId: z.string().uuid('Invalid user ID'),
|
|
});
|
|
|
|
// ── Activity Type Schemas ──
|
|
|
|
export const createActivityTypeSchema = z.object({
|
|
title: z.string().min(1, 'Title is required').max(255, 'Title too long'),
|
|
itemCode: z.string().max(50, 'Item code too long').optional(),
|
|
taxationType: z.enum(['GST', 'Non GST'], {
|
|
errorMap: () => ({ message: 'Taxation type must be GST or Non GST' }),
|
|
}),
|
|
sapRefNo: z.string().min(1, 'SAP ref number (Claim Document Type) is required').max(50, 'SAP ref number too long'),
|
|
creditPostingOn: z.enum(['Spares', 'Vehicle', 'GMA', 'Apparel'], {
|
|
errorMap: () => ({ message: 'Credit posting on must be Spares, Vehicle, GMA or Apparel' }),
|
|
}),
|
|
});
|
|
|
|
export const updateActivityTypeSchema = createActivityTypeSchema.partial();
|
|
|
|
export const activityTypeParamsSchema = z.object({
|
|
activityTypeId: z.string().uuid('Invalid activity type ID'),
|
|
});
|
|
|
|
// ── Form 16 Configuration Schemas ──
|
|
|
|
const notificationItemSchema = z.object({
|
|
enabled: z.boolean(),
|
|
template: z.string().optional(),
|
|
});
|
|
|
|
const notification26AsSchema = z.object({
|
|
enabled: z.boolean(),
|
|
templateRe: z.string().optional(),
|
|
templateDealers: z.string().optional(),
|
|
});
|
|
|
|
export const updateForm16ConfigSchema = z.object({
|
|
submissionViewerEmails: z.array(z.string().email()).optional(),
|
|
twentySixAsViewerEmails: z.array(z.string().email()).optional(),
|
|
reminderEnabled: z.boolean().optional(),
|
|
reminderDays: z.number().int().min(0).optional(),
|
|
notification26AsDataAdded: notification26AsSchema.optional(),
|
|
notificationForm16SuccessCreditNote: notificationItemSchema.optional(),
|
|
notificationForm16Unsuccessful: notificationItemSchema.optional(),
|
|
alertSubmitForm16Enabled: z.boolean().optional(),
|
|
alertSubmitForm16FrequencyDays: z.number().int().min(0).optional(),
|
|
alertSubmitForm16FrequencyHours: z.number().int().min(0).optional(),
|
|
alertSubmitForm16RunAtTime: z.string().regex(/^(\d{1,2}:\d{2})?$/, 'Time must be in HH:mm format').optional(),
|
|
alertSubmitForm16Template: z.string().optional(),
|
|
reminderNotificationEnabled: z.boolean().optional(),
|
|
reminderFrequencyDays: z.number().int().min(0).optional(),
|
|
reminderFrequencyHours: z.number().int().min(0).optional(),
|
|
reminderRunAtTime: z.string().regex(/^(\d{1,2}:\d{2})?$/, 'Time must be in HH:mm format').optional(),
|
|
reminderNotificationTemplate: z.string().optional(),
|
|
});
|