From ecd1406a66fa7977565b0db4be10448ff3aeb03c Mon Sep 17 00:00:00 2001 From: Dmitriy Vostrikov Date: Sun, 15 Dec 2024 17:15:14 +0100 Subject: [PATCH] feat: register tariff for group pass & show alert Refs: #UPS-5301 --- .../feature-saving/components/GroupPass.tsx | 16 +++++++++++++--- .../components/MobileSavingPage.tsx | 16 +++++++++++----- .../components/tariff/TariffCard.tsx | 8 +++++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/mobile/feature-saving/components/GroupPass.tsx b/src/mobile/feature-saving/components/GroupPass.tsx index be8e262..36b7d79 100644 --- a/src/mobile/feature-saving/components/GroupPass.tsx +++ b/src/mobile/feature-saving/components/GroupPass.tsx @@ -4,12 +4,22 @@ import { Grouppass } from "@/shared/lib/dataAccess"; import { useTranslation } from "@/shared/lib/utils/hooks"; import { Stack, Typography, useTheme } from "@mui/material"; import { OpportunityStateGrouppass } from "./OpportunityStateGrouppass"; +import { Alert } from "@/mobile/lib/ui"; type GroupPassProps = { groupPass: Grouppass; + alertData?: { + alertType: "error" | "success"; + message?: string; + }; + firstCardEntry: boolean; }; -export const GroupPass = ({ groupPass }: GroupPassProps) => { +export const GroupPass = ({ + groupPass, + alertData, + firstCardEntry, +}: GroupPassProps) => { const { t } = useTranslation(); const theme = useTheme(); @@ -28,11 +38,11 @@ export const GroupPass = ({ groupPass }: GroupPassProps) => { - {/* {alertData && ( + {alertData && ( {alertData.message} - )} */} + )} ); }; diff --git a/src/mobile/feature-saving/components/MobileSavingPage.tsx b/src/mobile/feature-saving/components/MobileSavingPage.tsx index c8e91f5..bc63533 100644 --- a/src/mobile/feature-saving/components/MobileSavingPage.tsx +++ b/src/mobile/feature-saving/components/MobileSavingPage.tsx @@ -104,7 +104,7 @@ export const MobileSavingPage = () => { setAlertData({ alertType: "success", message: t("saving.mobile.tariff.discountRegistered", { - price: data.data.at(0)?.tariff.price, + price: (data.data.at(0)?.tariff?.price ?? 0) * data.data.length, }), }); }, @@ -167,11 +167,13 @@ export const MobileSavingPage = () => { passHoldersData?.data.member?.[0]?.cardSystemMemberships?.[0] ?.uitpasNumber; - if (!uitpasNumber) return; + if (!uitpasNumber || !selectedActivity["@id"]) return; + + if (!count) count = 1; postTicketSale({ - data: Array.of({ - eventId: getUuid(selectedActivity?.["@id"] ?? ""), + data: Array(count).fill({ + eventId: getUuid(selectedActivity["@id"]), tariff: { id: tariffId, }, @@ -277,7 +279,11 @@ export const MobileSavingPage = () => { /> ) : ( groupPassHolder?.data.member?.[0] && ( - + ) )} diff --git a/src/mobile/feature-saving/components/tariff/TariffCard.tsx b/src/mobile/feature-saving/components/tariff/TariffCard.tsx index d2466cd..4883aa3 100644 --- a/src/mobile/feature-saving/components/tariff/TariffCard.tsx +++ b/src/mobile/feature-saving/components/tariff/TariffCard.tsx @@ -114,10 +114,12 @@ export const TariffCard = ({ )}