feat: implement comprehensive notification engine with policies, preferences, and automated dispatching services

This commit is contained in:
2026-07-21 18:53:11 -03:00
parent 40090cdec5
commit 10ca449f88
82 changed files with 10249 additions and 171 deletions
+16
View File
@@ -1,12 +1,15 @@
import { create } from "zustand";
import type { ReactNode } from "react";
interface IConfirmStore {
visible: boolean;
message: string;
content?: ReactNode;
title: string;
onConfirm: () => void;
onCancel: () => void;
show: (message: string, onConfirm: () => void, onCancel: () => void) => void;
showContent: (message: string, content: ReactNode, onConfirm: () => void, onCancel: () => void) => void;
close: () => void;
clear: () => void;
}
@@ -16,6 +19,7 @@ export type ConfirmState = IConfirmStore;
const useConfirmStore = create<ConfirmState>()((set) => ({
visible: false,
message: "",
content: undefined,
title: "",
onConfirm: () => {},
onCancel: () => {},
@@ -23,6 +27,16 @@ const useConfirmStore = create<ConfirmState>()((set) => ({
set(() => ({
visible: true,
message: message,
content: undefined,
onConfirm: onConfirm,
onCancel: onCancel,
title: "Atención",
})),
showContent: (message: string, content: ReactNode, onConfirm: () => void, onCancel: () => void) =>
set(() => ({
visible: true,
message: message,
content: content,
onConfirm: onConfirm,
onCancel: onCancel,
title: "Atención",
@@ -31,6 +45,7 @@ const useConfirmStore = create<ConfirmState>()((set) => ({
set(() => ({
visible: false,
message: "",
content: undefined,
onConfirm: () => {},
onCancel: () => {},
title: "",
@@ -39,6 +54,7 @@ const useConfirmStore = create<ConfirmState>()((set) => ({
set(() => ({
visible: false,
message: "",
content: undefined,
onConfirm: () => {},
onCancel: () => {},
title: "",
@@ -0,0 +1,75 @@
import { create } from "zustand";
import {
NotificationFormMode,
CompanyNotificationPolicy,
ClientNotificationPreferences,
ClientCompanyNotificationOverride
} from "@models/NotificationPreferences.model";
interface NotificationPreferencesState {
mode: NotificationFormMode;
companyId: string;
clientId: string;
companyPolicy: CompanyNotificationPolicy | null;
clientPreferences: ClientNotificationPreferences | null;
clientOverride: ClientCompanyNotificationOverride | null;
formData: {
defaultChannels: string[];
preferredChannels: string[];
mutedChannels: string[];
timezone: string;
quietHours: { from: string; to: string } | null;
reminderRules: { offset: number; enabled: boolean }[];
};
isDirty: boolean;
loading: boolean;
setMode: (mode: NotificationFormMode) => void;
setCompanyId: (companyId: string) => void;
setClientId: (clientId: string) => void;
setCompanyPolicy: (policy: CompanyNotificationPolicy | null) => void;
setClientPreferences: (preferences: ClientNotificationPreferences | null) => void;
setClientOverride: (override: ClientCompanyNotificationOverride | null) => void;
updateFormData: (data: Partial<NotificationPreferencesState["formData"]>) => void;
setDirty: (dirty: boolean) => void;
setLoading: (loading: boolean) => void;
resetForm: () => void;
}
const initialFormData = {
defaultChannels: [],
preferredChannels: [],
mutedChannels: [],
timezone: "America/Argentina/Buenos_Aires",
quietHours: null,
reminderRules: []
};
export const useNotificationPreferencesStore = create<NotificationPreferencesState>()((set) => ({
mode: "company-policy",
companyId: "",
clientId: "",
companyPolicy: null,
clientPreferences: null,
clientOverride: null,
formData: { ...initialFormData },
isDirty: false,
loading: false,
setMode: (mode) => set({ mode }),
setCompanyId: (companyId) => set({ companyId }),
setClientId: (clientId) => set({ clientId }),
setCompanyPolicy: (policy) => set({ companyPolicy: policy }),
setClientPreferences: (preferences) => set({ clientPreferences: preferences }),
setClientOverride: (override) => set({ clientOverride: override }),
updateFormData: (data) =>
set((state) => ({
formData: { ...state.formData, ...data },
isDirty: true
})),
setDirty: (dirty) => set({ isDirty: dirty }),
setLoading: (loading) => set({ loading }),
resetForm: () =>
set({
formData: { ...initialFormData },
isDirty: false
})
}));