Skip to content

Commit

Permalink
feat: added new columns in alerts table
Browse files Browse the repository at this point in the history
  • Loading branch information
tomer-shvadron committed May 1, 2024
1 parent cc0fcd7 commit 09c87cd
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ export const TextWithNAFallback: TTextWithNAFallback = forwardRef(
);
},
);

// @ts-ignore
TextWithNAFallback.displayName = 'TextWithNAFallback';
7 changes: 6 additions & 1 deletion apps/backoffice-v2/src/domains/alerts/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ export const AlertsListSchema = z.array(
ObjectWithIdSchema.extend({
dataTimestamp: z.string().datetime(),
updatedAt: z.string().datetime(),
subject: ObjectWithIdSchema.extend({ name: z.string() }),
subject: ObjectWithIdSchema.extend({
id: z.string(),
name: z.string(),
correlationId: z.string(),
type: z.enum(['business', 'counterparty']),
}),
severity: z.enum(AlertSeverities),
label: z.string(),
alertDetails: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const AlertsTable: FunctionComponent<IAlertsTableProps> = ({ data }) => {
{headers.map(header => (
<TableHead
key={header.id}
className={`sticky top-0 z-10 h-[34px] bg-white p-0 text-[14px] font-bold text-[#787981]`}
className={`sticky top-0 z-10 h-[34px] bg-white p-1 text-[14px] font-bold text-[#787981]`}
>
{header.column.id === 'select' && (
<span className={'pe-4'}>
Expand All @@ -38,7 +38,7 @@ export const AlertsTable: FunctionComponent<IAlertsTableProps> = ({ data }) => {
)}
{header.column.id !== 'select' && (
<button
className="flex h-9 flex-row items-center gap-x-2 px-3 text-[#A3A3A3]"
className="flex h-9 flex-row items-center gap-x-2 px-3 text-left text-[#A3A3A3]"
onClick={() => header.column.toggleSorting()}
>
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { severityToClassName } from '@/pages/TransactionMonitoringAlerts/compone
import { IndeterminateCheckbox } from '@/common/components/atoms/IndeterminateCheckbox/IndeterminateCheckbox';
import { SnakeCase, titleCase } from 'string-ts';
import { toScreamingSnakeCase } from '@/common/utils/to-screaming-snake-case/to-screaming-snake-case';
import { useEllipsesWithTitle } from '@/common/hooks/useEllipsesWithTitle/useEllipsesWithTitle';
import { buttonVariants } from '@/common/components/atoms/Button/Button';

const columnHelper = createColumnHelper<
TAlertsList[number] & {
Expand Down Expand Up @@ -84,6 +86,39 @@ export const columns = [
},
header: 'Subject',
}),
columnHelper.accessor('subject.type', {
cell: info => {
const subjectType = info.getValue();

return (
<TextWithNAFallback className={`max-w-[12ch]`}>{titleCase(subjectType)}</TextWithNAFallback>
);
},
header: 'Subject Type',
}),
columnHelper.accessor('subject.correlationId', {
cell: info => {
// eslint-disable-next-line react-hooks/rules-of-hooks -- ESLint doesn't like `cell` not being `Cell`.
const { ref, styles } = useEllipsesWithTitle<HTMLSpanElement>();
const subjectId = info.getValue();

return (
<div className={`w-[11.8ch]`}>
<TextWithNAFallback
className={buttonVariants({
variant: 'link',
className: '!block cursor-pointer !p-0 text-sm !text-blue-500',
})}
style={styles}
ref={ref}
>
{subjectId}
</TextWithNAFallback>
</div>
);
},
header: 'Subject ID',
}),
columnHelper.accessor('severity', {
cell: info => {
const severity = info.getValue();
Expand All @@ -108,7 +143,7 @@ export const columns = [
cell: info => {
const alertDetails = info.getValue();

return <TextWithNAFallback>{alertDetails}</TextWithNAFallback>;
return <TextWithNAFallback className={`max-w-[40ch]`}>{alertDetails}</TextWithNAFallback>;
},
header: 'Alert Details',
}),
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ export class AlertControllerExternal {
alertDetails: alertDefinition.description,
subject: counterparty.business
? {
type: 'business',
id: counterparty.business.id,
name: counterparty.business.companyName,
correlationId: counterparty.business.correlationId,
}
: {
type: 'counterparty',
id: counterparty.endUser.id,
correlationId: counterparty.endUser.correlationId,
name: `${counterparty.endUser.firstName} ${counterparty.endUser.lastName}`,
},
decision: state,
Expand Down
6 changes: 3 additions & 3 deletions services/workflows-service/src/alert/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alert, AlertDefinition, Business, User } from '@prisma/client';
import { Alert, AlertDefinition, Business, EndUser, User } from '@prisma/client';

export type TExecutionDetails = {
checkpoint: {
Expand All @@ -23,8 +23,8 @@ export type TAlertResponse = Alert & {
alertDefinition: Pick<AlertDefinition, 'description' | 'label'>;
assignee: Pick<User, 'id' | 'firstName' | 'lastName' | 'avatarUrl'>;
counterparty: {
business: Pick<Business, 'id' | 'companyName'>;
endUser: Pick<User, 'id' | 'firstName' | 'lastName'>;
business: Pick<Business, 'id' | 'companyName' | 'correlationId'>;
endUser: Pick<EndUser, 'id' | 'firstName' | 'lastName' | 'correlationId'>;
};
};

Expand Down

0 comments on commit 09c87cd

Please sign in to comment.