Skip to content

Commit e280608

Browse files
Add comments feature to MatchCard component
update openapi with the comments already sent by the `/cases/:caseid` route
1 parent 5c55727 commit e280608

6 files changed

Lines changed: 70 additions & 29 deletions

File tree

packages/app-builder/src/components/CaseManager/ContinuousScreening/MatchCard.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CommentLine } from '@app-builder/components/Screenings/MatchCard/CommentLine';
12
import { MatchDetails } from '@app-builder/components/Screenings/MatchDetails';
23
import { TopicTag } from '@app-builder/components/Screenings/TopicTag';
34
import { Case } from '@app-builder/models/cases';
@@ -54,6 +55,9 @@ export function MatchCard({ caseDetail, screening, screeningMatch }: MatchCardPr
5455
return <TopicTag key={topic} topic={topic} className="text-small" />;
5556
})}
5657
</div>
58+
{screeningMatch.comments.map((comment) => {
59+
return <CommentLine key={comment.id} comment={comment} />;
60+
})}
5761
</div>
5862
</div>
5963
</Collapsible.Trigger>

packages/app-builder/src/components/Screenings/MatchCard/CommentLine.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ScreeningMatch } from '@app-builder/models/screening';
1+
import type { ScreeningMatchComment } from '@app-builder/models/screening';
22
import { useOrganizationUsers } from '@app-builder/services/organization/organization-users';
33
import { getFullName } from '@app-builder/services/user';
44
import { useFormatDateTime } from '@app-builder/utils/format';
55
import { Avatar } from 'ui-design-system';
66

