Skip to content

Commit

Permalink
Web banking - Add permissions to display digital card (#1046)
Browse files Browse the repository at this point in the history
* Web banking - Add permissions to display digital card

* fix logic
  • Loading branch information
sandrine-ds authored Dec 5, 2024
1 parent 7b32983 commit 53f64c0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
9 changes: 7 additions & 2 deletions clients/banking/src/components/CardItemArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const CardItemArea = ({ accountMembershipId, userId, cardId, large = true
"AccountCardsItemOrderAddress",
]);

const { canPrintPhysicalCard } = usePermissions();
const { canPrintPhysicalCard, canReadOtherMembersCards } = usePermissions();
const [data, { refresh }] = useQuery(CardPageDocument, { cardId });

useCrumb(
Expand Down Expand Up @@ -135,8 +135,12 @@ export const CardItemArea = ({ accountMembershipId, userId, cardId, large = true
},
]
: []),
...match({ isCurrentUserCardOwner, card })
...match({ isCurrentUserCardOwner, card, canReadOtherMembersCards })
.with(
{
canReadOtherMembersCards: true,
card: { type: P.not("SingleUseVirtual") },
},
{ isCurrentUserCardOwner: true, card: { type: P.not("SingleUseVirtual") } },
() => [
{
Expand Down Expand Up @@ -229,6 +233,7 @@ export const CardItemArea = ({ accountMembershipId, userId, cardId, large = true
<Space height={24} />

<CardItemMobilePayment
isCurrentUserCardOwner={isCurrentUserCardOwner}
card={card}
onRefreshRequest={() => {
refresh();
Expand Down
28 changes: 19 additions & 9 deletions clients/banking/src/components/CardItemMobilePayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ type CompleteDigitalCard = DigitalCardFragment & { __typename: "CompleteDigitalC

const DigitalCardTile = ({
digitalCard,
isCurrentUserCardOwner,
onPressCancel,
}: {
digitalCard: CompleteDigitalCard;
isCurrentUserCardOwner: boolean;
onPressCancel: () => void;
}) => {
const deviceName = digitalCard.device.name ?? t("card.mobilePayment.unnamed");
Expand Down Expand Up @@ -84,25 +86,32 @@ const DigitalCardTile = ({
</LakeText>
</View>

<LakeTooltip placement="left" content={t("card.mobilePayment.disconnect")}>
<LakeButton
mode="tertiary"
ariaLabel={t("card.mobilePayment.cancel")}
icon="subtract-circle-regular"
onPress={onPressCancel}
/>
</LakeTooltip>
{isCurrentUserCardOwner && (
<LakeTooltip placement="left" content={t("card.mobilePayment.disconnect")}>
<LakeButton
mode="tertiary"
ariaLabel={t("card.mobilePayment.cancel")}
icon="subtract-circle-regular"
onPress={onPressCancel}
/>
</LakeTooltip>
)}
</Box>
</Tile>
);
};

type Props = {
card: Card;
isCurrentUserCardOwner: boolean;
onRefreshRequest: () => void;
};

export const CardItemMobilePayment = ({ card, onRefreshRequest }: Props) => {
export const CardItemMobilePayment = ({
card,
onRefreshRequest,
isCurrentUserCardOwner,
}: Props) => {
const [cancelConfirmationModalModal, setCancelConfirmationModalModal] = useState<
Option<CompleteDigitalCard>
>(Option.None());
Expand Down Expand Up @@ -152,6 +161,7 @@ export const CardItemMobilePayment = ({ card, onRefreshRequest }: Props) => {
digitalCards.map(digitalCard => (
<Fragment key={digitalCard.id}>
<DigitalCardTile
isCurrentUserCardOwner={isCurrentUserCardOwner}
digitalCard={digitalCard}
onPressCancel={() => setCancelConfirmationModalModal(Option.Some(digitalCard))}
/>
Expand Down

0 comments on commit 53f64c0

Please sign in to comment.