-
Notifications
You must be signed in to change notification settings - Fork 14
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
Changes from 15 commits
3f8dd3a
53a46a6
52a750a
4130ede
81e5c2d
d447b80
05e9076
c3089f5
c4ba270
509034e
cf14a37
c2d94b9
ac5be57
59b9169
967301a
d5b9e4d
056ef46
446eede
f7caae6
6dc4812
5895bbf
b50f5f2
dd22a5a
a382c34
56aaae0
b2d1db9
c606538
2769430
f42d74b
05aa179
5801037
f312404
bc6dbc6
61554a9
7cbc51d
61021d5
6c0bdc9
7505e92
cdb8558
6dc5c8b
4b6b38c
cf64a87
8e4f6b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { Text, View } from 'react-native'; | ||
import styled from 'styled-components'; | ||
|
||
const TitleWithSubTitle = styled(View)` | ||
display: flex; | ||
flex-direction: column; | ||
flex: 1 0 0; | ||
`; | ||
const BaseText = styled(Text)` | ||
color: #212229; | ||
font-family: Montserrat; | ||
font-size: 14px; | ||
font-style: normal; | ||
line-height: 20px; | ||
`; | ||
const SubTitle = styled(BaseText)` | ||
font-weight: 500; | ||
`; | ||
const BoldTitle = styled(BaseText)` | ||
font-weight: 700; | ||
`; | ||
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 |
---|---|---|
|
@@ -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'; | ||
|
@@ -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 = { | ||
|
@@ -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%')}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use flex There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undid the changes, it actually doesnt affect anything |
||
`; | ||
|
||
const Type = styled(Text)` | ||
|
@@ -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(); | ||
}, []); | ||
|
@@ -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} | ||
|
@@ -154,7 +179,7 @@ const CardRow = (paymentMethod: any) => { | |
: ( | ||
<> | ||
{getPaymentMethodIcon()} | ||
{paymentMethod.mark ? ( | ||
{(paymentMethod.mark && !paymentMethod.alignMarkToRight) ? ( | ||
<SvgIcon | ||
style={{ | ||
position: 'absolute', | ||
|
@@ -170,7 +195,7 @@ const CardRow = (paymentMethod: any) => { | |
} | ||
|
||
</ImageContainer> | ||
<TextContainer> | ||
<TextContainer noSvg={paymentMethod.noSvg}> | ||
{paymentMethod.addNew | ||
? ( | ||
<> | ||
|
@@ -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} | ||
|
@@ -205,6 +232,17 @@ const CardRow = (paymentMethod: any) => { | |
{paymentMethod.disabledReason} | ||
</Description> | ||
)} | ||
{(paymentMethod.mark && paymentMethod.alignMarkToRight) ? ( | ||
<SvgIcon | ||
style={{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
</> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to styles file