Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new columns in alerts table #2334

Merged
merged 6 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
tomer-shvadron marked this conversation as resolved.
Show resolved Hide resolved
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>();
tomer-shvadron marked this conversation as resolved.
Show resolved Hide resolved
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>
);
tomer-shvadron marked this conversation as resolved.
Show resolved Hide resolved
},
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',
tomer-shvadron marked this conversation as resolved.
Show resolved Hide resolved
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
Loading