Skip to content

Commit 9a6401a

Browse files
fix: always show refine button and ask confirmation when reviewing a confirmed_hit (#705)
1 parent 6e2a20b commit 9a6401a

File tree

5 files changed

+58
-14
lines changed

5 files changed

+58
-14
lines changed

packages/app-builder/src/components/Sanctions/SanctionReview.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ export function SanctionReviewSection({
3838
totalMatches: sanctionCheck.matches.length,
3939
})}
4040
</span>
41-
{needsRefine ? (
42-
<Button
43-
className="ml-auto"
44-
variant="secondary"
45-
onClick={() => setIsRefining(true)}
46-
>
47-
<Icon icon="restart-alt" className="size-5" />
48-
{t('sanctions:refine_search')}
49-
</Button>
50-
) : null}
41+
<Button
42+
className="ml-auto"
43+
variant="secondary"
44+
onClick={() => setIsRefining(true)}
45+
>
46+
<Icon icon="restart-alt" className="size-5" />
47+
{t('sanctions:refine_search')}
48+
</Button>
5149
</div>
5250
{!needsRefine ? (
5351
<Callout bordered>{t('sanctions:callout.review')}</Callout>
@@ -70,7 +68,7 @@ export function SanctionReviewSection({
7068
/>
7169
))}
7270
</div>
73-
{needsRefine && isRefining ? (
71+
{isRefining ? (
7472
<RefineSearchModal
7573
decisionId={decisionId}
7674
sanctionCheck={sanctionCheck}

packages/app-builder/src/locales/ar/sanctions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,6 @@
112112
"match.status.skipped": "تخطي",
113113
"match.unique_counterparty_identifier": "معرف فريد للطرف المقابل",
114114
"sanction_check": "فحص العقوبة",
115-
"see_details": "انظر التفاصيل"
115+
"see_details": "انظر التفاصيل",
116+
"review_modal.confirmation": "تأكيد"
116117
}

packages/app-builder/src/locales/en/sanctions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"review_modal.comment_label": "Add a comment",
2323
"review_modal.status_label": "Choose a status",
2424
"review_modal.title": "Change match status",
25+
"review_modal.confirmation": "Confirmation",
2526
"review_modal.whitelist_label": "Do not alert again if this profile is associated with:",
2627
"see_details": "See details",
2728
"start_reviewing": "Start reviewing",

packages/app-builder/src/locales/fr/sanctions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"review_modal.comment_label": "Ajouter un commentaire",
102102
"review_modal.status_label": "Choisissez un statut",
103103
"review_modal.title": "Modifier l'état de la correspondance",
104+
"review_modal.confirmation": "Confirmation",
104105
"review_modal.whitelist_label": "Ne plus alerter si ce profil est associé à:",
105106
"callout.needs_review": "{{toreview}} / {{totalmatches}} à examiner",
106107
"entity.schema.vehicle": "Véhicule",

packages/app-builder/src/routes/ressources+/cases+/review-sanction-match.tsx

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { parseWithZod } from '@conform-to/zod';
99
import { type ActionFunctionArgs, json } from '@remix-run/node';
1010
import { useFetcher } from '@remix-run/react';
1111
import { type UpdateSanctionCheckMatchDto } from 'marble-api';
12-
import { useEffect, useState } from 'react';
12+
import { useEffect, useRef, useState } from 'react';
1313
import { useTranslation } from 'react-i18next';
1414
import { Button, ModalV2, Switch, TextArea } from 'ui-design-system';
1515
import { z } from 'zod';
@@ -74,6 +74,8 @@ export const SanctionCheckReviewModal = ({
7474
UpdateSanctionCheckMatchDto['status'] | null
7575
>(null);
7676
const onClose = useCallbackRef(_onClose);
77+
const [isConfirming, setIsConfirming] = useState(false);
78+
const formRef = useRef<HTMLFormElement>(null);
7779

7880
const fetcher = useFetcher<typeof action>();
7981
useEffect(() => {
@@ -98,6 +100,7 @@ export const SanctionCheckReviewModal = ({
98100
className="flex flex-col gap-8 p-8"
99101
method="post"
100102
action={getRoute('/ressources/cases/review-sanction-match')}
103+
ref={formRef}
101104
>
102105
<input name="matchId" type="hidden" value={sanctionMatch.id} />
103106
<div className="flex flex-col gap-2">
@@ -142,14 +145,54 @@ export const SanctionCheckReviewModal = ({
142145
{t('common:cancel')}
143146
</ModalV2.Close>
144147
<Button
145-
type="submit"
148+
type={currentStatus === 'confirmed_hit' ? 'button' : 'submit'}
146149
disabled={!currentStatus}
147150
className="flex-1"
148151
variant="primary"
149152
name="save"
153+
onClick={() => {
154+
if (currentStatus === 'confirmed_hit') {
155+
setIsConfirming(true);
156+
}
157+
}}
150158
>
151159
{t('common:save')}
152160
</Button>
161+
<ModalV2.Content
162+
open={isConfirming}
163+
onClose={() => setIsConfirming(false)}
164+
>
165+
<ModalV2.Title>
166+
{t('sanctions:review_modal.confirmation')}
167+
</ModalV2.Title>
168+
<div className="flex flex-col gap-4 p-6">
169+
<div>{t('sanctions:review_modal.callout_confirmed_hit')}</div>
170+
<div className="flex justify-between gap-4">
171+
<ModalV2.Close
172+
render={
173+
<Button
174+
className="flex-1"
175+
variant="secondary"
176+
name="cancel"
177+
/>
178+
}
179+
>
180+
{t('common:cancel')}
181+
</ModalV2.Close>
182+
<Button
183+
disabled={!currentStatus}
184+
className="flex-1"
185+
variant="primary"
186+
name="save"
187+
onClick={() => {
188+
fetcher.submit(formRef.current);
189+
}}
190+
>
191+
{t('common:save')}
192+
</Button>
193+
</div>
194+
</div>
195+
</ModalV2.Content>
153196
</div>
154197
</fetcher.Form>
155198
</ModalV2.Content>

0 commit comments

Comments
 (0)