Skip to content

Commit

Permalink
Style sources
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlovin committed Feb 14, 2018
1 parent 56c91dd commit 64e2dcd
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 10 deletions.
15 changes: 15 additions & 0 deletions public/img/jcb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/img/payment-methods/amex.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/img/payment-methods/diners-club.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/img/payment-methods/discover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/img/payment-methods/mastercard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/img/payment-methods/visa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions src/views/communityBilling/components/source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// @flow
import * as React from 'react';
import {
SourceContainer,
SourceText,
SourceName,
SourceExpiration,
} from '../style';

type Props = {
source: {
sourceId: string,
card: {
brand: string,
last4: string,
exp_month: number,
exp_year: number,
},
},
};

const getCardImage = (brand: string) => {
switch (brand) {
case 'Visa':
return '/img/payment-methods/visa.svg';
case 'Discover':
return '/img/payment-methods/discover.svg';
case 'Diners Club':
return '/img/payment-methods/diners-club.svg';
case 'MasterCard':
return '/img/payment-methods/mastercard.svg';
case 'American Express':
return '/img/payment-methods/amex.svg';
default:
return '/img/payment-methods/card-unknown.svg';
}
};

class Source extends React.Component<Props> {
render() {
const { source } = this.props;
const imageSrc = getCardImage(source.card.brand);
return (
<SourceContainer>
<img src={imageSrc} width={48} />
<SourceText>
<SourceName>
{source.card.brand} ending in {source.card.last4}
</SourceName>
<SourceExpiration>
Expires {source.card.exp_month}/{source.card.exp_year}
</SourceExpiration>
</SourceText>
</SourceContainer>
);
}
}

export default Source;
14 changes: 4 additions & 10 deletions src/views/communityBilling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import viewNetworkHandler, {
type ViewNetworkHandlerType,
} from '../../components/viewNetworkHandler';
import { Loading } from '../../components/loading';
import Source from './components/source';

type Props = {
...$Exact<ViewNetworkHandlerType>,
Expand All @@ -36,7 +37,7 @@ class CommunityMembersSettings extends React.Component<Props> {
render() {
const { data, isLoading } = this.props;
const { community } = data;
console.log(community);

if (community && community.id && community.communityPermissions.isOwner) {
if (!community.billingSettings.administratorEmail) {
return (
Expand All @@ -59,17 +60,10 @@ class CommunityMembersSettings extends React.Component<Props> {

<Column>
<SectionCard>
<SectionTitle>Sources</SectionTitle>
<SectionTitle>Payment Method</SectionTitle>
{community.billingSettings.sources.map(
source =>
source && (
<p key={source.sourceId}>
{source.sourceId} · {source.card.last4} ·{' '}
{source.card.brand} · Exp {source.card.exp_month}/{
source.card.exp_year
}
</p>
)
source && <Source key={source.sourceId} source={source} />
)}
</SectionCard>

Expand Down
24 changes: 24 additions & 0 deletions src/views/communityBilling/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,27 @@ export const EmailForm = styled.form`
margin-left: 16px;
}
`;

export const SourceContainer = styled.div`
display: flex;
align-items: center;
`;
export const SourceText = styled.p`
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
margin-left: 12px;
`;
export const SourceName = styled.p`
line-height: 1.3;
font-size: 15px;
font-weight: 500;
color: ${props => props.theme.text.default};
`;
export const SourceExpiration = styled.p`
line-height: 1.3;
font-size: 14px;
font-weight: 400;
color: ${props => props.theme.text.alt};
`;

0 comments on commit 64e2dcd

Please sign in to comment.