7-
export const CommentLine = ({ comment }: { comment: ScreeningMatch['comments'][number] }) => {
7+
export const CommentLine = ({ comment }: { comment: ScreeningMatchComment }) => {
88
const formatDateTime = useFormatDateTime();
99
const { getOrgUserById } = useOrganizationUsers();
1010
const user = getOrgUserById(comment.authorId);

packages/app-builder/src/models/continuous-screening.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import {
2323
} from 'marble-api';
2424
import * as R from 'remeda';
2525
import {
26+
adaptScreeningMatchComments,
2627
adaptScreeningMatchPayload,
2728
isKnownEntitySchema,
2829
matchEntitySchemas,
29-
OpenSanctionEntitySchema,
30-
ScreeningMatchPayload,
30+
type OpenSanctionEntitySchema,
31+
type ScreeningMatchComment,
32+
type ScreeningMatchPayload,
3133
} from './screening';
3234
import { createScreeningFilters, getDatasetFromFilters } from './screening-config';
3335

@@ -358,6 +360,7 @@ export type ContinuousScreeningMatchBase = {
358360
continuousScreeningId: string;
359361
status: ContinuousScreeningMatchBaseDto['status'];
360362
payload: ContinuousScreeningMatchPayload;
363+
comments: ScreeningMatchComment[];
361364
};
362365

363366
export type ContinuousScreeningMatchScreeningEntity = ContinuousScreeningMatchBase & {
@@ -417,36 +420,36 @@ export function adaptContinuousScreeningRequest(dto: ContinuousScreeningRequestD
417420
};
418421
}
419422

420-
export function adaptContinuousScreeningMatchMarble(
421-
dto: ContinuousScreeningMatchMarbleDto,
422-
): ContinuousScreeningMatchMarble {
423+
function adaptContinuousScreeningMatchBase(dto: ContinuousScreeningMatchBaseDto): ContinuousScreeningMatchBase {
423424
return {
424425
id: dto.id,
425426
continuousScreeningId: dto.continuous_screening_id,
426427
status: dto.status,
427-
objectType: dto.object_type,
428-
objectId: dto.object_id,
429428
payload: {
430429
...adaptScreeningMatchPayload(dto.payload),
431430
target: dto.payload.target,
432431
datasets: dto.payload.datasets,
433432
},
433+
comments: adaptScreeningMatchComments(dto.comments),
434+
};
435+
}
436+
437+
export function adaptContinuousScreeningMatchMarble(
438+
dto: ContinuousScreeningMatchMarbleDto,
439+
): ContinuousScreeningMatchMarble {
440+
return {
441+
...adaptContinuousScreeningMatchBase(dto),
442+
objectType: dto.object_type,
443+
objectId: dto.object_id,
434444
};
435445
}
436446

437447
export function adaptContinuousScreeningMatchScreeningEntity(
438448
dto: ContinuousScreeningMatchScreeningEntityDto,
439449
): ContinuousScreeningMatchScreeningEntity {
440450
return {
441-
id: dto.id,
442-
continuousScreeningId: dto.continuous_screening_id,
443-
status: dto.status,
451+
...adaptContinuousScreeningMatchBase(dto),
444452
opensanctionEntityId: dto.opensanction_entity_id,
445-
payload: {
446-
...adaptScreeningMatchPayload(dto.payload),
447-
target: dto.payload.target,
448-
datasets: dto.payload.datasets,
449-
},
450453
};
451454
}
452455

packages/app-builder/src/models/screening.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ export function adaptScreeningMatchPayload(dto: ScreeningMatchPayloadDto): Scree
196196
};
197197
}
198198

199+
export type ScreeningMatchComment = {
200+
id: string;
201+
authorId: string;
202+
comment: string;
203+
createdAt: string;
204+
};
205+
199206
export type ScreeningMatch = {
200207
id: string;
201208
entityId: string;
@@ -204,14 +211,18 @@ export type ScreeningMatch = {
204211
enriched: boolean;
205212
// datasets: unknown[];
206213
payload: ScreeningMatchPayload;
207-
comments: {
208-
id: string;
209-
authorId: string;
210-
comment: string;
211-
createdAt: string;
212-
}[];
214+
comments: ScreeningMatchComment[];
213215
};
214216

217+
export function adaptScreeningMatchComments(comments: ScreeningMatchDto['comments']): ScreeningMatchComment[] {
218+
return R.map(comments, (comment) => ({
219+
id: comment.id,
220+
authorId: comment.author_id,
221+
comment: comment.comment,
222+
createdAt: comment.created_at,
223+
}));
224+
}
225+
215226
export function adaptScreeningMatch(dto: ScreeningMatchDto): ScreeningMatch {
216227
return {
217228
id: dto.id,
@@ -220,12 +231,7 @@ export function adaptScreeningMatch(dto: ScreeningMatchDto): ScreeningMatch {
220231
status: dto.status,
221232
enriched: dto.enriched,
222233
payload: adaptScreeningMatchPayload(dto.payload),
223-
comments: R.map(dto.comments, (comment) => ({
224-
id: comment.id,
225-
authorId: comment.author_id,
226-
comment: comment.comment,
227-
createdAt: comment.created_at,
228-
})),
234+
comments: adaptScreeningMatchComments(dto.comments),
229235
};
230236
}
231237

packages/marble-api/openapis/marblecore-api/continuous-screenings.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ components:
892892
- continuous_screening_id
893893
- status
894894
- payload
895+
- comments
895896
- created_at
896897
- updated_at
897898
properties:
@@ -913,6 +914,27 @@ components:
913914
reviewed_by:
914915
type: string
915916
format: uuid
917+
comments:
918+
type: array
919+
items:
920+
type: object
921+
required:
922+
- id
923+
- author_id
924+
- comment
925+
- created_at
926+
properties:
927+
id:
928+
type: string
929+
format: uuid
930+
author_id:
931+
type: string
932+
format: uuid
933+
comment:
934+
type: string
935+
created_at:
936+
type: string
937+
format: date-time
916938
created_at:
917939
type: string
918940
format: date-time

packages/marble-api/src/generated/marblecore-api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ export type ContinuousScreeningMatchBaseDto = {
263263
status: "pending" | "confirmed_hit" | "no_hit" | "skipped";
264264
payload: ContinuousScreeningMatchPayloadDto;
265265
reviewed_by?: string;
266+
comments: {
267+
id: string;
268+
author_id: string;
269+
comment: string;
270+
created_at: string;
271+
}[];
266272
created_at: string;
267273
updated_at: string;
268274
};

0 commit comments

Comments
 (0)