Skip to content

Commit

Permalink
Hide create button if no permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrine-ds committed Dec 6, 2024
1 parent ba0ada9 commit b8ebac8
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions clients/banking/src/components/MerchantProfilePaymentArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
MerchantPaymentsDocument,
MerchantPaymentsQuery,
} from "../graphql/partner";
import { usePermissions } from "../hooks/usePermissions";
import { t } from "../utils/i18n";
import { GetRouteParams, Router } from "../utils/routes";
import { Connection } from "./Connection";
Expand Down Expand Up @@ -142,6 +143,8 @@ type Props = {
export const MerchantProfilePaymentArea = ({ params, large }: Props) => {
const { merchantProfileId, accountMembershipId } = params;

const { canCreateMerchantPaymentLinks } = usePermissions();

const route = Router.useRoute([
"AccountMerchantsProfilePaymentsList",
"AccountMerchantsProfilePaymentsDetails",
Expand Down Expand Up @@ -277,23 +280,25 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => {
});
}}
>
<LakeTooltip
content={t("merchantProfile.paymentLink.button.new.disable")}
disabled={canCreatePayments}
>
<LakeButton
disabled={!canCreatePayments}
size="small"
icon="add-circle-filled"
color="current"
onPress={() => {
setShouldShowTopbar(false);
setPickerModal.open();
}}
{canCreateMerchantPaymentLinks && (
<LakeTooltip
content={t("merchantProfile.paymentLink.button.new.disable")}
disabled={canCreatePayments}
>
{t("merchantProfile.payments.button.new")}
</LakeButton>
</LakeTooltip>
<LakeButton
disabled={!canCreatePayments}
size="small"
icon="add-circle-filled"
color="current"
onPress={() => {
setShouldShowTopbar(false);
setPickerModal.open();
}}
>
{t("merchantProfile.payments.button.new")}
</LakeButton>
</LakeTooltip>
)}
</MerchantProfilePaymentListFilter>
</Box>
</>
Expand Down Expand Up @@ -343,7 +348,7 @@ export const MerchantProfilePaymentArea = ({ params, large }: Props) => {
}
}}
renderEmptyList={() =>
hasSearch ? (
hasSearch || !canCreateMerchantPaymentLinks ? (
<EmptyView
icon="lake-transfer"
borderedIcon={true}
Expand Down

0 comments on commit b8ebac8

Please sign in to comment.