mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 08:11:12 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
64
src-old/lib/notificationValidation.ts
Normal file
64
src-old/lib/notificationValidation.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { z } from 'zod';
|
||||
import type { NotificationPreferences } from '@/types/notifications';
|
||||
|
||||
/**
|
||||
* Schema for channel preferences
|
||||
*/
|
||||
export const channelPreferencesSchema = z.object({
|
||||
in_app: z.boolean(),
|
||||
email: z.boolean(),
|
||||
push: z.boolean(),
|
||||
sms: z.boolean()
|
||||
});
|
||||
|
||||
/**
|
||||
* Schema for workflow preferences (dynamic keys)
|
||||
*/
|
||||
export const workflowPreferencesSchema = z.record(z.string(), z.boolean());
|
||||
|
||||
/**
|
||||
* Schema for frequency settings
|
||||
*/
|
||||
export const frequencySettingsSchema = z.object({
|
||||
digest: z.enum(['realtime', 'hourly', 'daily', 'weekly'] as const),
|
||||
max_per_hour: z.number().int().min(1).max(999)
|
||||
});
|
||||
|
||||
/**
|
||||
* Complete notification preferences schema
|
||||
*/
|
||||
export const notificationPreferencesSchema = z.object({
|
||||
channelPreferences: channelPreferencesSchema,
|
||||
workflowPreferences: workflowPreferencesSchema,
|
||||
frequencySettings: frequencySettingsSchema
|
||||
});
|
||||
|
||||
/**
|
||||
* Schema for subscriber data
|
||||
*/
|
||||
export const subscriberDataSchema = z.object({
|
||||
subscriberId: z.string().uuid('Invalid subscriber ID'),
|
||||
email: z.string().email('Invalid email').optional(),
|
||||
firstName: z.string().max(100).optional(),
|
||||
lastName: z.string().max(100).optional(),
|
||||
phone: z.string().max(20).optional(),
|
||||
avatar: z.string().url('Invalid avatar URL').optional(),
|
||||
data: z.record(z.string(), z.any()).optional()
|
||||
});
|
||||
|
||||
/**
|
||||
* Default notification preferences for new users
|
||||
*/
|
||||
export const DEFAULT_NOTIFICATION_PREFERENCES: NotificationPreferences = {
|
||||
channelPreferences: {
|
||||
in_app: true,
|
||||
email: true,
|
||||
push: false,
|
||||
sms: false
|
||||
},
|
||||
workflowPreferences: {},
|
||||
frequencySettings: {
|
||||
digest: 'daily',
|
||||
max_per_hour: 10
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user