Skip to content

Commit

Permalink
feat: misc fixes and add whitelisting on review (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChibiBlasphem authored Feb 13, 2025
1 parent 3a23fb4 commit a21352c
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 20 deletions.
6 changes: 4 additions & 2 deletions packages/app-builder/src/components/Sanctions/MatchCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type SanctionCheckMatch } from '@app-builder/models/sanction-check';
import { SanctionCheckReviewModal } from '@app-builder/routes/ressources+/cases+/review-sanction-match';
import { useOrganizationUsers } from '@app-builder/services/organization/organization-users';
import { getFullName } from '@app-builder/services/user';
import { formatDateTime, useFormatLanguage } from '@app-builder/utils/format';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -85,7 +86,7 @@ export const MatchCard = ({
<SanctionCheckReviewModal
open={isInReview}
onClose={() => setIsInReview(false)}
sanctionMatchId={match.id}
sanctionMatch={match}
/>
</div>
);
Expand All @@ -99,6 +100,7 @@ function CommentLine({
const language = useFormatLanguage();
const { getOrgUserById } = useOrganizationUsers();
const user = getOrgUserById(comment.authorId);
const fullName = getFullName(user);

return (
<div key={comment.id} className="flex flex-col gap-2">
Expand All @@ -109,7 +111,7 @@ function CommentLine({
lastName={user?.lastName}
/>
<span className="flex items-baseline gap-1">
Roger Grand
{fullName}
<time className="text-grey-50 text-xs" dateTime={comment.createdAt}>
{formatDateTime(comment.createdAt, { language })}
</time>
Expand Down
5 changes: 3 additions & 2 deletions packages/app-builder/src/components/Sanctions/StatusTag.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type SanctionCheckMatch } from '@app-builder/models/sanction-check';
import clsx from 'clsx';
import { useTranslation } from 'react-i18next';
import { Tag } from 'ui-design-system';
import { Tag, type TagProps } from 'ui-design-system';
import { Icon } from 'ui-icons';

import { sanctionsI18n } from './sanctions-i18n';
Expand All @@ -10,7 +10,8 @@ const statusTagColors = {
pending: 'orange',
no_hit: 'grey',
confirmed_hit: 'red',
} as const;
skipped: 'grey',
} satisfies Record<SanctionCheckMatch['status'], TagProps['color']>;

export type StatusTagProps = {
status: SanctionCheckMatch['status'];
Expand Down
4 changes: 3 additions & 1 deletion packages/app-builder/src/locales/ar/sanctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@
"refine_modal.schema.vehicle": "عربة",
"entity.schema.airplane": "طائرة",
"entity.schema.vessel": "إناء",
"refine_modal.schema.legalentity": "الكيان القانوني"
"refine_modal.schema.legalentity": "الكيان القانوني",
"match.status.skipped": "تخطي",
"match.unique_counterparty_identifier": "معرف فريد للطرف المقابل"
}
2 changes: 2 additions & 0 deletions packages/app-builder/src/locales/en/sanctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"match.status.pending": "To review",
"match.status.no_hit": "No match",
"match.status.confirmed_hit": "Match confirmed",
"match.status.skipped": "Skipped",
"match.unique_counterparty_identifier": "Unique counterpary Identifier",
"entity.property.name": "Name",
"entity.property.position": "Position",
"entity.property.religion": "Religion",
Expand Down
4 changes: 3 additions & 1 deletion packages/app-builder/src/locales/fr/sanctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@
"refine_modal.no_match_label": "Aucune correspondance possible n'a été trouvée avec votre recherche.",
"refine_modal.schema.vehicle": "Véhicule",
"entity.schema.airplane": "Avion",
"entity.schema.vessel": "Navire"
"entity.schema.vessel": "Navire",
"match.status.skipped": "Sauté",
"match.unique_counterparty_identifier": "Identifiant unique de contrepartie"
}
8 changes: 7 additions & 1 deletion packages/app-builder/src/models/sanction-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export type SanctionCheckStatus =
| 'confirmed_hit'
| 'no_hit'
| 'error';
export type SanctionCheckMatchStatus = 'pending' | 'confirmed_hit' | 'no_hit';
export type SanctionCheckMatchStatus =
| 'pending'
| 'confirmed_hit'
| 'no_hit'
| 'skipped';
export type SanctionCheckEntitySchema = (typeof entitySchemas)[number];

export type SanctionCheckMatchPayload = {
Expand Down Expand Up @@ -56,6 +60,7 @@ export type SanctionCheckMatch = {
queryIds: string[];
status: SanctionCheckMatchStatus;
// datasets: unknown[];
uniqueCounterpartyIdentifier?: string;
payload: SanctionCheckMatchPayload;
comments: {
id: string;
Expand All @@ -74,6 +79,7 @@ export function adaptSanctionCheckMatch(
queryIds: dto.query_ids,
status: dto.status,
payload: adapatSanctionCheckMatchPayload(dto.payload),
uniqueCounterpartyIdentifier: dto.unique_counterparty_identifier,
comments: R.map(dto.comments, (comment) => ({
id: comment.id,
authorId: comment.author_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export interface SanctionCheckRepository {
listDatasets(): Promise<OpenSanctionsCatalog>;
updateMatchStatus(args: {
matchId: string;
status: Exclude<SanctionCheckMatchStatus, 'pending'>;
status: Extract<SanctionCheckMatchStatus, 'no_hit' | 'confirmed_hit'>;
comment?: string;
whitelist?: boolean;
}): Promise<SanctionCheckMatch>;
searchSanctionCheckMatches(args: {
decisionId: string;
Expand Down Expand Up @@ -53,11 +54,12 @@ export function makeGetSanctionCheckRepository() {
adaptSanctionCheck,
);
},
updateMatchStatus: async ({ matchId, status, comment }) => {
updateMatchStatus: async ({ matchId, status, comment, whitelist }) => {
return adaptSanctionCheckMatch(
await marbleCoreApiClient.updateSanctionCheckMatch(matchId, {
status,
comment,
whitelist,
}),
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Callout } from '@app-builder/components';
import { setToastMessage } from '@app-builder/components/MarbleToaster';
import { StatusRadioGroup } from '@app-builder/components/Sanctions/StatusRadioGroup';
import { type SanctionCheckMatch } from '@app-builder/models/sanction-check';
import { serverServices } from '@app-builder/services/init.server';
import { useCallbackRef } from '@app-builder/utils/hooks';
import { getRoute } from '@app-builder/utils/routes';
Expand All @@ -10,7 +11,7 @@ import { useFetcher } from '@remix-run/react';
import { type UpdateSanctionCheckMatchDto } from 'marble-api';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, ModalV2, TextArea } from 'ui-design-system';
import { Button, ModalV2, Switch, TextArea } from 'ui-design-system';
import { z } from 'zod';

const schema = z.object({
Expand Down Expand Up @@ -62,11 +63,11 @@ export async function action({ request }: ActionFunctionArgs) {
export const SanctionCheckReviewModal = ({
open,
onClose: _onClose,
sanctionMatchId,
sanctionMatch,
}: {
open: boolean;
onClose: () => void;
sanctionMatchId: string;
sanctionMatch: SanctionCheckMatch;
}) => {
const { t } = useTranslation(['common', 'sanctions']);
const [currentStatus, setCurrentStatus] = useState<
Expand Down Expand Up @@ -98,7 +99,7 @@ export const SanctionCheckReviewModal = ({
method="post"
action={getRoute('/ressources/cases/review-sanction-match')}
>
<input name="matchId" type="hidden" value={sanctionMatchId} />
<input name="matchId" type="hidden" value={sanctionMatch.id} />
<div className="flex flex-col gap-2">
<div className="text-m">
{t('sanctions:review_modal.status_label')}
Expand All @@ -117,17 +118,21 @@ export const SanctionCheckReviewModal = ({
<TextArea name="comment" />
</div>
{/* TODO: Whitelisting */}
{/* {currentStatus === 'no_hit' ? (
{currentStatus === 'no_hit' &&
!!sanctionMatch.uniqueCounterpartyIdentifier ? (
<div className="flex flex-col gap-2">
<span className="flex items-center gap-2">
<Switch name="whitelist" /> {t('sanctions:review_modal.whitelist_label')}
<Switch name="whitelist" />{' '}
{t('sanctions:review_modal.whitelist_label')}
</span>
<div className="border-grey-90 bg-grey-98 flex flex-col gap-2 rounded border p-2">
<span className="font-semibold">IBAN</span>
<span>FR76 4061 8801 5200 0500 9263 912</span>
<span className="font-semibold">
{t('sanctions:match.unique_counterparty_identifier')}
</span>
<span>{sanctionMatch.uniqueCounterpartyIdentifier}</span>
</div>
</div>
) : null} */}
) : null}
<div className="flex flex-1 flex-row gap-2">
<ModalV2.Close
render={
Expand Down
6 changes: 5 additions & 1 deletion packages/marble-api/openapis/marblecore-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5182,9 +5182,11 @@ components:
type: string
status:
type: string
enum: ['pending', 'confirmed_hit', 'no_hit']
enum: ['pending', 'confirmed_hit', 'no_hit', 'skipped']
datasets:
type: array
unique_counterparty_identifier:
type: string
payload:
$ref: '#/components/schemas/SanctionCheckMatchPayloadDto'
comments:
Expand Down Expand Up @@ -5404,6 +5406,8 @@ components:
enum: ['confirmed_hit', 'no_hit']
comment:
type: string
whitelist:
type: boolean
UpdateScenarioIterationBody:
type: object
properties:
Expand Down
4 changes: 3 additions & 1 deletion packages/marble-api/src/generated/marblecore-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,9 @@ export type SanctionCheckMatchDto = {
id: string;
entity_id: string;
query_ids: string[];
status: "pending" | "confirmed_hit" | "no_hit";
status: "pending" | "confirmed_hit" | "no_hit" | "skipped";
datasets: any;
unique_counterparty_identifier?: string;
payload: SanctionCheckMatchPayloadDto;
comments: {
id: string;
Expand Down Expand Up @@ -546,6 +547,7 @@ export type SanctionCheckFileDto = {
export type UpdateSanctionCheckMatchDto = {
status: "confirmed_hit" | "no_hit";
comment?: string;
whitelist?: boolean;
};
export type SanctionCheckRefineDto = object;
export type UpdateScenarioIterationRuleBodyDto = {
Expand Down

0 comments on commit a21352c

Please sign in to comment.