Skip to content

Commit f5ea2cb

Browse files
authored
Merge pull request #108 from m2mathew/dev
2.12.0
2 parents 9d8dfc3 + f7b63e4 commit f5ea2cb

File tree

10 files changed

+605
-6
lines changed

10 files changed

+605
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tmac-website",
33
"description": "Website for the Texas Music Administrators Conference",
4-
"version": "2.11.0",
4+
"version": "2.12.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/m2mathew/tmac-website"

src/components/register/invoice-table.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const InvoiceTable = ({
8888
for the {currentSchoolYearLong} school year.
8989
</CustomTableCell>
9090
<CustomTableCell align="right">
91-
{isString ? updatedAmount : `$${updatedAmount.toFixed(2).toLocaleString()}`}
91+
{isString ? updatedAmount : `$${updatedAmount?.toFixed(2).toLocaleString()}`}
9292
</CustomTableCell>
9393
</TableRow>
9494
</TableBody>

src/components/register/register-stepper.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ function getSteps(
2424
isAuthenticated
2525
? 'Sign in to the TMAC members area'
2626
: 'Sign up for TMAC website login',
27-
'Complete membership form',
2827
isViewingSponsors
29-
? 'Choose Sponsor level and make payment'
28+
? 'Complete sponsor form'
29+
: 'Complete membership form',
30+
isViewingSponsors
31+
? 'Confirm Sponsor level and send payment'
3032
: 'Pay TMAC dues',
3133
];
3234
}

src/pages/events/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Box } from '@material-ui/core';
33
import PropTypes from 'prop-types';
44
import React from 'react';
55
import { Helmet } from 'react-helmet';
6-
import { Link, graphql } from 'gatsby';
6+
import { graphql } from 'gatsby';
77
import { makeStyles } from '@material-ui/styles';
88

99
// Internal Dependencies

src/pages/members/member-content.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import {
33
Box,
44
CircularProgress,
55
} from '@material-ui/core';
6+
import { Link } from 'gatsby';
67
import PropTypes from 'prop-types';
78
import React, { useEffect, useMemo, useState } from 'react';
89

910
// Internal Dependencies
1011
import EnhancedAlert from '../../components/shared/EnhancedAlert';
1112
import Cards from '../../components/shared/cards';
1213
import presets from '../../utils/presets';
13-
import { ADMIN_USER_EMAIL_LIST } from '../../utils/member-constants';
14+
import { ADMIN_USER_EMAIL_LIST, TMAC_WEB_ADMIN_EMAIL_LIST } from '../../utils/member-constants';
1415

