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

Pay with Business accounts #797

Merged
merged 43 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3f8dd3a
start business accounts ui payment methods
OmerGery Dec 31, 2023
53a46a6
wip
OmerGery Dec 31, 2023
52a750a
wip service estimation adapt
OmerGery Jan 1, 2024
4130ede
fix
OmerGery Jan 1, 2024
81e5c2d
add skelton. fix service estimation interval. hide business payment m…
OmerGery Jan 2, 2024
d447b80
show business tab only if at least 1 buiz payment method
OmerGery Jan 2, 2024
05e9076
display BA name in ride history and active
OmerGery Jan 2, 2024
c3089f5
add name of BA to future ride
OmerGery Jan 2, 2024
c4ba270
checkmark to the right
OmerGery Jan 3, 2024
509034e
style fix
OmerGery Jan 3, 2024
cf14a37
add mixpanels
OmerGery Jan 4, 2024
c2d94b9
update BA svg, add subtitle to BA payment card
OmerGery Jan 4, 2024
ac5be57
add subtitle
OmerGery Jan 4, 2024
59b9169
clean business account state
OmerGery Jan 4, 2024
967301a
Update styled.js
OmerGery Jan 4, 2024
d5b9e4d
Update index.tsx
OmerGery Jan 4, 2024
056ef46
extract to styled files @ormiz
OmerGery Jan 4, 2024
446eede
on submit AUT-18223 fix
OmerGery Jan 9, 2024
f7caae6
fix AUT-18227
OmerGery Jan 9, 2024
6dc4812
Update index.tsx
OmerGery Jan 9, 2024
5895bbf
add empty state for services and choose payment
OmerGery Jan 10, 2024
b50f5f2
always allow offline for BA
OmerGery Jan 15, 2024
dd22a5a
new logic of storing last BA
OmerGery Jan 15, 2024
a382c34
Merge branch 'master' into AUT-15088-business-accounts
OmerGery Jan 15, 2024
56aaae0
fixes
OmerGery Jan 15, 2024
b2d1db9
tabs not scrollable
OmerGery Jan 15, 2024
c606538
Update index.tsx
OmerGery Jan 15, 2024
2769430
remove Montserrat
OmerGery Jan 16, 2024
f42d74b
Update index.tsx
OmerGery Jan 16, 2024
05aa179
Revert "remove Montserrat"
OmerGery Jan 16, 2024
5801037
inter
OmerGery Jan 16, 2024
f312404
remove reason from business pay
OmerGery Jan 16, 2024
bc6dbc6
fix chosen method
OmerGery Jan 21, 2024
61554a9
fix add payment , rm BA id
OmerGery Jan 21, 2024
7cbc51d
fix for delete from BA
OmerGery Jan 21, 2024
61021d5
Update index.tsx
OmerGery Jan 21, 2024
6c0bdc9
fix active tab
OmerGery Jan 22, 2024
7505e92
cr
OmerGery Jan 23, 2024
cdb8558
cr2
OmerGery Jan 23, 2024
6dc5c8b
cr them context
OmerGery Jan 23, 2024
4b6b38c
CR styled
OmerGery Jan 23, 2024
cf64a87
fix flex
OmerGery Jan 23, 2024
8e4f6b5
fix div width of payment metod title
OmerGery Jan 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const ActiveRideContent = () => {
ride={ride}
/>
<RidePaymentDetails
rideId={ride.id || ''}
ride={ride}
paymentMethod={ride.payment?.paymentMethod}
state={ride.state}
currency={ride.priceCurrency}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { BoldTitle, SubTitle, TitleWithSubTitle } from './styled';

interface BusinessAccountTextProps {
title: string;
subTitle: string;
}
const BusinessAccountText = ({
title, subTitle,
} : BusinessAccountTextProps) => (
<TitleWithSubTitle>
<BoldTitle numberOfLines={1}>{title}</BoldTitle>
<SubTitle numberOfLines={1}>{subTitle}</SubTitle>
</TitleWithSubTitle>
);

export default BusinessAccountText;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Text, View } from 'react-native';
import styled from 'styled-components';

export const TitleWithSubTitle = styled(View)`
display: flex;
flex-direction: column;
flex: 1 0 0;
`;
export const BaseText = styled(Text)`
color: #212229;
font-family: Inter;
font-size: 14px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use theme context

font-style: normal;
line-height: 20px;
`;
export const SubTitle = styled(BaseText)`
font-weight: 500;
`;
export const BoldTitle = styled(BaseText)`
font-weight: 700;
`;
70 changes: 54 additions & 16 deletions examples/client/Locomotion/src/Components/CardRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { View, Text } from 'react-native';
import moment from 'moment';
import styled, { ThemeContext } from 'styled-components';
import { PaymentIcon } from 'react-native-payment-icons';
import BusinessAccountText from '../BusinessAccountText';
import { RideInterface, RidePageContext } from '../../context/newRideContext';
import { PAYMENT_METHODS, paymentMethodToIconMap } from '../../pages/Payments/consts';
import Button from '../Button';
import { capitalizeFirstLetter, getLastFourForamttedShort } from '../../pages/Payments/cardDetailUtils';
Expand All @@ -13,7 +15,7 @@ import SvgIcon from '../SvgIcon';
import selected from '../../assets/selected-v.svg';
import { Start, StartCapital } from '../../lib/text-direction';
import chevronIcon from '../../assets/chevron.svg';
import { isCashPaymentMethod } from '../../lib/ride/utils';
import { isCashPaymentMethod, isOfflinePaymentMethod } from '../../lib/ride/utils';
import paymentContext from '../../context/payments';

type ContainerProps = {
Expand Down Expand Up @@ -49,7 +51,7 @@ const margin = `margin-${Start()}`;
const TextContainer = styled(View)`
justify-content: center;
${margin}: 16px;
width: 80%;
width: ${({ noSvg } : { noSvg: boolean}) => (noSvg ? '95%' : '80%')};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use flex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undid the changes, it actually doesnt affect anything

`;

const Type = styled(Text)`
Expand Down Expand Up @@ -93,9 +95,28 @@ const style = {

const CardRow = (paymentMethod: any) => {
const { primaryColor } = useContext(ThemeContext);
const { offlinePaymentText, loadOfflinePaymentText } = paymentContext.useContainer();
const {
offlinePaymentText,
loadOfflinePaymentText,
getBusinessAccountNameById,
} = paymentContext.useContainer();
const { businessAccountId } = paymentMethod;
const [isCardExpired, setIsCardExpired] = useState(false);

const getPaymentMethodTitle = () => {
const businessAccountName = getBusinessAccountNameById(businessAccountId);
if (businessAccountName) {
return businessAccountName;
}
if (isCashPaymentMethod(paymentMethod)) {
return i18n.t('payments.cash');
}
if (isOfflinePaymentMethod(paymentMethod)) {
return offlinePaymentText;
}
return capitalizeFirstLetter(paymentMethod.name);
};

useEffect(() => {
loadOfflinePaymentText();
}, []);
Expand All @@ -111,11 +132,15 @@ const CardRow = (paymentMethod: any) => {
: (`${paymentMethod.testIdPrefix || ''}ChoosePaymentMethod${paymentMethod.id === PAYMENT_METHODS.OFFLINE || paymentMethod.id === PAYMENT_METHODS.CASH ? `_${paymentMethod.id}` : ''}`);

const getPaymentMethodIcon = () => {
if (paymentMethod.noSvg) {
return null;
}
const { brand, id, lastFour } = paymentMethod;
const isCard = lastFour;
if (isCard) {
return <PaymentIcon type={brand} />;
}
if (!paymentMethodToIconMap[id]) { return null; }
return (
<SvgIcon
fill={primaryColor}
Expand Down Expand Up @@ -154,7 +179,7 @@ const CardRow = (paymentMethod: any) => {
: (
<>
{getPaymentMethodIcon()}
{paymentMethod.mark ? (
{(paymentMethod.mark && !paymentMethod.alignMarkToRight) ? (
<SvgIcon
style={{
position: 'absolute',
Expand All @@ -170,7 +195,7 @@ const CardRow = (paymentMethod: any) => {
}

</ImageContainer>
<TextContainer>
<TextContainer noSvg={paymentMethod.noSvg}>
{paymentMethod.addNew
? (
<>
Expand All @@ -179,17 +204,19 @@ const CardRow = (paymentMethod: any) => {
)
: (
<>
{!paymentMethod.lastFour
? (
<Type>
{isCashPaymentMethod(paymentMethod) ? i18n.t('payments.cash') : offlinePaymentText }
</Type>
)
: (
<Type>
{capitalizeFirstLetter(paymentMethod.name)}
</Type>
)}
{
(businessAccountId && offlinePaymentText)
? (
<BusinessAccountText
title={getPaymentMethodTitle()}
subTitle={offlinePaymentText}
/>
)
: (
<Type>
{getPaymentMethodTitle()}
</Type>
)}
{paymentMethod.lastFour
? <Description>{getLastFourForamttedShort(paymentMethod.lastFour)}</Description>
: null}
Expand All @@ -205,6 +232,17 @@ const CardRow = (paymentMethod: any) => {
{paymentMethod.disabledReason}
</Description>
)}
{(paymentMethod.mark && paymentMethod.alignMarkToRight) ? (
<SvgIcon
style={{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it needs custom style? you may use flex to place it right

position: 'absolute',
right: 10,
bottom: 15,
}}
Svg={selected}
fill={primaryColor}
/>
) : null }
</Container>
</Button>
</>
Expand Down
26 changes: 26 additions & 0 deletions examples/client/Locomotion/src/Components/EmptyState/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import {
Container, Description, Title, TitleWithoutDescription,
} from './styled';

interface EmptyStateProps {
title: string;
description?: string;
}
const EmptyState = ({
title,
description,
}: EmptyStateProps) => (
<Container>
{description
? <Title>{title}</Title>
: <TitleWithoutDescription>{title}</TitleWithoutDescription>
}

{description ? <Description>{description}</Description> : null}
</Container>
);
EmptyState.defaultProps = {
description: '',
};
export default EmptyState;
42 changes: 42 additions & 0 deletions examples/client/Locomotion/src/Components/EmptyState/styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Text, View } from 'react-native';
import styled from 'styled-components';

export const Container = styled(View)`
border-radius: 8px;
border: 1px dashed rgba(125, 139, 172, 0.32);
display: flex;
padding: 16px;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 4px;
flex: 1 0 0;
align-self: stretch;
`;
export const Title = styled(Text)`
align-self: stretch;
color: #212229;
text-align: center;
font-family: Inter;
font-size: 14px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use theme context

font-style: normal;
font-weight: 600;
`;
export const Description = styled(Text)`
align-self: stretch;
color: #666975;
text-align: center;
font-family: Inter;
font-size: 14px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use theme context

font-style: normal;
font-weight: 400;
`;
export const TitleWithoutDescription = styled(Text)`
align-self: stretch;
color: #666975;
text-align: center;
font-family: Inter;
font-size: 14px;
font-style: normal;
font-weight: 500;
`;
24 changes: 20 additions & 4 deletions examples/client/Locomotion/src/Components/RideCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import StopPointsVerticalView from '../StopPointsVerticalView';
import { getFormattedPrice, isPriceEstimated, convertTimezoneByLocation } from '../../context/newRideContext/utils';
import cashIcon from '../../assets/cash.svg';
import offlineIcon from '../../assets/offline.svg';
import { PAYMENT_METHODS } from '../../pages/Payments/consts';
import PaymentContext from '../../context/payments';
import SettingsContext from '../../context/settings';
Expand All @@ -23,17 +24,26 @@ interface CardComponentProps {
brand: any;
id: string;
}
businessAccountId: string | undefined;
}
const CardComponent = ({ paymentMethod }: CardComponentProps) => {
const CardComponent = ({ paymentMethod, businessAccountId }: CardComponentProps) => {
const isCash = PAYMENT_METHODS.CASH === paymentMethod.id;
const isOffline = PAYMENT_METHODS.OFFLINE === paymentMethod.id;
const { offlinePaymentText, loadOfflinePaymentText } = PaymentContext.useContainer();
const {
offlinePaymentText,
loadOfflinePaymentText,
getBusinessAccountNameById,
} = PaymentContext.useContainer();

useEffect(() => {
loadOfflinePaymentText();
}, []);

const getText = () => {
const businessAccountName = getBusinessAccountNameById(businessAccountId);
if (businessAccountName) {
return businessAccountName;
}
if (isCash) {
return i18n.t('payments.cash');
} if (isOffline) {
Expand All @@ -47,12 +57,13 @@ const CardComponent = ({ paymentMethod }: CardComponentProps) => {
return cashIcon;
}
if (isOffline) {
return null;
return offlineIcon;
}
};
return (
<TextRowWithIcon
text={getText() || ''}
subTitle={businessAccountId ? offlinePaymentText : ''}
Image={() => !isCash && !isOffline && <PaymentIcon type={paymentMethod.brand} />}
icon={getIcon()}
style={{ marginTop: 10, marginBottom: 10 }}
Expand Down Expand Up @@ -168,7 +179,12 @@ const RideCard = ({
</DateContainer>

<StopPointsVerticalView ride={ride} />
{paymentMethod && <CardComponent paymentMethod={paymentMethod} />}
{paymentMethod && (
<CardComponent
paymentMethod={paymentMethod}
businessAccountId={ride.businessAccountId}
/>
)}
<RoundedButton testID="cancelRide" onPress={onPress} hollow type="cancel">
{i18n.t('home.cancelRideButton')}
</RoundedButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getFormattedPrice } from '../../context/newRideContext/utils';
import CardRow from '../CardRow';
import CardsTitle from '../CardsTitle';
import i18n from '../../I18n';
import { PriceCalculation, RidePageContext } from '../../context/newRideContext';
import { PriceCalculation, RideInterface, RidePageContext } from '../../context/newRideContext';
import {
PaymentRow, RidePriceDetails, PriceText, ViewDetails, CardRowContainer,
} from './styled';
Expand All @@ -16,12 +16,12 @@ import * as navigationService from '../../services/navigation';
import Button from '../Button';

const RidePaymentDetails = ({
rideId,
ride,
paymentMethod,
rideHistory = false,
state,
} :{
rideId: string,
ride: RideInterface,
paymentMethod: PaymentMethodInterface,
rideHistory: boolean
currency: string,
Expand All @@ -36,7 +36,7 @@ const RidePaymentDetails = ({
const { showPrice, loadShowPrice } = SettingsContext.useContainer();

const updatePriceCalculation = async () => {
const calculation = await getRidePriceCalculation(rideId);
const calculation = await getRidePriceCalculation(ride?.id);
setPriceCalculation(calculation);
};

Expand All @@ -53,7 +53,7 @@ const RidePaymentDetails = ({
<CardsTitle noPaddingLeft title={i18n.t('ride.paymentMethod')} />
<PaymentRow>
<CardRowContainer>
<CardRow {...paymentMethod} />
<CardRow {...{ ...paymentMethod, businessAccountId: ride.businessAccountId }} />
</CardRowContainer>
<RidePriceDetails>

Expand All @@ -74,7 +74,7 @@ const RidePaymentDetails = ({
testID="viewRidePaymentDetails"
noBackground
onPress={() => navigationService.navigate(MAIN_ROUTES.RIDE_PRICE_BREAKDOWN,
{ rideId, rideHistory })}
{ rideId: ride.id, rideHistory })}
>
{state !== RIDE_STATES.CANCELED
|| (state === RIDE_STATES.CANCELED
Expand Down
Loading
Loading