Skip to content

Commit

Permalink
Fix price breakdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolic committed Feb 7, 2024
1 parent a604dff commit 87877d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const RidePaymentDetails = ({
getRidePriceCalculation,
} = useContext(RidePageContext);

const { businessAccountId } = useContext(RidePageContext);
const { getBusinessAccountById } = PaymentContext.useContainer();
const { showPrice, loadShowPrice } = SettingContext.useContainer();

Expand All @@ -49,11 +48,9 @@ const RidePaymentDetails = ({

useEffect(() => {
updatePriceCalculation();
showPriceBasedOnAccount(loadShowPrice, getBusinessAccountById, ride.businessAccountId);
}, []);

useEffect(() => {
showPriceBasedOnAccount(loadShowPrice, getBusinessAccountById, businessAccountId);
}, [businessAccountId]);

return (paymentMethod ? (
<>
Expand Down
16 changes: 10 additions & 6 deletions examples/client/Locomotion/src/pages/RideHistory/RideCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { getPriceCalculation } from '../../../context/futureRides/api';
import RidePaymentDetails from '../../../Components/RidePaymentDetails';
import PaymentContext from '../../../context/payments';
import SettingContext from '../../../context/settings';
import { RidePageContext } from '../../../context/newRideContext';
import showPriceBasedOnAccount from '../../../services/showPriceBasedOnAccount';
import {
DaySecTitleSubText,
DaySecTitleText,
Expand Down Expand Up @@ -55,13 +53,19 @@ const RideTitleCard = ({
ride, page, showTip, tip, isPaymentRejected,
}) => {
const isDebuggingEnabled = (typeof atob !== 'undefined');
const { businessAccountId } = useContext(RidePageContext);
const { getBusinessAccountById } = PaymentContext.useContainer();
const { showPrice, loadShowPrice } = SettingContext.useContainer();

useEffect(() => {
showPriceBasedOnAccount(loadShowPrice, getBusinessAccountById, businessAccountId);
}, [businessAccountId]);
loadShowPrice();
}, []);

if (ride.businessAccountId) {
const { showPriceToMembers } = getBusinessAccountById(ride.businessAccountId);
ride.showPrice = showPriceToMembers;
} else {
ride.showPrice = showPrice;
}

const getTipButton = () => {
if (!isDebuggingEnabled && tip === null) {
Expand Down Expand Up @@ -126,7 +130,7 @@ const RideTitleCard = ({
) : <RideStateText>{i18n.t(`rideHistory.ride.states.${ride.state}`)}</RideStateText>}
</RideViewTextContainer>
<RideViewSecTextContainer>
{showPrice && (
{ride.showPrice && (
<DaySecTitleText markError={isPaymentRejected} testID="ridePrice">
{getFormattedPrice(ride.priceCurrency, ride.priceAmount)}
</DaySecTitleText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type LoadShowPriceFunction = (showPriceToMembers?: boolean) => void;
export default (
loadShowPrice: LoadShowPriceFunction,
getBusinessAccountById: GetBusinessAccountByIdFunction,
businessAccountId: string | null,
businessAccountId: string | null | undefined,
) => {
if (businessAccountId) {
const { showPriceToMembers } = getBusinessAccountById(businessAccountId);
Expand Down

0 comments on commit 87877d3

Please sign in to comment.