Skip to content

Commit

Permalink
feat: register tariff for group pass & show alert
Browse files Browse the repository at this point in the history
Refs: #UPS-5301
  • Loading branch information
d-vostrikov committed Dec 16, 2024
1 parent 8efdf82 commit ecd1406
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
16 changes: 13 additions & 3 deletions src/mobile/feature-saving/components/GroupPass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -28,11 +38,11 @@ export const GroupPass = ({ groupPass }: GroupPassProps) => {
<OpportunityStateGrouppass groupPass={groupPass} />
</Stack>

{/* {alertData && (
{alertData && (
<Alert type={alertData.alertType} newAlert={!firstCardEntry}>
{alertData.message}
</Alert>
)} */}
)}
</Stack>
);
};
16 changes: 11 additions & 5 deletions src/mobile/feature-saving/components/MobileSavingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
});
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -277,7 +279,11 @@ export const MobileSavingPage = () => {
/>
) : (
groupPassHolder?.data.member?.[0] && (
<GroupPass groupPass={groupPassHolder?.data.member?.[0]} />
<GroupPass
groupPass={groupPassHolder?.data.member?.[0]}
firstCardEntry={firstCardEntry}
alertData={alertData}
/>
)
)}

Expand Down
8 changes: 5 additions & 3 deletions src/mobile/feature-saving/components/tariff/TariffCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ export const TariffCard = ({
<StepperField
value={stepperCount}
onChange={setStepperCount}
subtitle={t("saving.mobile.tariff.card.discountsAvailable", {
count: calculatedRemainingDiscounts,
{...(remainingDiscounts && {
subtitle: t("saving.mobile.tariff.card.discountsAvailable", {
count: calculatedRemainingDiscounts,
}),
maxValue: remainingDiscounts,
})}
maxValue={remainingDiscounts}
/>
</Box>
)}
Expand Down

0 comments on commit ecd1406

Please sign in to comment.