Skip to content

Commit

Permalink
fix(get-alerts-search-schema.ts): add alertType field to the search s…
Browse files Browse the repository at this point in the history
…chema to support filtering by alert type (#2145)

fix(TransactionMonitoringAlertsAnalysis.page.tsx): add key prop to AlertAnalysisSheet component to force re-render when alertId changes
fix(useTransactionMonitoringAlertsAnalysisPageLogic.tsx): remove duplicate navigateBack() call in useEffect hook
fix(schema.prisma): fix enum values for AlertState to match the database mapping
fix(alert.service.ts): fix mapping of AlertState.under_review to AlertStatus.pending
  • Loading branch information
MatanYadaev authored Mar 4, 2024
1 parent 6d7a379 commit 0812b7d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseSearchSchema } from '@/common/hooks/useSearchParamsByEntity/validation-schemas';
import { z } from 'zod';
import { AlertStatus, AlertStatuses, TAlertsList } from '@/domains/alerts/fetchers';
import { AlertStatus, AlertStatuses, AlertTypes, TAlertsList } from '@/domains/alerts/fetchers';
import { BooleanishSchema } from '@/lib/zod/utils/checkers';

export const getAlertsSearchSchema = (authenticatedUserId: string | null) =>
Expand All @@ -15,11 +15,15 @@ export const getAlertsSearchSchema = (authenticatedUserId: string | null) =>
assigneeId: z.array(z.string().nullable()).catch([]),
status: z.array(z.enum(AlertStatuses)).catch([AlertStatus.NEW]),
state: z.array(z.string().nullable()).catch([]),
alertType: z.array(z.enum(AlertTypes)).catch([]),
})
.catch({
assigneeId: [],
status: [AlertStatus.NEW],
state: [],
alertType: [],
}),
selected: BooleanishSchema.optional(),
businessId: z.string().optional(),
counterpartyId: z.string().optional(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { valueOrNA } from '@/common/utils/value-or-na/value-or-na';
import { ctw } from '@/common/utils/ctw/ctw';

export const TransactionMonitoringAlertsAnalysisPage = () => {
const { transactions, onNavigateBack, alertDefinition, isLoadingAlertDefinition } =
const { transactions, onNavigateBack, alertDefinition, isLoadingAlertDefinition, alertId } =
useTransactionMonitoringAlertsAnalysisPageLogic();

return (
<AlertAnalysisSheet
key={alertId}
transactions={transactions ?? []}
onOpenStateChange={onNavigateBack}
heading={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ export const useTransactionMonitoringAlertsAnalysisPageLogic = () => {
}

navigateBack();
navigateBack();
}, [navigate, navigateBack]);

return {
transactions,
onNavigateBack,
alertDefinition,
isLoadingAlertDefinition,
alertId,
};
};
15 changes: 6 additions & 9 deletions services/workflows-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -623,19 +623,17 @@ enum AlertSeverity {
}

enum AlertState {
// New
triggered @map("101") // Alert generated based on criteria indicating potential suspicious activity.
triggered @map("101") // Alert generated based on criteria indicating potential suspicious activity.
// Pending
underReview @map("201") // Alert is being investigated for more details and assessment.
escalated @map("202") // Alert requires attention from higher authority or specialized investigation.
under_review @map("201") // Alert is being investigated for more details and assessment.
escalated @map("202") // Alert requires attention from higher authority or specialized investigation.
// Completed - Various resolutions indicating the outcome of the investigation.
rejected @map("301") // Investigation confirms the alert as a real threat, necessitating specific actions or interventions.
dismissed @map("302") // Alert considered not relevant or not posing any actionable risk.
cleared @map("303") // Investigation finds activity to be legitimate and not suspicious.
rejected @map("301") // Investigation confirms the alert as a real threat, necessitating specific actions or interventions.
dismissed @map("302") // Alert considered not relevant or not posing any actionable risk.
cleared @map("303") // Investigation finds activity to be legitimate and not suspicious.
}

enum AlertStatus {
Expand Down Expand Up @@ -782,4 +780,3 @@ model Counterparty {
@@unique([projectId, correlationId])
@@index([correlationId])
}

2 changes: 1 addition & 1 deletion services/workflows-service/src/alert/alert.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class AlertService {
private getStatusFromState(newState: AlertState): ObjectValues<typeof AlertStatus> {
const alertStateToStatusMap = {
[AlertState.triggered]: AlertStatus.new,
[AlertState.underReview]: AlertStatus.pending,
[AlertState.under_review]: AlertStatus.pending,
[AlertState.escalated]: AlertStatus.pending,
[AlertState.dismissed]: AlertStatus.completed,
[AlertState.rejected]: AlertStatus.completed,
Expand Down

0 comments on commit 0812b7d

Please sign in to comment.