Skip to content

Commit

Permalink
fix: always show refine button and ask confirmation when reviewing a …
Browse files Browse the repository at this point in the history
…confirmed_hit (#705)
  • Loading branch information
ChibiBlasphem authored Feb 19, 2025
1 parent 6e2a20b commit 9a6401a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 14 deletions.
20 changes: 9 additions & 11 deletions packages/app-builder/src/components/Sanctions/SanctionReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ export function SanctionReviewSection({
totalMatches: sanctionCheck.matches.length,
})}
</span>
{needsRefine ? (
<Button
className="ml-auto"
variant="secondary"
onClick={() => setIsRefining(true)}
>
<Icon icon="restart-alt" className="size-5" />
{t('sanctions:refine_search')}
</Button>
) : null}
<Button
className="ml-auto"
variant="secondary"
onClick={() => setIsRefining(true)}
>
<Icon icon="restart-alt" className="size-5" />
{t('sanctions:refine_search')}
</Button>
</div>
{!needsRefine ? (
<Callout bordered>{t('sanctions:callout.review')}</Callout>
Expand All @@ -70,7 +68,7 @@ export function SanctionReviewSection({
/>
))}
</div>
{needsRefine && isRefining ? (
{isRefining ? (
<RefineSearchModal
decisionId={decisionId}
sanctionCheck={sanctionCheck}
Expand Down
3 changes: 2 additions & 1 deletion packages/app-builder/src/locales/ar/sanctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,6 @@
"match.status.skipped": "تخطي",
"match.unique_counterparty_identifier": "معرف فريد للطرف المقابل",
"sanction_check": "فحص العقوبة",
"see_details": "انظر التفاصيل"
"see_details": "انظر التفاصيل",
"review_modal.confirmation": "تأكيد"
}
1 change: 1 addition & 0 deletions packages/app-builder/src/locales/en/sanctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"review_modal.comment_label": "Add a comment",
"review_modal.status_label": "Choose a status",
"review_modal.title": "Change match status",
"review_modal.confirmation": "Confirmation",
"review_modal.whitelist_label": "Do not alert again if this profile is associated with:",
"see_details": "See details",
"start_reviewing": "Start reviewing",
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder/src/locales/fr/sanctions.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"review_modal.comment_label": "Ajouter un commentaire",
"review_modal.status_label": "Choisissez un statut",
"review_modal.title": "Modifier l'état de la correspondance",
"review_modal.confirmation": "Confirmation",
"review_modal.whitelist_label": "Ne plus alerter si ce profil est associé à:",
"callout.needs_review": "{{toreview}} / {{totalmatches}} à examiner",
"entity.schema.vehicle": "Véhicule",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { parseWithZod } from '@conform-to/zod';
import { type ActionFunctionArgs, json } from '@remix-run/node';
import { useFetcher } from '@remix-run/react';
import { type UpdateSanctionCheckMatchDto } from 'marble-api';
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, ModalV2, Switch, TextArea } from 'ui-design-system';
import { z } from 'zod';
Expand Down Expand Up @@ -74,6 +74,8 @@ export const SanctionCheckReviewModal = ({
UpdateSanctionCheckMatchDto['status'] | null
>(null);
const onClose = useCallbackRef(_onClose);
const [isConfirming, setIsConfirming] = useState(false);
const formRef = useRef<HTMLFormElement>(null);

const fetcher = useFetcher<typeof action>();
useEffect(() => {
Expand All @@ -98,6 +100,7 @@ export const SanctionCheckReviewModal = ({
className="flex flex-col gap-8 p-8"
method="post"
action={getRoute('/ressources/cases/review-sanction-match')}
ref={formRef}
>
<input name="matchId" type="hidden" value={sanctionMatch.id} />
<div className="flex flex-col gap-2">
Expand Down Expand Up @@ -142,14 +145,54 @@ export const SanctionCheckReviewModal = ({
{t('common:cancel')}
</ModalV2.Close>
<Button
type="submit"
type={currentStatus === 'confirmed_hit' ? 'button' : 'submit'}
disabled={!currentStatus}
className="flex-1"
variant="primary"
name="save"
onClick={() => {
if (currentStatus === 'confirmed_hit') {
setIsConfirming(true);
}
}}
>
{t('common:save')}
</Button>
<ModalV2.Content
open={isConfirming}
onClose={() => setIsConfirming(false)}
>
<ModalV2.Title>
{t('sanctions:review_modal.confirmation')}
</ModalV2.Title>
<div className="flex flex-col gap-4 p-6">
<div>{t('sanctions:review_modal.callout_confirmed_hit')}</div>
<div className="flex justify-between gap-4">
<ModalV2.Close
render={
<Button
className="flex-1"
variant="secondary"
name="cancel"
/>
}
>
{t('common:cancel')}
</ModalV2.Close>
<Button
disabled={!currentStatus}
className="flex-1"
variant="primary"
name="save"
onClick={() => {
fetcher.submit(formRef.current);
}}
>
{t('common:save')}
</Button>
</div>
</div>
</ModalV2.Content>
</div>
</fetcher.Form>
</ModalV2.Content>
Expand Down

0 comments on commit 9a6401a

Please sign in to comment.