Skip to content

Commit

Permalink
Keep permissions naming
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Nov 28, 2024
1 parent 658e7fe commit 4ff2c09
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions clients/banking/src/components/TransferRegularWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ const BeneficiaryStep = ({
isAccountClosing: boolean;
onPressSubmit: (beneficiary: SepaBeneficiary) => void;
}) => {
const permissions = usePermissions();

const canCreateTrustedBeneficiary = !isAccountClosing && permissions.canCreateTrustedBeneficiary;
const canInitiateCreditTransferToNewBeneficiary =
isAccountClosing || permissions.canInitiateCreditTransferToNewBeneficiary;
const { canInitiateCreditTransferToNewBeneficiary, canCreateTrustedBeneficiary } =
usePermissions();

const [activeTab, setActiveTab] = useState(
canInitiateCreditTransferToNewBeneficiary ? (initialBeneficiary?.kind ?? "new") : "saved",
canInitiateCreditTransferToNewBeneficiary || isAccountClosing
? (initialBeneficiary?.kind ?? "new")
: "saved",
);

const tabs: { id: SepaBeneficiary["kind"]; label: string }[] = [
...(canInitiateCreditTransferToNewBeneficiary
...(canInitiateCreditTransferToNewBeneficiary || isAccountClosing
? [{ id: "new" as const, label: t("transfer.new.beneficiary.new") }]
: []),
{ id: "saved" as const, label: t("transfer.new.beneficiary.saved") },
Expand Down Expand Up @@ -85,7 +84,7 @@ const BeneficiaryStep = ({
accountCountry={accountCountry}
accountId={accountId}
onPressSubmit={onPressSubmit}
saveCheckboxVisible={canCreateTrustedBeneficiary}
saveCheckboxVisible={canCreateTrustedBeneficiary && !isAccountClosing}
initialBeneficiary={match(initialBeneficiary)
.with({ kind: "new" }, identity)
.with({ kind: "saved" }, P.nullish, () => undefined)
Expand Down

0 comments on commit 4ff2c09

Please sign in to comment.