Skip to content

Commit

Permalink
fix: show refine button only when review not completed (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChibiBlasphem authored Feb 19, 2025
1 parent beafd1f commit b10426a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/app-builder/src/components/Sanctions/SanctionReview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Callout } from '@app-builder/components/Callout';
import {
isSanctionCheckError,
isSanctionCheckReviewCompleted,
type SanctionCheck,
} from '@app-builder/models/sanction-check';
import { useState } from 'react';
Expand Down Expand Up @@ -31,6 +32,7 @@ export function SanctionReviewSection({
(m) => m.status === 'pending',
).length;
const hasError = isSanctionCheckError(sanctionCheck);
const isRefinable = !isSanctionCheckReviewCompleted(sanctionCheck);

return (
<div className="flex h-fit flex-[2] flex-col gap-6">
Expand All @@ -43,14 +45,16 @@ export function SanctionReviewSection({
totalMatches: sanctionCheck.matches.length,
})}
</span>
<Button
className="ml-auto"
variant="secondary"
onClick={() => setIsRefining(true)}
>
<Icon icon="restart-alt" className="size-5" />
{t('sanctions:refine_search')}
</Button>
{isRefinable ? (
<Button
className="ml-auto"
variant="secondary"
onClick={() => setIsRefining(true)}
>
<Icon icon="restart-alt" className="size-5" />
{t('sanctions:refine_search')}
</Button>
) : null}
</div>
{match(sanctionCheck)
.when(isSanctionCheckError, (sc) => (
Expand Down
7 changes: 7 additions & 0 deletions packages/app-builder/src/models/sanction-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,10 @@ export function isSanctionCheckError(
): sanctionCheck is SanctionCheckError {
return sanctionCheck.status === 'error';
}

export function isSanctionCheckReviewCompleted(sanctionCheck: SanctionCheck) {
return (
sanctionCheck.status === 'no_hit' ||
sanctionCheck.status === 'confirmed_hit'
);
}

0 comments on commit b10426a

Please sign in to comment.