Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web banking - Add permissions to display digital card #1046

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading