159 lines
4.2 KiB
TypeScript
159 lines
4.2 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const sendCampaignSchema = z.object({
|
|
userID: z.string().min(1, "User ID is required"),
|
|
title: z.string().min(1, "Title is required"),
|
|
body: z.string().min(1, "Body is required"),
|
|
data: z.record(z.any()).optional().default({}),
|
|
});
|
|
|
|
export const setupCampaignSchema = z.object({
|
|
title: z.string().min(1, "Title is required"),
|
|
content: z.string().min(1, "Content is required"),
|
|
date: z.string().min(1, "Date is required"),
|
|
});
|
|
|
|
export const updateCampaignSchema = z.object({
|
|
title: z.string().min(1, "Title is required").optional(),
|
|
content: z.string().min(1, "Content is required").optional(),
|
|
date: z.string().min(1, "Date is required").optional(),
|
|
status: z.enum(["pending", "completed", "cancelled", "failed"]).optional(),
|
|
});
|
|
|
|
export type SendCampaignInput = z.infer<typeof sendCampaignSchema>;
|
|
export type SetupCampaignInput = z.infer<typeof setupCampaignSchema>;
|
|
export type UpdateCampaignInput = z.infer<typeof updateCampaignSchema>;
|
|
|
|
export interface Campaign {
|
|
UUID_ACP: string;
|
|
Title_ACP: string;
|
|
Content_ACP: string;
|
|
Date_ACP: string;
|
|
Status_ACP: "pending" | "completed" | "cancelled" | "failed";
|
|
TargetUsers_ACP: number;
|
|
SentCount_ACP: number;
|
|
SuccessCount_ACP: number;
|
|
FailureCount_ACP: number;
|
|
DeliveryRate_ACP: number;
|
|
SentAt_ACP: string | null;
|
|
CompletedAt_ACP: string | null;
|
|
ErrorMessage_ACP: string | null;
|
|
UpdatedAt_ACP: string;
|
|
CreatedAt_ACP: string;
|
|
}
|
|
|
|
export interface CampaignAnalytics {
|
|
summary: {
|
|
campaigns: {
|
|
total: number;
|
|
completed: number;
|
|
failed: number;
|
|
pending: number;
|
|
cancelled: number;
|
|
successRate: string;
|
|
avgResponseTime: string;
|
|
upcomingCount: number;
|
|
};
|
|
delivery: {
|
|
totalTargetUsers: number;
|
|
totalSent: number;
|
|
totalDelivered: number;
|
|
totalFailed: number;
|
|
overallDeliveryRate: string;
|
|
totalDeliveryRecords: number;
|
|
};
|
|
};
|
|
charts: {
|
|
statusDistribution: {
|
|
labels: string[];
|
|
data: number[];
|
|
};
|
|
deliveryStatusDistribution: {
|
|
labels: string[];
|
|
data: number[];
|
|
};
|
|
campaignTimeline: Record<string, any>;
|
|
creationTrend: {
|
|
labels: string[];
|
|
data: number[];
|
|
};
|
|
statusOverTime: Record<string, Record<string, number>>;
|
|
deliveryRateTrend: {
|
|
labels: string[];
|
|
data: number[];
|
|
};
|
|
};
|
|
topPerforming: Array<{
|
|
id: string;
|
|
title: string;
|
|
targetUsers: number;
|
|
successCount: number;
|
|
failureCount: number;
|
|
deliveryRate: number;
|
|
date: string;
|
|
}>;
|
|
upcoming: any[];
|
|
recentActivity: any[];
|
|
}
|
|
|
|
export interface CampaignAnalyticsResponse {
|
|
status: string;
|
|
message: string;
|
|
data: CampaignAnalytics;
|
|
}
|
|
|
|
export interface CampaignReport {
|
|
campaign: {
|
|
id: string;
|
|
title: string;
|
|
content: string;
|
|
status: string;
|
|
scheduledDate: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
errorMessage: string | null;
|
|
};
|
|
metrics: {
|
|
leadTime: string;
|
|
executionTime: string;
|
|
isScheduled: boolean;
|
|
isOverdue: boolean;
|
|
timeUntilExecution: string;
|
|
status: string;
|
|
avgDeliveryTime: string;
|
|
};
|
|
delivery: {
|
|
targetUsers: number;
|
|
sentCount: number;
|
|
successCount: number;
|
|
failureCount: number;
|
|
deliveryRate: string;
|
|
sentAt: string | null;
|
|
completedAt: string | null;
|
|
statusBreakdown: {
|
|
pending: number;
|
|
sent: number;
|
|
delivered: number;
|
|
failed: number;
|
|
};
|
|
errorBreakdown: Record<string, number>;
|
|
};
|
|
timeline: {
|
|
created: string;
|
|
scheduled: string;
|
|
sent: string | null;
|
|
completed: string | null;
|
|
executed: string;
|
|
};
|
|
deliveryRecords: {
|
|
total: number;
|
|
records: any[];
|
|
};
|
|
}
|
|
|
|
export interface CampaignReportResponse {
|
|
status: string;
|
|
message: string;
|
|
data: CampaignReport;
|
|
}
|