Skip to content

Commit b10426a

Browse files
fix: show refine button only when review not completed (#707)
1 parent beafd1f commit b10426a

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Callout } from '@app-builder/components/Callout';
22
import {
33
isSanctionCheckError,
4+
isSanctionCheckReviewCompleted,
45
type SanctionCheck,
56
} from '@app-builder/models/sanction-check';
67
import { useState } from 'react';
@@ -31,6 +32,7 @@ export function SanctionReviewSection({
3132
(m) => m.status === 'pending',
3233
).length;
3334
const hasError = isSanctionCheckError(sanctionCheck);
35+
const isRefinable = !isSanctionCheckReviewCompleted(sanctionCheck);
3436

3537
return (
3638
<div className="flex h-fit flex-[2] flex-col gap-6">
@@ -43,14 +45,16 @@ export function SanctionReviewSection({
4345
totalMatches: sanctionCheck.matches.length,
4446
})}
4547
</span>
46-
<Button
47-
className="ml-auto"
48-
variant="secondary"
49-
onClick={() => setIsRefining(true)}
50-
>
51-
<Icon icon="restart-alt" className="size-5" />
52-
{t('sanctions:refine_search')}
53-
</Button>
48+
{isRefinable ? (
49+
<Button
50+
className="ml-auto"
51+
variant="secondary"
52+
onClick={() => setIsRefining(true)}
53+
>
54+
<Icon icon="restart-alt" className="size-5" />
55+
{t('sanctions:refine_search')}
56+
</Button>
57+
) : null}
5458
</div>
5559
{match(sanctionCheck)
5660
.when(isSanctionCheckError, (sc) => (

packages/app-builder/src/models/sanction-check.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,10 @@ export function isSanctionCheckError(
189189
): sanctionCheck is SanctionCheckError {
190190
return sanctionCheck.status === 'error';
191191
}
192+
193+
export function isSanctionCheckReviewCompleted(sanctionCheck: SanctionCheck) {
194+
return (
195+
sanctionCheck.status === 'no_hit' ||
196+
sanctionCheck.status === 'confirmed_hit'
197+
);
198+
}

0 commit comments

Comments
 (0)