diff --git a/clients/banking/src/components/CardItemPhysicalDetails.tsx b/clients/banking/src/components/CardItemPhysicalDetails.tsx index 045b32c0d..c14ad9ca7 100644 --- a/clients/banking/src/components/CardItemPhysicalDetails.tsx +++ b/clients/banking/src/components/CardItemPhysicalDetails.tsx @@ -529,6 +529,7 @@ export const CardItemPhysicalDetails = ({ const textColor = hasBindingUserError ? colors.gray[300] : colors.gray[800]; const previousCard = card.physicalCard?.previousPhysicalCards[0]; const [currentCard, setCurrentCard] = useState<"previous" | "renewed">("renewed"); + const cardHolderType = card.accountMembership.account?.holder.info.type; return ( @@ -1587,34 +1588,35 @@ export const CardItemPhysicalDetails = ({ - {match(card.insuranceSubscription) - .with(P.nonNullable, ({ package: { level } }) => ( - - - - - {match(level) - .with("Basic", () => ( - {t("cardDetail.insurance.description.basic")} - )) - .with("Essential", () => ( - {t("cardDetail.insurance.description.essential")} - )) - .with("Premium", () => ( - - {t("cardDetail.insurance.description.premium")} - - )) - .otherwise(() => null)} - - )) - .otherwise(() => null)} + {cardHolderType === "Company" && + match(card.insuranceSubscription) + .with(P.nonNullable, ({ package: { level } }) => ( + + + + + {match(level) + .with("Basic", () => ( + {t("cardDetail.insurance.description.basic")} + )) + .with("Essential", () => ( + {t("cardDetail.insurance.description.essential")} + )) + .with("Premium", () => ( + + {t("cardDetail.insurance.description.premium")} + + )) + .otherwise(() => null)} + + )) + .otherwise(() => null)} (null); const cardInsurance = card.insuranceSubscription; + const cardHolderType = card.accountMembership.account?.holder.info.type; const { canUpdateCard } = usePermissions(); @@ -104,7 +105,7 @@ export const CardItemSettings = ({ cardId, accountMembershipId, card }: Props) = return ( - {({ small }) => ( + {({ small, large }) => ( <> {card.accountMembership.canManageCards ? null : ( <> @@ -134,68 +135,74 @@ export const CardItemSettings = ({ cardId, accountMembershipId, card }: Props) = - + - {cardInsurance != null && cardInsurance.package.noticeUrl != null && ( - <> - - - - - - {match(cardInsurance.package) - .with({ level: "Basic" }, () => - t("cardDetail.insurance.description.premium"), - ) - .with({ level: "Essential" }, () => - t("cardDetail.insurance.description.essential"), - ) - .with({ level: "Premium" }, () => - t("cardDetail.insurance.description.premium"), - ) - .otherwise(() => null)} - - - - - - - - - {t("cardDetail.insurance.link")} - + {cardInsurance != null && + cardInsurance.package.noticeUrl != null && + cardHolderType === "Company" && ( + <> + + + - - - - - + + {match(cardInsurance.package) + .with({ level: "Basic" }, () => + t("cardDetail.insurance.description.premium"), + ) + .with({ level: "Essential" }, () => + t("cardDetail.insurance.description.essential"), + ) + .with({ level: "Premium" }, () => + t("cardDetail.insurance.description.premium"), + ) + .otherwise(() => null)} + + + - - - {formatNestedMessage("cardDetail.insurance.claim", { - link: text => ( - <> - - - - {text} - + + + + {t("cardDetail.insurance.link")} + - - - - - - ), - })} + + + + - - - - )} + + + + {formatNestedMessage("cardDetail.insurance.claim", { + link: text => ( + <> + + + + {text} + + + + + + + + ), + })} + + + + + + )} diff --git a/clients/banking/src/components/CardItemVirtualDetails.tsx b/clients/banking/src/components/CardItemVirtualDetails.tsx index 77d66db8e..8fe7bf134 100644 --- a/clients/banking/src/components/CardItemVirtualDetails.tsx +++ b/clients/banking/src/components/CardItemVirtualDetails.tsx @@ -91,6 +91,7 @@ export const CardItemVirtualDetails = ({ }; const textColor = hasBindingUserError ? colors.gray[300] : colors.gray[800]; + const cardHolderType = card.accountMembership.account?.holder.info.type; return ( @@ -262,34 +263,35 @@ export const CardItemVirtualDetails = ({ - {match(card.insuranceSubscription) - .with(P.nonNullable, ({ package: { level } }) => ( - - - + {cardHolderType === "Company" && + match(card.insuranceSubscription) + .with(P.nonNullable, ({ package: { level } }) => ( + + + - {match(level) - .with("Basic", () => ( - {t("cardDetail.insurance.description.basic")} - )) - .with("Essential", () => ( - {t("cardDetail.insurance.description.essential")} - )) - .with("Premium", () => ( - - {t("cardDetail.insurance.description.premium")} - - )) - .otherwise(() => null)} - - )) - .otherwise(() => null)} + {match(level) + .with("Basic", () => ( + {t("cardDetail.insurance.description.basic")} + )) + .with("Essential", () => ( + {t("cardDetail.insurance.description.essential")} + )) + .with("Premium", () => ( + + {t("cardDetail.insurance.description.premium")} + + )) + .otherwise(() => null)} + + )) + .otherwise(() => null)} ); diff --git a/clients/banking/src/components/CardListCells.tsx b/clients/banking/src/components/CardListCells.tsx index 299d089f4..6282797fa 100644 --- a/clients/banking/src/components/CardListCells.tsx +++ b/clients/banking/src/components/CardListCells.tsx @@ -83,6 +83,7 @@ const cardChip = Lazy(() => ( export const FullNameAndCardTypeCell = ({ card }: { card: Card }) => { const spendingLimits = card.spendingLimits ?? []; + const cardHolderType = card.accountMembership.account?.holder.info.type; return ( @@ -128,7 +129,7 @@ export const FullNameAndCardTypeCell = ({ card }: { card: Card }) => { {t("cards.format.virtual")} - {isNotNullish(insuranceSubscription) && ( + {isNotNullish(insuranceSubscription) && cardHolderType === "Company" && ( <> @@ -171,7 +172,7 @@ export const FullNameAndCardTypeCell = ({ card }: { card: Card }) => { - {isNotNullish(insuranceSubscription) && ( + {isNotNullish(insuranceSubscription) && cardHolderType === "Company" && ( <> @@ -273,6 +274,7 @@ export const CardStatusCell = ({ card }: { card: Card }) => { export const CardSummaryCell = ({ card }: { card: Card }) => { const spendingLimits = card.spendingLimits ?? []; + const cardHolderType = card.accountMembership.account?.holder.info.type; return ( @@ -314,7 +316,7 @@ export const CardSummaryCell = ({ card }: { card: Card }) => { ariaLabel={t("cards.format.virtual")} /> - {isNotNullish(insuranceSubscription) && ( + {isNotNullish(insuranceSubscription) && cardHolderType === "Company" && ( <> @@ -354,7 +356,7 @@ export const CardSummaryCell = ({ card }: { card: Card }) => { .otherwise(() => undefined)} - {isNotNullish(insuranceSubscription) && ( + {isNotNullish(insuranceSubscription) && cardHolderType === "Company" && ( <> diff --git a/clients/banking/src/components/CardWizard.tsx b/clients/banking/src/components/CardWizard.tsx index f5a671044..16a2c86fa 100644 --- a/clients/banking/src/components/CardWizard.tsx +++ b/clients/banking/src/components/CardWizard.tsx @@ -557,12 +557,7 @@ export const CardWizard = ({ {match(step) .with({ name: "CardProductType" }, ({ cardProduct }) => ( ; - accountHolderType: AccountHolderType; + accountHolderType: AccountHolderType | undefined; cardProducts: NonNullable; initialCardProduct?: CardProduct; onSubmit: (cardProduct: CardProduct) => void; @@ -408,12 +408,12 @@ export const CardWizardProduct = ({ ), }), ) - .exhaustive()} + .otherwise(() => null)} - {defaultInsurancePackage != null && ( + {defaultInsurancePackage != null && accountHolderType === "Company" && ( diff --git a/clients/banking/src/graphql/partner.gql b/clients/banking/src/graphql/partner.gql index f44d98224..33a072d50 100644 --- a/clients/banking/src/graphql/partner.gql +++ b/clients/banking/src/graphql/partner.gql @@ -817,6 +817,7 @@ fragment CardListItem on Card { id info { name + type } } } @@ -1887,6 +1888,7 @@ query GetCardProducts( } accountMembership(id: $accountMembershipId) { id + accountHolderType account { id holder {