1516
// Local Dependencies
1617
import MemberFileShareCard from './MemberFileShareCard';
@@ -76,6 +77,7 @@ const MemberContent = ({
7677
}
7778

7879
const isAdmin = authUser && ADMIN_USER_EMAIL_LIST.includes(authUser.email);
80+
const isTMACWebAdmin = authUser && TMAC_WEB_ADMIN_EMAIL_LIST.includes(authUser.email);
7981

8082
return (
8183
<div>
@@ -117,6 +119,13 @@ const MemberContent = ({
117119
))}
118120
</Cards>
119121

122+
{isTMACWebAdmin
123+
? (
124+
<Box component="p" mt={4}>
125+
View the <Link to="/members/sponsor-list">Sponsors</Link> for this year.
126+
</Box>
127+
) : null}
128+
120129
<div
121130
css={{
122131
display: 'block',

src/pages/members/sponsor-list.js

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// External Dependencies
2+
import { Helmet } from 'react-helmet';
3+
import { Typography } from '@material-ui/core';
4+
import { makeStyles } from '@material-ui/styles';
5+
import PropTypes from 'prop-types';
6+
import React, { useEffect, useState } from 'react';
7+
8+
// Internal Dependencies
9+
// import Alert from '../../components/shared/Alert';
10+
import AuthUserContext from '../../components/session/AuthUserContext';
11+
import EnhancedAlert from '../../components/shared/EnhancedAlert';
12+
import Layout from '../../components/layout';
13+
import SponsorListTable from './sponsor-table';
14+
import Status from './status';
15+
import presets from '../../utils/presets';
16+
import { doGetUsers } from '../../firebase/db';
17+
import { TMAC_WEB_ADMIN_EMAIL_LIST } from '../../utils/member-constants';
18+
19+
// Local Variables
20+
const propTypes = {
21+
isAuthenticated: PropTypes.bool.isRequired,
22+
location: PropTypes.shape({}).isRequired,
23+
userEmail: PropTypes.string,
24+
};
25+
26+
const defaultProps = {
27+
userEmail: '',
28+
};
29+
30+
const useStyles = makeStyles((theme) => ({
31+
adminCard: {
32+
borderLeft: `4px solid ${theme.palette.alert.info}`,
33+
maxWidth: '75%',
34+
},
35+
paddingContainer: {
36+
paddingLeft: 24,
37+
},
38+
root: {
39+
paddingLeft: 0,
40+
width: '0 auto',
41+
[presets.Tablet]: {
42+
paddingLeft: 0,
43+
},
44+
},
45+
}));
46+
47+
// Component Definition
48+
const SponsorListContent = ({
49+
isAuthenticated,
50+
userEmail,
51+
}) => {
52+
const classes = useStyles();
53+
54+
const [userData, setUserData] = useState([]);
55+
56+
console.log('userData', userData);
57+
58+
const handleUpdateUserList = (userList) => {
59+
setUserData(userList);
60+
};
61+
62+
useEffect(() => {
63+
const userList = [];
64+
65+
doGetUsers('sponsor', userList, handleUpdateUserList);
66+
}, []);
67+
68+
if (!userData || !isAuthenticated) {
69+
return null;
70+
}
71+
72+
const isTMACWebAdmin = userEmail && TMAC_WEB_ADMIN_EMAIL_LIST.includes(userEmail);
73+
74+
if (!isTMACWebAdmin) {
75+
return <Typography>This data is only available for admin users.</Typography>;
76+
}
77+
78+
return (
79+
<div className={classes.root}>
80+
<Status />
81+
82+
<Helmet>
83+
<title>TMAC | Sponsor List</title>
84+
</Helmet>
85+
86+
<div className={classes.paddingContainer}>
87+
<h2>Sponsor list</h2>
88+
89+
{isTMACWebAdmin && (
90+
<EnhancedAlert
91+
title="Admin View"
92+
severity="info"
93+
>
94+
You can print any sponsor&apos;s invoice or receipt from each row.
95+
</EnhancedAlert>
96+
)}
97+
98+
<SponsorListTable
99+
data={Object.values(userData)}
100+
isAdmin={isTMACWebAdmin}
101+
/>
102+
</div>
103+
</div>
104+
);
105+
};
106+
107+
SponsorListContent.propTypes = propTypes;
108+
SponsorListContent.defaultProps = defaultProps;
109+
110+
const SponsorList = (props) => (
111+
// eslint-disable-next-line
112+
<Layout location={props.location}>
113+
<SponsorListWithContext
114+
{...props}
115+
/>
116+
</Layout>
117+
);
118+
119+
const SponsorListWithContext = (props) => (
120+
<AuthUserContext.Consumer>
121+
{(authUser) => (
122+
<SponsorListContent
123+
{...props}
124+
userEmail={authUser ? authUser.email : ''}
125+
isAuthenticated={!!authUser}
126+
/>
127+
)}
128+
</AuthUserContext.Consumer>
129+
);
130+
131+
export default SponsorList;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// External Dependencies
2+
import {
3+
IconButton,
4+
Tooltip,
5+
} from '@material-ui/core';
6+
import PrintIcon from '@material-ui/icons/Print';
7+
import PropTypes from 'prop-types';
8+
import React, { Fragment, useRef } from 'react';
9+
import ReactToPrint from 'react-to-print';
10+
import ReceiptIcon from '@material-ui/icons/Receipt';
11+
import { makeStyles } from '@material-ui/styles';
12+
13+
// Internal Dependencies
14+
import Invoice from '../../../components/register/invoice';
15+
16+
// Local Variables
17+
const propTypes = {
18+
user: PropTypes.shape({
19+
PaymentOption: PropTypes.string.isRequired,
20+
userId: PropTypes.string.isRequired,
21+
}),
22+
};
23+
24+
const defaultProps = {
25+
user: null,
26+
};
27+
28+
const useStyles = makeStyles({
29+
icon: {
30+
height: 24,
31+
width: 24,
32+
},
33+
});
34+
35+
// Component Definition
36+
const MemberTableRowActionElements = ({ user }) => {
37+
const classes = useStyles();
38+
39+
const componentRef = useRef();
40+
41+
const hasReceipt = user && user.PaymentOption && user.PaymentOption.toLowerCase() === 'paypal';
42+
const hasInvoice = user && user.PaymentOption && user.PaymentOption.toLowerCase() === 'invoiced';
43+
44+
if (hasReceipt) {
45+
return (
46+
<Fragment key={`print-receipt-${user.userId}`}>
47+
<ReactToPrint
48+
content={() => componentRef.current}
49+
trigger={() => (
50+
<Tooltip title="Print receipt">
51+
<IconButton aria-label="Print receipt">
52+
<ReceiptIcon className={classes.icon} />
53+
</IconButton>
54+
</Tooltip>
55+
)}
56+
/>
57+
58+
<div css={{ display: 'none' }}>
59+
<Invoice
60+
amount={user.AmountDonated}
61+
form={user}
62+
isInvoice={false}
63+
receiptId={user.receiptId}
64+
ref={componentRef}
65+
sponsorLevel={user.SponsorLevel}
66+
/>
67+
</div>
68+
</Fragment>
69+
);
70+
}
71+
72+
if (hasInvoice) {
73+
return (
74+
<Fragment key={`print-invoice-${user.userId}`}>
75+
<ReactToPrint
76+
content={() => componentRef.current}
77+
trigger={() => (
78+
<Tooltip title="Print invoice">
79+
<IconButton aria-label="Print invoice">
80+
<PrintIcon className={classes.icon} />
81+
</IconButton>
82+
</Tooltip>
83+
)}
84+
/>
85+
86+
<div css={{ display: 'none' }}>
87+
<Invoice
88+
amount={user.AmountDonated}
89+
form={user}
90+
invoiceId={user.invoiceId || 1}
91+
isInvoice
92+
ref={componentRef}
93+
sponsorLevel={user.SponsorLevel}
94+
/>
95+
</div>
96+
</Fragment>
97+
);
98+
}
99+
return null;
100+
};
101+
102+
MemberTableRowActionElements.propTypes = propTypes;
103+
MemberTableRowActionElements.defaultProps = defaultProps;
104+
105+
export default MemberTableRowActionElements;

0 commit comments

Comments
 (0)